Google Maps API V3 上的限制标记
我的数据库中有很多标记,我想在地图上仅显示地图边界之间的标记。
如果我拖放地图或更改缩放级别,我想仅显示 SQL 的有限标记。
有人知道我该怎么做吗? 我该如何执行 SQL 命令?
注意:我不想按区域对标记进行分组。
I have a lot of markers in my database and i would like to show on map only the markers between the bounds of the map.
IF I drag and drop the map or change the zoom level, I would like to show only the limited markers by SQL.
Anyone knows how can i do it?
How can I do the SQL Command?
note: I don't want to group the markers by region.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这篇关于创建商店定位器的文章很好地介绍了如何操作SQL。这是计算地球距离的基本Haversine 公式。本文包含该内容的 SQL 版本。在 JavaScript 方面,您可以使用
map.getCenter()
和map.getBounds()
来确定地图的中心和边界的位置,以便计算距离。另一种方法是,如果您单独存储纬度和经度,则只需获取地图边界,这将为您提供西南和东北边界角。然后,您可以获得纬度位于两个纬度之间、经度位于边界的两个经度之间的所有内容。
This article on creating a store locator gives a good introduction to how to do the SQL. That's the basic Haversine Formula for computing distance on the globe. The article contains the SQL version of that. On the JavaScript side, you would use
map.getCenter()
andmap.getBounds()
to figure out where the center and bounds of the map were so you could calculate the distance.Another approach, if you're storing latitude and longitude separately is you simply get the map bounds, which will give you a south west and north east bounding corners. Then you could get everything where the latitude is between the two latitudes, and the longitude is between the two longitudes of the bounds.