0

I have a mapView with 600 pois on it, each poi is showing the same PIN.

The movement of the map is very slow when the 600 pois are being showed at once.

It is possible to show all of them without slowing the map movement?

This is part of my code:

My bitmap for the pins:

Bitmap marker= ResourceManager.getImageResourceByName(pinId).getBitmapOfWidth((int) (App.getWidth()*0.14));
                        d = new BitmapDrawable(marker);
                        d.setBounds(0 - d.getIntrinsicWidth() / 2, 0 - d.getIntrinsicHeight(), d.getIntrinsicWidth() / 2, 0);

How i add the overlays (i do this in a while bucle in a async task):

this.itemizedOverlay.addOverlay(values[0]);
NullPointerException
  • 36,107
  • 79
  • 222
  • 382

1 Answers1

0

Displaying that many pins will always slow the map down. I faced a similar problem in an iOS app and found that the best thing to do was to come up with a method of clustering the pins at higher zoom levels, and having a function to display the pins for a given viewport at a given zoom level.

Have a look at some hierarchical clustering algorithms - my solution involved running a clustering algorithm whenever the pin data updates (which wasn't very often in my case). The clustering algorithm took in the locations of all of the pins, and produced N sets of clustered pins for the N zoom levels I supported. Each of these N sets of clustered points would have a minimum and maximum zoom level, so when the map is zoomed in a particular amount, the app would request the relevant pins for this viewport, from the relevant zoom level. This turned out to work very well - the work involved with doing these calculations is a lot less than the work involved in displaying every pin in the data set (and transforming them to the current viewport/zoom level).

I'm afraid I can't provide any code for this, but this is definitely the best way I found of displaying large numbers of pins on a map. It looks and feels a lot better to the user.

benwad
  • 6,414
  • 10
  • 59
  • 93