[英]Two Points Distance From My Path or KML /KMZ Calculating with Google Map javascript
I have a question about Google Map Javascript api. 我对Google Map Javascript API有疑问。 You know, google map calculating two points distance with city map. 你知道,谷歌地图计算与城市地图的两点距离。 Can I use a kml, kmz way and calculate this two points distance from my kml/ kmz or points ? 我可以使用kml,kmz方式来计算距kml / kmz或点的两点距离吗?
Or how can I calculate ? 或如何计算?
If you know your coordinates, then you can use the geometry library. 如果知道坐标,则可以使用几何库。
You need to load the geometry library 您需要加载几何库
http://maps.googleapis.com/maps/api/js?sensor=false&libraries=geometry
The distance between two points is the length of the shortest path between them. 两点之间的距离是两点之间最短路径的长度。 This shortest path is called a geodesic. 该最短路径称为测地线。 On a sphere all geodesics are segments of a great circle. 在一个球体上,所有测地线都是一个大圆的段。 To compute this distance, call computeDistanceBetween()
, passing it two LatLng
objects. 要计算此距离,请调用computeDistanceBetween()
, computeDistanceBetween()
其传递两个LatLng
对象。
Example: 例:
var a = new google.maps.LatLng(0,0);
var b = new google.maps.LatLng(0,1);
var distance = google.maps.geometry.spherical.computeDistanceBetween(a,b);
distance
will be the distance in meters . distance
将以米为单位的距离。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.