Calculate distance between two points in google maps V3

后端 未结 15 1950
醉梦人生
醉梦人生 2020-11-22 02:27

How do you calculate the distance between two markers in Google maps V3? (Similar to the distanceFrom function inV2.)

Thanks..

15条回答
  •  执念已碎
    2020-11-22 02:54

    There actually seems to be a method in GMap3. It's a static method of the google.maps.geometry.spherical namespace.

    It takes as arguments two LatLng objects and will utilize a default Earth radius of 6378137 meters, although the default radius can be overridden with a custom value if necessary.

    Make sure you include:

    
    

    in your head section.

    The call will be:

    google.maps.geometry.spherical.computeDistanceBetween (latLngA, latLngB);
    

提交回复
热议问题