Triggering a map event (like a marker click) in Google maps Android V2-ThrowExceptions

Exception or error:

I am trying to trigger a marker click (or other map events too) programmatically in Google maps API for android V2.
Does anyone have an idea as to how to do it ?

Apparently javascript api (v3) , has a trigger function but I could’nt find anything for android.

Thanks for the help.

How to solve:

You cannot triger a marker click directly.

If you need to run default implementation when onMarkerClick returns false (or you have no OnMarkerClickListener), you need to do it yourself:

marker.showInfoWindow();
map.animateCamera(CameraUpdateFactory.newLatLng(marker.getPosition()), 250, null);

250 is assumed here, API doesn’t give you the value used internally for this default marker click behaviour.

If you have a OnMarkerClickListener, you can just keep the reference and call a function on it sending marker as a param.

###

There is a good tutorial for detecting a marker click on Google maps V2 here: http://android-er.blogspot.in/2013/01/google-maps-android-api-v2-example_5213.html

Hope this will helps you.

###

OnMapClickListener is an Interface you can use to detect clicks on Google Maps V2.
Kind of a “trigger” like in js. You set a Listener for specific events and you wait until you got some. Then you declare a method and you handle the event.

Leave a Reply

Your email address will not be published. Required fields are marked *