How to get point coordinates of a modified drawingManager shape? GoogleMaps API v3

前端 未结 1 2026
囚心锁ツ
囚心锁ツ 2020-12-05 21:50

I have this DrawingManager Object:

    drawingManager = new google.maps.drawing.DrawingManager({
      drawingMode: google.maps.drawing.OverlayType.POLYGON,
         


        
相关标签:
1条回答
  • 2020-12-05 22:22

    Ok having the answer on my second code:

    var coordinates = (polygon.getPath().getArray());
    

    Finally I got the last array with coordinates calling this code by adding a listener to call a function that get the array:

    JS

    function getCoordinates() {
        console.log(polygon.getPath().getArray());
    }
    
    google.maps.event.addDomListener(document.getElementById('CoordsButton'), 'click', getCoordinates);
    

    HTML

    <button id="CoordsButton">Coordinates</button>
    

    Then when the button is clicked now I get the coords...

    Thanks anyway

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