Google Maps API how to get the click listener to recognize drags

前端 未结 2 1680
温柔的废话
温柔的废话 2021-01-29 05:47

I\'m trying to create an editable polygon in google maps that on change, returns the Geo Coordinates of the polygon. At the following JS Fiddle, you\'ll notice if you create a t

2条回答
  •  不知归路
    2021-01-29 06:00

    There is a drag event on polygon. It should be attached using google.maps.event.addListener not google.maps.event.addDomListener. More about polygon events here in the docs (scroll lower to Events).

    This works:

    function overlayClickListener(overlay) {
        google.maps.event.addListener(overlay, "drag", function(event){
            console.log("Changing this guy!");
            $('#vertices').val(overlay.getPath().getArray());
        });
    }
    

提交回复
热议问题