最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - proximity search google map - Stack Overflow

programmeradmin2浏览0评论

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 ? .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..

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..

Share Improve this question edited Sep 9, 2013 at 7:44 j0k 22.8k28 gold badges81 silver badges90 bronze badges asked Feb 28, 2012 at 17:17 Anjana SharmaAnjana Sharma 4,7955 gold badges40 silver badges51 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 3

Google has a plete 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./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!

发布评论

评论列表(0)

  1. 暂无评论