How do I detect a click event on a google map through an overlay?

前端 未结 1 737
深忆病人
深忆病人 2020-12-06 18:15

My problem is that I have a circle map overlay but I want to be able to move the circle by clicking the map to set the new center, the actual problem is that when I click on

1条回答
  •  借酒劲吻你
    2020-12-06 18:44

    All you need to do is to set the clickable: false option in the GPolygon constructor, as in the following example (GPolygonOptions: API Reference):

    
     
     
        
       Google Maps Non Clickable Polygon Demo 
       
     
    
       

    Screenshot with evidence:

    Google Maps Non Clickable Polygon Demo

    Note that the click(overlay: GOverlay, latlng: GLatLng, overlaylatlng: GLatLng) event passes different arguments based on the context of the click, and whether or not the click occured on a clickable overlay. If the click does not occur on a clickable overlay, the overlay argument is null and the latlng argument contains the geographical coordinates of the point that was clicked. If the user clicks on an overlay that is clickable, the overlay argument contains the overlay object, while the overlaylatlng argument contains the coordinates of the clicked overlay (Source: API Reference).

    0 讨论(0)
提交回复
热议问题