I have a map on which i want to put marker's. When there are 5-10 marker the maps load quickly but when no of marker's are more than 30 then app become unresponsive. Should i punch marker's using async task or is it possible to punch marker after map is completely loaded.
Asked
Active
Viewed 248 times
1
-
1Can you please post your code how you are setting markers, are you setting any custom icon for marker? – Mohan Krishna Oct 14 '14 at 08:27
3 Answers
0
You should definitely use Async Task.
I had the same issue with maps a while back with an app ( maps api v1 ) , but loading markers using async task resolved the issue.

Daniel M.
- 486
- 5
- 7
-
But google map api says you can't put marker on background thread.It must be on UI thread – Key_coder Oct 20 '14 at 04:49
0
If you're using Google Maps v2, and are using a non-default marker icon, there is a bug currently where they cause excessive slow down. See issue 7174 and this stackoverflow question. A workaround is to use the default icon marker.
0
You should really avoid Async Task, especially for a high "n" of markers. AsyncTasks are for quick few second tasks.
I would suggest setting the markers on the onCreateView() of the map fragment after the map is initialized.
If you are really intent on trying some sort of background thread, look into Executor Services or FutureTask

Mykel
- 1,355
- 15
- 25
-
For limited number of markers ui thread is ok but as no of markers increases ui thread is also become unresponsive – Key_coder Oct 20 '14 at 07:11
-
@Gaurav Absolutely true, but I wanted to answer the question about AsyncTask. Have you tried an Executor Service? – Mykel Oct 20 '14 at 07:16
-
-
Well , You can take for example one of my old apps : http://bit.ly/1FuRM7C . When the app starts I load all marker and then add them to the map. All of these are done with AsyncTasks and I haven't had a problem with that ( maps api v2) . Other apps have over 3000 markers and taking into account the amount of information the app still loads ok ( i think :)) ) – Daniel M. Oct 21 '14 at 06:37