GoogleMaps Polyline Length in V3

后端 未结 7 1211
半阙折子戏
半阙折子戏 2020-12-10 23:30

There doesn\'t seem to be a length funciton for the Polyline in Google Maps anymore in V3.

Has anyone found a workaround for this functionality gap?

7条回答
  •  余生分开走
    2020-12-11 00:01

    
    ... var path = poly.getPath(); // or:
    var path = polygon.getPath(); 
    ... = google.maps.geometry.spherical.computeLength(path.getArray())
    ... = google.maps.geometry.spherical.computeArea(path.getArray())
    

    --> distance for polyline, area for polygon

    and between two points: computeDistanceBetween()

    Don't forget to specify the geometry library (libraries=geometry)

    http://code.google.com/apis/maps/documentation/javascript/geometry.html

提交回复
热议问题