Polygon Touch detection Google Map API V2

后端 未结 6 2092
小蘑菇
小蘑菇 2020-11-28 11:22

I\'m trying to figure out how best to do this, I have a map with one Polygon drawn on it. Since it doesn\'t seem as though the Google Maps API V2 has a touch de

6条回答
  •  情歌与酒
    2020-11-28 12:01

    With the release of Google Play Services 8.4.0, the Maps API has included support for adding an OnPolygonClickListener to Polygons. Both polygons, polylines and overlays support similar events.

    You just need to call GoogleMap.setOnPolygonClickListener(OnPolygonClickListener listener) to set it up, and correspondingly for the other listeners (setOnPolylineClickListener, &c):

    map.setOnPolygonClickListener(new GoogleMap.OnPolygonClickListener() {  
        @Override  
        public void onPolygonClick(Polygon polygon) {  
            // Handle click ...  
        }  
    });  
    

    Although a bit late, it solves this use case quite nicely.

提交回复
热议问题