开发者

Displaying tens of thousands of geocoordinates

开发者 https://www.devze.com 2023-04-04 16:47 出处:网络
Say I have a database of lat/long values stored (e.g. the geocoordinates of bus开发者_如何学JAVAinesses). Now, I want the user to be able to search for something like:

Say I have a database of lat/long values stored (e.g. the geocoordinates of bus开发者_如何学JAVAinesses). Now, I want the user to be able to search for something like:

search for all Chinese restaurants in Los Angeles

Is there a way to do this using Google Maps? Would I somehow pass all the geocoordinates? It will be in the tens of thousands.


Google Map API does have view port biasing and region code biasing to help search their database but not yours.

Latitude and longitude roughly equate to distance on the ground (1 degree for both latitude and longitude is about 69 miles, see the degree length section for latitude and longitude for more info). Therefore if you stored latitude and longitude in seperate columns, and if you can resolve Los Angeles to a lat/long (maybe by using Google's reverse geocoding), you code do a simple query to return only the business that are within an approximate distance from the Los Angeles lat/long.

This will return results within a square, (or rectangle, but not a circle), that is centered on the Los Angeles lat/long. Any result within the square's corner will be greater than the selected approximate distance away from the Los Angeles lat/long.


If you are asking show me all results within a radius, or all results within a bounding box then you only face an sql query problem - once you have the central point of the query.

If you want to find all places within a city, then perhaps you can simply have your sql query filter on a field in your database.

select title from restaurants where city = "Los Angeles";

or if you have accurate zip code coverage:

select title from restaurants where postal_code like "<ZIP-STARt>%";

If you do not have 100% zip code coverage then consider running a one-off geocoding exercise to bring back the zip code.

(I admit ignorance of how zip codes relate to cities in the US)

0

精彩评论

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