I am making a map with multiple markers an multiple polygons. Way Map is implemented is that you can have only 1 polygon click and marker click listener. Now in that listener handler I want to identify which polygon got clicked which cannot until I compare all Geopoints against all polygons I draw which is really ineffective. For markers I am using the caption as the identifier but polygon does not even have caption.
Unfortunately, our Polygon implementation doesn’t have an identifier for a polygon. But Vaadin implementation has a long id which increments when you create a new polygon. So you can retrieve this id by the following:
((PolygonDelegate) polygon).getPolygon().getId()
To identifier clicked polygon, you can store this id in HashMap with a String value. For instance: