0

I have 2000's of marker which needs to be displayed in the google maps dynamically. If I load all marker on one time it's affecting the performance of my application. So I am running my API one time and storing all coordinates in the SQLite DB and I want to display marker only which is nearby onCameraMove.

How can I achieve that? I have multiple Questions in StackOverflow but none will solve my issues.

Piyush
  • 492
  • 5
  • 22
  • Query the database and then use Location.distanceBetween() to find the distance between the current location and the marker location. You can specify the radius if the distance between them is less than the radius you are good to show else don't show it. – Jawad Ahmed Sep 24 '19 at 08:56
  • Is it will be good practice if I query the DB everytime onCameraMove @JawadAhmed – Piyush Sep 24 '19 at 09:05
  • Do it on a background thread – Jawad Ahmed Sep 24 '19 at 09:06

1 Answers1

0

You should add a criteria when retrieving the list of markers like only retrieving markers in certain radius.

you can refer to this qustion if you decided to go with this approach : Query to get records based on Radius in SQLite?

Sarah Maher
  • 790
  • 1
  • 10
  • 21