如何在一个位置的所有方向上使用5公里的点,对Google API进行地理编码? [英] How to take 5 km points in all directions of a location, geocoding google api?

查看:95
本文介绍了如何在一个位置的所有方向上使用5公里的点,对Google API进行地理编码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,我有这些线:

  55.623151,8.48215 

我希望看到地理编码距北,南,东,西5公里,地点位于^以上。



我该怎么做?

解决方案

如果您使用Google Maps API v3,如下所示:

将Geometry库包含到您的网页中,以供 Spherical Computations

 < script type =text / javascript
src =http://maps.googleapis.com/maps/api/js?libraries=geometry&sensor=false>
< / script>

然后您可以计算:

  var point = new google.maps.LatLng(55.623151,8.48215); 
var spherical = google.maps.geometry.spherical;
var north = spherical.computeOffset(point,5000,0);
var west = spherical.computeOffset(point,5000,-90);
var south = spherical.computeOffset(point,5000,180);
var east = spherical.computeOffset(point,5000,90);

您可以查看在jsfiddle上运行版本


Ok so i have these cords:

55.623151, 8.48215

I would like to see the geo codes 5 km from north, south, east, west from this geo location above^.

How can i do this?

解决方案

If you use Google Maps API v3, then you would proceed as follows:

Include the Geometry library into your Web page for Spherical Computations:

<script type="text/javascript" 
    src="http://maps.googleapis.com/maps/api/js?libraries=geometry&sensor=false"> 
</script>

Then you can compute:

var point = new google.maps.LatLng(55.623151, 8.48215);
var spherical = google.maps.geometry.spherical; 
var north = spherical.computeOffset(point, 5000, 0); 
var west  = spherical.computeOffset(point, 5000, -90); 
var south = spherical.computeOffset(point, 5000, 180); 
var east  = spherical.computeOffset(point, 5000, 90); 

You can check a running version on jsfiddle.

这篇关于如何在一个位置的所有方向上使用5公里的点,对Google API进行地理编码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆