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