1

I have a database with about 20,000 coordinations. I created an android application using the Google Map API. Now, I want to fetch all the coordinations in the range of my current view of the map view (showing them as markers). And, when I move the map from one place to another, load some new coordination for the current new view automatically.

The database that I am using is (MySQL), and for each point in a row, I have two columns (longitude and Latitude) and some other columns to hold details about the point like name of the place, address ..etc.

What I have done by now:
I can load some coordination from the database and put them on the google map as markers. But, this is not what I want, I want the google map to specify a range of current view and bring all the GPS coordination in this range from the database. I searched on the Internet, I could not find any useful resources.

Kurdish Programmer
  • 403
  • 1
  • 4
  • 14
  • 1
    So, you'll need [the Google Map's bounding box](https://stackoverflow.com/questions/14700498/android-google-maps-get-boundary-co-ordinates) to begin with. But how to query your database based on location constraints? We don't know your database schema, so it's impossible to say. Or even if it's SQL or some type of NoSQL. If SQL, does every item have latitude and longitude values in separate columns? Anyway you should probably try something first and then ask more specific questions when you meet some trouble you can't overcome. – Markus Kauppinen Sep 12 '19 at 15:04
  • Markus, thank you so much for your response. I will edit my question and add the details of the database. – Kurdish Programmer Sep 12 '19 at 15:36

1 Answers1

1

First I would like to thank Markus Kauppinen for his comment that helped me to find the answer.

As he mentioned, first of all, we have to get the boundary of the current map view in our application that consists of two points (NorthEast, and South West). then we can create the database query like the following:

SELECT * FROM tablename where geo_lat lat2 and geo_long < long1 and geo_long > long2


whereas,
northeast=lat1, long1
southwest=lat2,long2

Kurdish Programmer
  • 403
  • 1
  • 4
  • 14