0

I've a mapView on which I managed to get an overlay onLongPress with the help of GestureListener. What I actually want is, I want to add markers (with same icon) one by one. Like I want to mark different positions on map (not all at once). Any help with this would be great as am newbie with MapView and Overlays.

ark
  • 553
  • 2
  • 11
  • 19

1 Answers1

1

Use ItemizedOverlay class to add drawable on specific longitudes and latitudes.

In your MapActivity write

GeoPoint your_point = (Provide geopoint information here);

Drawable drawable = this.getResources().getDrawable(R.drawable.your_point_image);

HelloItemizedOverlay itemizedoverlay = new HelloItemizedOverlay( drawable, MapsActivity.this, mapView); GeoPoint point = new GeoPoint((int) (your_point.getLat() * 1E6), (int) (your_point.getLon() * 1E6));

OverlayItem overlayitem1 = new OverlayItem(your_point);

itemizedoverlay.addOverlay(overlayitem1); mapView.getOverlays().add(itemizedoverlay);

Where

HelloItemizedOverlay extends ItemizedOverlay{

public HelloItemizedOverlay(Drawable defaultMarker, Activity context, MapView mapView) { super(boundCenterBottom(defaultMarker)); mContext = context; this.mapView = mapView;

}

}

I did it this way and it works.

Fahad Ishaque
  • 1,916
  • 1
  • 17
  • 21