更新时间:2023-01-08 11:32:25
var miledistance, kmdistance;
miledistance = glatlng1.distanceFrom(glatlng2, 3959).toFixed(1);
kmdistance = (miledistance * 1.609344).toFixed(1);
如果你有lat,lngs作为浮点数,你可以创建一些GLatLng来使用这个方法。例如
If you have the lat, lngs as floats you can just create some GLatLng's to use this method.. eg
var miledistance, kmdistance;
miledistance = new GLatLng(lat1,lng1).distanceFrom(new GLatLng(lat2, lng2), 3959).toFixed(1);
kmdistance = (miledistance * 1.609344).toFixed(1);
邓肯。