谷歌地图。如何创建一个给定中心点坐标的LatLngBounds矩形(方形) [英] google maps. how to create a LatLngBounds rectangle (square) given coords of a central point

查看:683
本文介绍了谷歌地图。如何创建一个给定中心点坐标的LatLngBounds矩形(方形)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个点(X,Y),我想创建一个正方形Google maps LatLngBounds对象,以便使地理编码请求仅偏向于此LatLngBound区域。



如何创建一个以给定点为中心的LatLngBounds平方?我必须找到NE和SW点。但是我怎么找到距离d和点(x,y)?

谢谢

解决方案

您也可以从定义为圆的半径中 getBounds ,并将trig保留为google。



new google.maps.Circle({center:latLng,radius:radius})。getBounds();

I have a point (X,Y) and I want to create a square , Google maps LatLngBounds object so to make geocode requests bias only into this LatLngBound region.

How can I create such a LatLngBounds square with center the given point? I have to find the NE and SW point. But how can I find it given a distance d and a point (x,y)?

Thanks

解决方案

You can also getBounds from a radius defined as a circle and leave the trig to google.

new google.maps.Circle({center: latLng, radius: radius}).getBounds();

这篇关于谷歌地图。如何创建一个给定中心点坐标的LatLngBounds矩形(方形)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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