distance of a polyline

前端 未结 2 1420
广开言路
广开言路 2021-01-07 01:36

I am working in a polyline and I need to obtain the distance of this. So if anyone can help I would be very gratefully.

Best regards.

This is my code:

<
2条回答
  •  伪装坚强ぢ
    2021-01-07 02:28

    It's easy - using built in functions in the geometry library...

    const polyLengthInMeters = google.maps.geometry.spherical.computeLength(yourPolyline.getPath().getArray());
    

    To use the geometry library you declare it when you load the map api

    
    

    for more info see:

    Google API Polyline reference

    Google API mcvArray reference

    Google API Spherical geometry reference

提交回复
热议问题