質問

I stored the latitude and longitude from a lot of gasstations in a database. I also made a Google Maps. Now, I want to select the gasstations from my database where latitude and longitude are between the North East Latitude / Longitude and South West Latitude / Longitude from my Google Maps.

How can i calculate which gasstations I have to select?

役に立ちましたか?

解決

Simply modify your database query in the backend to only return locations between your points. Something like the first answer here.

Obviously the syntax will depend on the database that you are using.

Actually I would suggest using:

SELECT * FROM tilistings WHERE lat BETWEEN a AND c AND lng between b AND  d

Where a and b are you top left coordinates and c and d are your bottom right. I think BETWEEN is more performant.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top