Вопрос

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