I'm trying to set onInfoWindowClickListener for each marker that hit the related API according to the POJO id. That's what I found for setting onInfoWindowClick event.
googleMap.setOnInfoWindowClickListener(new OnInfoWindowClickListener() { @Override public void onInfoWindowClick(Marker marker) { // TODO Auto-generated method stub } });
But I need to set related pojo ids as tags to related markers before I do googleMap.addMarker(marker)
. But there is no such thing as marker.setTag()
. How could I put my ID without setting tag?
For adding a custom marker to Google Maps navigate to the app > res > drawable > Right-Click on it > New > Vector Assets and select the icon which we have to show on your Map. You can change the color according to our requirements. After creating this icon now we will move towards adding this marker to our Map.
Now You can do like this
Update your google play service version to
com.google.android.gms:play-services:9.4.0 Marker marker=mMap.addmarker(new MarkerOptions(LatLang)); // set object as tag marker.setTag(your object) // to retrieve the marker marker.getTag();// Type cast to your object type;
I have one way. Just create HashMap
with both your main Marker
and another one with POJO Class
and get back your POJO Class
based on Particular Marker
clicked on getInfoContents(.....)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With