Reputation: 73721
I need to create some custom polygon overlays on my map and by custom I mean I need to add more information to the overlay so that when it gets clicked I can show a dialog or something with information about the overlay.
I have done a little reading and it looks like the Overlay
and ItemizedOverlay
classes were removed from the API v2 in the form of Polygons
,Polylines
etc...
In order to create a custom overlay it looks like I have to create a View
on top of the map and just draw on the view but some of my polygons might not be visible for the current map projection
Is there anyway to assign an id to the polygon class or something so that I know what was clicked so I can get the information?
Upvotes: 0
Views: 2228
Reputation: 22232
First of all GMaps Android API v2 doesn't provide a callback for when a polygon is clicked. You would have to use onMapClick and use point inside polygon algorithm iterating over all polygons.
If you keep Map you can iterate over keys and if you have a match, get the value.
Alternatively you may want to try Android Maps Extensions, which has a GoogleMap.getPolygons()
for you to iterate over and Polygon.setData(Object)
+ Polygon.getData()
to assign any additional data and retrieve it when you find a match using point inside polygon algorithm.
Upvotes: 1