Ejemplo n.º 1
0
  private void showRouteStops(List<Stop> stops) {
    if (stops == null) {
      status.setText("Route stops could not be loaded"); // TODO why?
      status.setVisibility(View.VISIBLE);
      return;
    }

    Drawable drawable = getResources().getDrawable(R.drawable.marker);
    final StopsItemizedOverlay itemizedOverlay = new StopsItemizedOverlay(drawable, mapView);
    for (Stop stop : stops) {
      itemizedOverlay.addOverlay(new StopOverlayItem(stop));
    }

    final List<Overlay> overlays = mapView.getOverlays();
    overlays.add(itemizedOverlay);
    overlays.add(new RouteOverlayItem(stops));
    mapView.postInvalidate();

    routeStops = stops;

    if (selectedStop != null) {
      zoomMapToLocation(
          KnownStopLocationProviderService.makeLocationForSelectedStop(
              DistanceMeasuringService.findClosestOf(
                  routeStops,
                  KnownStopLocationProviderService.makeLocationForSelectedStop(selectedStop))));
    }
  }
Ejemplo n.º 2
0
  public void onLocationChanged(Location location) {
    Log.i(
        TAG,
        "Handset location update received: "
            + DistanceMeasuringService.makeLocationDescription(location));
    status.setText("Location found: " + DistanceMeasuringService.makeLocationDescription(location));
    status.setVisibility(View.VISIBLE);

    locationCircleOverlay.setPoint(location);
    mapView.postInvalidate();

    if (currentLocation == null && routeStops != null) {
      zoomMapToLocation(
          KnownStopLocationProviderService.makeLocationForSelectedStop(
              DistanceMeasuringService.findClosestOf(routeStops, location)));
      currentLocation = location;
    }
  }