Search code examples
androiddictionaryandroid-mapviewosmdroid

Get Marker (org.osmdroid.bonuspack.overlays) from mMapView.getOverlays()


I'm using OSMDroid. I put my overlays marker in map view with

Marker startMarker = new Marker(mMapView);
startMarker.setPosition(VBA.getPosition());
startMarker.setIcon(getResources().getDrawable(R.drawable.ic_location_big));
startMarker.setTitle(VBA.getHotelName());
etc...

...
mMapView.getOverlays().add(startMarker);

Now i have to get all markers (for example thanks a foreach) to add a listener


Solution

  • mMapView MapView.getOverlays() returns a List of Overlay. Easy to scan.

    Then to check if an overlay is a Marker:

    if (overlay instanceof Marker) { ... }