Set multiple marker in osmdroid

Asked by At

Hi everyone I'm using osmdroid in my application. I have a list of Latitude and Longitude sets and want to show them on the map and each one should be clickable means when I click on one of them it opens new specific activity. so how i suppose to do that ? I want to do something just like this :

Sadly i couldn't find much information about working with osmdroid so any help would be appreciated.

This is how i used osmdroid map

    mapView.setTileSource(TileSourceFactory.MAPNIK);
    IMapController mapController = mapView.getController();
    mapController.setZoom(9.5);
    GeoPoint startPoint = new GeoPoint(34.796830, 48.514820);
    mapController.setCenter(startPoint);
    mapView.setBuiltInZoomControls(true);
    mapView.setMultiTouchControls(true);

And this is overlays with geopoints :

List<OverlayItem> mItem = new ArrayList<OverlayItem>();
    Drawable mMarker = this.getResources().getDrawable(R.drawable.marker_default);
 GeoPoint point;
        if (nearestDiscountsList.size()>0) {
            for (int i = 0; i < nearestDiscountsList.size(); i++) {
                point = new 
GeoPoint(Double.parseDouble(nearestDiscountsList.get(i).getLatitude()), 
Double.parseDouble(nearestDiscountsList.get(i).getLongitude()));
                OverlayItem overlayItem = new OverlayItem("Here", 
"sampleDescription", point);
                overlayItem.setMarker(mMarker);
                mItem.add(overlayItem);
            }
        }

But I do not know where to add these ):

Even any sample code about this will do the job.

0 Answers