コード例 #1
0
  @Override
  public void showRoute(
      final double fromLat, final double fromLon, final double toLat, final double toLon) {

    Log.debug("calculating path " + fromLat + "," + fromLon + " to " + toLat + "," + toLon);

    Projection proj = mapView.getLayers().getBaseLayer().getProjection();
    stopMarker.setMapPos(proj.fromWgs84(toLon, toLat));

    CloudMadeDirections directionsService =
        new CloudMadeDirections(
            this,
            new MapPos(fromLon, fromLat),
            new MapPos(toLon, toLat),
            CloudMadeDirections.ROUTE_TYPE_CAR,
            CloudMadeDirections.ROUTE_TYPE_MODIFIER_FASTEST,
            CLOUDMADE_KEY,
            proj);
    directionsService.route();
  }
コード例 #2
0
  @Override
  public void routeResult(Route route) {

    if (route.getRouteResult() != Route.ROUTE_RESULT_OK) {
      Toast.makeText(this, "Route error", Toast.LENGTH_LONG).show();
      return;
    }

    routeLayer.clear();
    routeLayer.add(route.getRouteLine());
    Log.debug("route line points: " + route.getRouteLine().getVertexList().size());
    //        Log.debug("route line: "+route.getRouteLine().toString());
    markerLayer.addAll(
        CloudMadeDirections.getRoutePointMarkers(
            routeImages, MARKER_SIZE, route.getInstructions()));
    mapView.requestRender();
    Toast.makeText(this, "Route " + route.getRouteSummary(), Toast.LENGTH_LONG).show();
  }