Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plotting hundreds of markers onto a MapView

I can plot overlay markers on a map easily, but the requirements for this project ask for the addition of several hundred overlay markers. Obviously this causes ANRs all over the place.

I cannot use an AsyncTask to handle the addition of the overlay markers as the task cannot access the views.

So how can I move the addition of these overlays to the MapView in such a way that the app does not ANR?

Or is the realistic limit to the number of overlay markers I can plot much more limited?

like image 484
Ollie C Avatar asked Dec 03 '25 18:12

Ollie C


1 Answers

Override the onPostExecute and onProgressUpdate methods of the AsyncTask to hop onto the UI thread. You can manipulate your UI from within there. Remember to keep all the grunt work in the doInBackground method.

Trying to fire off a few hundred AsyncTasks is not a good idea so I recommend using a queue that a fixed number of AsyncTasks consume requests off.

Your next problem is dealing with performance when the user manipulates the map.

like image 166
Che Jami Avatar answered Dec 06 '25 07:12

Che Jami



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!