How to take 5 km points in all directions of a location, geocoding google api?

微笑、不失礼 提交于 2019-12-02 23:19:46

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!