-2

I am using android google maps v2 now and I have implemented polygon based on the lat/long and i would like to recognize the polygon click event .

But was unable to do so. I would like to know should I use maps v3 as it has onClickListner for polygon-id or is there anything similar for google maps v2 ?

Please let me know.Appreciate any help .Thanks in Advance.

Condition:
I am looking to implement every state with different colours and onClick event for each polygon.
Please suggest the best alternative for the above implementation.

Jason Wood
  • 89
  • 3
  • 14

1 Answers1

0

I have just worked on something similar. As best I can tell, there is no click event for polygons in Google Maps for Android API v2. There are a couple of different solutions available that I won't go into.

The simplest method is to rely on OnMapClickListener. Register the listener and receive onMapClick(LatLng point) callbacks from the GoogleMap. Then use a point in polygon algorithm to determine if the click was inside one of the polygons on the map.

Reference: How can I determine whether a 2D Point is within a Polygon?

Community
  • 1
  • 1
dm78
  • 1,570
  • 1
  • 16
  • 28