近距离搜索谷歌地图 [英] proximity search google map
问题描述
我使用google map v3捕获MS SQL数据库表中名为Locations的所有地址,这些地址将包含LocationName,LocationAddress,LocationZip,LocationState,LocationCity,LocLatitude,LocLongitude和LocationType等列(如医院,医生办公室或紧急情况中心等)。
我有一个输入框,用户可以通过关键字和5,10,20和50英里半径选项进行搜索。我已经能够使用输入框,并通过输入关键字作为查询字符串搜索所有匹配的位置,并为他们在谷歌地图api 3绘制标记。我也喜欢在匹配的结果,如5英里的说洛杉矶..
可以使用本网站使用的方法吗?
http://maps.huge.info/dragcircle2.htm
它正在绘制5英里的半径,我需要几乎捕获该半径内的所有标记?请一些天才谷歌地图的家伙/女孩给我一些指导。
Google有一个关于创建商店定位器的完整教程。您缺少的重要信息是如何查询您的数据库以撤回您的半径内的位置。
http://code.google.com/apis/maps/articles/phpsqlsearch.html
查看上面的链接以获取详细信息,但查询将看起来像这样(mySQL):
SELECT
地址,
名称,
lat,
ng,
(
3959 * acos(
cos(弧度( (弧度(lat))
*
cos(弧度(lng) - 弧度('%s'))
+
sin(弧度('%s'))
*
sin(弧度(lat))
)
)距离
FROM markers
HAVING distance< '%s'
ORDER BY距离
LIMIT 0,20
它使用三角学!
I am using google map v3 to capture all the addresses in a MS SQL database table called Locations which will have columns like LocationName, LocationAddress, LocationZip, LocationState, LocationCity, LocLatitude, LocLongitude and LocationType(like hospital, physician office or emergency centers etc)..
I have an input box where users can search by keyword and a dropdown with 5,10, 20 and 50 miles radius option. I have been able to use the input box and pass the typed keyword as querystring to search for all the matching location and plot markers for them in google map api 3. I also like to do proximity search on the matched results like withing 5 miles of say Los Angeles..
can the method used in this site be used ? http://maps.huge.info/dragcircle2.htm
It is drawing a radius withing 5 miles, I need to pretty much capture all the markers within that radius? Please some genius google map guys/girls give me some guidance..
Google has a complete tutorial on creating a store locator. The vital piece of information that you are missing is how to query your database to pull back the locations within your radius.
http://code.google.com/apis/maps/articles/phpsqlsearch.html
take a look at the link above for details but the query will look somthing like this (mySQL):
SELECT
address,
name,
lat,
lng,
(
3959 * acos(
cos( radians('%s') ) * cos( radians( lat ) )
*
cos( radians( lng ) - radians('%s') )
+
sin( radians('%s') )
*
sin( radians( lat ) )
)
) AS distance
FROM markers
HAVING distance < '%s'
ORDER BY distance
LIMIT 0 , 20
It uses trigonometry!
这篇关于近距离搜索谷歌地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!