经度/纬度转换为1英里是什么? [英] What is the conversion of latitude/longitude to a 1 mile
本文介绍了经度/纬度转换为1英里是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Google地图,我需要能够在邮政编码中心周围5英里的范围内进行搜索,所以我认为最简单的方法是找出纬度/经度转换为英里。
解决方案
以下是使用 Google的几何图书馆。
请记住添加几何库。它与Google地图库不同。
$ b
< script type =text / javascript
src =http://maps.googleapis.com/maps/api/js?libraries=geometry&sensor=false>
< / script>
示例用法:
//距离函数默认为km。
//使用里程作为第三参数添加地球半径(以英里为单位)。
//地球半径以英里为单位== 3956.6
var distance =
google.maps.geometry.spherical.computeDistanceBetween(
/ * from LatLng * /,
/ *到LatLng * /,
/ *地球半径* /
);
if(distance <= 5){//小于或等于五英里
var marker = new google.maps.Marker({
map:map,
position:// LatLng
});
}
我有一个例子小提琴。
I'm working with Google Maps and I need to be able to search in a 5 mile radius around a zip code center so I figured the easiest way to do that would be to figure out the conversion of latitude/longitude to miles.
解决方案
Here is the basic idea using Google's Geometry library.
Remember to add the geometry library. It is separate than the Google maps library.
<script type="text/javascript"
src="http://maps.googleapis.com/maps/api/js?libraries=geometry&sensor=false">
</script>
example usage:
//the distance function defaults to km.
//to use miles add the radius of the earth in miles as the 3rd param.
//earths radius in miles == 3956.6
var distance =
google.maps.geometry.spherical.computeDistanceBetween(
/* from LatLng */,
/* to LatLng */,
/* radius of the earth */
);
if (distance <= 5) { //less or equal to five miles
var marker = new google.maps.Marker({
map: map,
position: //LatLng
});
}
I have an example fiddle of this in action.
这篇关于经度/纬度转换为1英里是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文