1

嗨,我想知道如何找到 openlayers 中两个标记之间的距离。

var distance = distanceBetweenMarkers(latLon1, latLon2){
//code to find the distance between latLon1, latLon2

}

请帮帮我...

4

1 回答 1

4

从[1] 中创建点LonLat并调用distanceTo方法。Geometry.Point

p1 = new OpenLayers.Geometry.Point(latLon1.lon,latLon1.lat);
p2 = new OpenLayers.Geometry.Point(latLon2.lon,latLon2.lat);
len = p1.distanceTo(p2);

1 - http://dev.openlayers.org/docs/files/OpenLayers/Geometry/Point-js.html#OpenLayers.Geometry.Point.distanceTo

于 2012-04-04T08:48:29.663 回答