1

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.

Key_coder
  • 534
  • 3
  • 27

3 Answers3

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
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.

Community
  • 1
  • 1
Tom
  • 6,946
  • 2
  • 47
  • 63
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

ThreadPoolExecutor

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
  • Not yet i'll try and let u know – Key_coder Oct 20 '14 at 07:18
  • 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