public void centerOnUserLocation() {
   GeoPoint p = locationOverlay.getMyLocation();
   if (p == null) {
     p = new GeoPoint(MAP_CENTER_LATITUDE, MAP_CENTER_LONGITUDE);
     Toast.makeText(mContext, "Sorry! Could not determine your location.", Toast.LENGTH_SHORT);
   }
   mapView.getController().animateTo(p);
 }
 public GeoPoint getCurrentUserLocation() {
   return locationOverlay.getMyLocation();
 }
 public void enableLocationOverlay() {
   locationOverlay.enableMyLocation();
   locationOverlay.enableCompass();
 }
 public void disableLocationOverlays() {
   locationOverlay.disableMyLocation();
   locationOverlay.disableCompass();
 }
  ///////////////////////////////// THIS INITIALIZES ALL THE MAP
  // OVERLAYS///////////////////////////////////
  private void initializeOverlays(final Context c) {
    // set up location overlay
    locationOverlay = new DirectionLocationOverlay(c, mapView, mResourceProxy);
    locationOverlay.setLocationUpdater(locationUpdateListener);

    // set up path overlay to draw the path as required
    pathOverlay = new CustomPathOverlay(c);
    pathOverlay.setStrokeWidth(STROKE_WIDTH);
    pathOverlay.setTransparency(PATH_TRANSPARENCY);

    MARKER_BASE_OFFSET =
        (int)
            Math.round(
                -1
                    * mapView
                        .getResources()
                        .getDrawable(R.drawable.path_direction_marker)
                        .getIntrinsicHeight()
                    / 1.5);
    pathIndicatorOverlays =
        new ItemizedIconOverlay<OverlayItem>(
            new ArrayList<OverlayItem>(),
            new ItemizedIconOverlay.OnItemGestureListener<OverlayItem>() {
              @Override
              public boolean onItemSingleTapUp(final int index, final OverlayItem item) {
                balloonOverlay.setMarkerBaseOffset(MARKER_BASE_OFFSET);
                balloonOverlay.setBalloonOverlay(item, 2);
                mapView.getController().animateTo(item.mGeoPoint);
                mapView.postInvalidate();
                return true;
              }

              @Override
              public boolean onItemLongPress(final int index, final OverlayItem item) {
                return false;
              }
            },
            mResourceProxy,
            1);

    // three default categories displayed. change/add/modify later as reqd
    categoriesDisplayed.add(Const.ATTRACTION);
    categoriesDisplayed.add(Const.BUS);
    categoriesDisplayed.add(Const.TRAM);
    categoriesDisplayed.add(Const.TRAIN);
    categoriesDisplayed.add(Const.CABLE);
    categoriesDisplayed.add(Const.BUS_INT);
    categoriesDisplayed.add(Const.MRT);
    categoriesDisplayed.add(Const.CABLEWAY);

    // set up the poi markers as required
    float densityFactor =
        TypedValue.applyDimension(
            TypedValue.COMPLEX_UNIT_DIP, 1, mContext.getResources().getDisplayMetrics());
    markerPointsOverlay =
        new ItemizedIconOverlay<OverlayItem>(
            new ArrayList<OverlayItem>(),
            new ItemizedIconOverlay.OnItemGestureListener<OverlayItem>() {
              @Override
              public boolean onItemSingleTapUp(final int index, final OverlayItem item) {
                balloonOverlay.setMarkerBaseOffset(0);
                balloonOverlay.setBalloonOverlay(item, 1);
                mapView.getController().animateTo(item.mGeoPoint);
                mapView.postInvalidate();
                return true;
              }

              @Override
              public boolean onItemLongPress(final int index, final OverlayItem item) {
                if (IS_DEBUG) {
                  testStartPoint = item.getPoint();
                  Toast.makeText(
                          c,
                          "selected point: "
                              + item.getPoint().getLatitudeE6()
                              + ","
                              + item.getPoint().getLongitudeE6(),
                          Toast.LENGTH_SHORT)
                      .show();
                }
                return false;
              }
            },
            mResourceProxy,
            MARKER_SCALE / densityFactor);

    // set up the balloon overlay to display whenever an attraction/interchange point is tapped
    balloonOverlay =
        new CustomBalloonOverlay(
            c,
            new ItemizedIconOverlay.OnItemGestureListener<OverlayItem>() {
              @Override
              public boolean onItemSingleTapUp(final int index, final OverlayItem item) {
                if (IS_DEBUG)
                  Toast.makeText(
                          c,
                          "Tapped blue arrow '"
                              + item.mTitle
                              + "' (index="
                              + index
                              + ") got single tapped up",
                          Toast.LENGTH_LONG)
                      .show();
                if (item.getUid().contains("path_indicator")) {
                  try {
                    String[] idData = item.getUid().split(":");
                    if (idData.length > 0) {
                      ((MapActivity) mContext).directionsPosition = Integer.parseInt(idData[0]);
                    }

                    if (((MapActivity) mContext).mapDirections != null)
                      ((MapActivity) mContext).mapDirections.performClick();
                  } catch (Exception e) {
                  }
                  return true; // return if it is a path indicator balloon
                }
                Intent intent = new Intent(c, NodeDetailActivity.class);
                intent.putExtra(Const.NODE_ID, Integer.parseInt(item.getUid()));
                intent.putExtra(
                    Const.FlurryStrings.FlurryEventName,
                    Const.FlurryStrings.LocationDetailsSourceMap);
                ((MapActivity) c)
                    .startActivityForResult(intent, MapActivity.ROUTE_DESTINATION_REQUEST_CODE);
                return true;
              }

              @Override
              public boolean onItemLongPress(final int index, final OverlayItem item) {
                return false;
              }
            });

    // Adding overlays
    mapView.getOverlays().add(pathOverlay);
    mapView.getOverlays().add(markerPointsOverlay);
    mapView.getOverlays().add(pathIndicatorOverlays);
    mapView.getOverlays().add(balloonOverlay);
    mapView.getOverlays().add(locationOverlay);
  }