如何在大型谷歌地图上绘制矩形区域并查询数据库以查找矩形内存在的位置/点? [英] How to draw a rectangular area on a large google map and query database to find locations/points that exist inside the rectangle?

查看:792
本文介绍了如何在大型谷歌地图上绘制矩形区域并查询数据库以查找矩形内存在的位置/点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,希望向最终用户展示Google地图,并允许他们使用简单的矩形绘图工具选择地图区域,然后将所有地点存储在客户端数据库中那在这个矩形选区内显示为地图上的点...



我对Google地图有一个简单的了解,并且可以通过Google地图来绘制所有地点在数据库瓦特/ o问题......我的问题来允许最终用户绘制矩形。不知道如何实现这一点。



有人可以解释或链接我的例子吗?

解决方案

有趣的问题。我喜欢google maps api。这里是你的解决方案jsFiddle:



http:/ /jsfiddle.net/JsAJA/2/



您必须在最小/最大lat和lng之间查询您的数据库。希望这会有帮助。



Bob



请注意,这打破了谷歌地图的自然用户体验。鼠标向下时不再拖动地图。它需要更好的用户体验。


I've got an application where I would like to present the end user with a google map and allow them to select an area of the map with a simple rectangular drawing tool and then have all of the locations stored in the client's database that fall in that rectangular selection area show up as points on the map...

I have a simple understanding of google maps and can get google maps to plot all the locations on the database w/o a problem... my problem comes in allowing the end user to draw the rectangle. Not sure how to implement this.

Can someone explain or link me to an example of how it's done?

解决方案

Interesting question. I love the google maps api. Here is a jsFiddle with your solution:

http://jsfiddle.net/JsAJA/2/

You will have to query your database for points between the minimum/maximum lat and lngs. Hope this helps.

Bob

P.S. Note that this breaks the natural user experience of google maps. The map is no longer dragged when you mouse down. It needs a better user experience.

这篇关于如何在大型谷歌地图上绘制矩形区域并查询数据库以查找矩形内存在的位置/点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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