Question

In Google maps v1 you know which focus overlayItem, with overlayItem.getfocus().

mPlaceOverlay = new ItemizedOverlay(icon, mMapView, this);
OverlayItem myFocusOverlayItem = null;
myFocusOverlayItem = mPlaceOverlay.getFocus();

But now in Google maps v2 I don't know which is the marker.I hope somebody of you can help me!

Was it helpful?

Solution

You need to register marker click listener via GoogleMap.setOnMarkerClickListener() and whenever some marker clicked - you need to remember this marker. That's the way to get currently focused marker.

Obviously you might want to "clear" last focused marker when user "unclicks" this marker (taps on a map, etc). In this case you need to register onInfoWindowClickListener and onMapClickListener and clear last focused item when these events occur

OTHER TIPS

Do this in onCreate method...

  Marker pos = googleMap.addMarker(new MarkerOptions().position(new LatLng(latitude, longitude)).snippet("You are here!").title("You are here!"));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top