开发者

google maps radius search

I have a database of hotels with address, also POI's with latitude and longitude.

I would like to search these POI's around the hotel with radius (5km 10 km开发者_StackOverflow社区...). How to do it?

Thanks


There is a (fairly extensive) tutorial for creating a "Store Locator" type page in JavaScript, MySQL PHP available from the Google Geo APIs Team here:

http://code.google.com/apis/maps/articles/phpsqlsearch.html

If you see the section under "Searching near a geocode", you could modify this to be a set geo-code for the hotel. Alternately you could just provide it with a string for the name of the hotel. This really depends on how you want your search to function.

Does this help you?

P.S. I also posted here about creating a super-efficient version of this if you want to optimize your own version Mysql Haversine Procedure (radius)using a center point


SELECT
*,
ACOS( SIN( RADIANS( `lat` ) ) * SIN( RADIANS( $lat ) ) + COS( RADIANS( `lat` ) )
* COS( RADIANS( $lat )) * COS( RADIANS( `lon` ) - RADIANS( $long )) ) * 6380 AS `distance`
FROM `places`
WHERE
ACOS( SIN( RADIANS( `lat` ) ) * SIN( RADIANS( $lat ) ) + COS( RADIANS( `lat` ) )
* COS( RADIANS( $lat )) * COS( RADIANS( `lon` ) - RADIANS( $long )) ) * 6380 < 10
ORDER BY `distance`

10 is radius in km
$lat and $long is the center or the circle
lat and lon are attributes if your table

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜