Drawing many map overlays efficiently

by Mark Wyszomierski » Sun, 02 Nov 2008 11:27:29 GMT

Sponsored Links

I have many pins I'd like to display on a map. I first tried adding
each as an Overlay, but this is way too slow, as each overlay tries
drawing itself even though it may not be visible within the screen

So the question is, is one overlay instance supposed to be used per
pin? Or is there some more efficient data structure to use with it?

If we are supposed to use Overlay for this, I figured I could keep the
"mercator" unit of each of my overlay cached, then recalculate the
mercator unit of the top-left, bottom-right points of the map view to
figure if an overlay should be drawn or not, which will probably be
much faster.

I'm guessing there's already some built-in way to draw a large number
of Overlays, as google is known for fast algorithms and efficiency?


Drawing many map overlays efficiently

by Mark Wyszomierski » Sun, 02 Nov 2008 14:04:48 GMT

 Ok well I am pre-calculating the 'mercator unit' for each pin now
which makes it very easy to clip pins that aren't within the bounds of
the visible map. This has helped performance a lot.

I still wonder though if Overlay adds a lot of overhead - would it be
much faster to just draw the pins myself manually?



Sponsored Links

Drawing many map overlays efficiently

by Guillaume Perrot » Sun, 02 Nov 2008 19:51:10 GMT

 An overlay can draw several items, not just one... (check
ItemizedOverlay which provides some facilities over Overlay to handle
An overlay is mandatory to "manually" draw something on the map.
An overlay is supposed to be a layer, you can draw what you want
inside, not just one pin, you can draw rects, circles, text, images
If an overlay has nothing to draw, you should remove it of the overlay
list until it has data.


Other Threads

1. Edit pictures immediately after capturing it on the Camera.

Hi All,

I'm writing an app that requires me to add an image (let's called it
ImageA) to any picture captured by the Camera. The feature of this app
is that ImageA can be added immediately after a picture is taken from
the Camera.

I need help here to achieve the above. Anybody can help?




2. Android Market Rank

Hi all,

I just released a free app, called "Android Market Rank" that let's
you find an app's elusive android rank.  You can see exactly what an
app's current rank is, what was the lowest (best) it's ever been, and
what the highest (worst) it's ever been.  It also has a graph that
shows how the rank has changed over time.  As a developer, this is
really useful information because the higher your rank is, the higher
your visibility to all android users.

What is android rank and how is it calculated?
No one knows how google calculates an app's rank but many have their
theories.  Your rank corresponds to what place you are in the category
list of apps.  For example, in the Arcade & Action free list, Angry
Birds is #1 (of course), Glow Hockey is #3, and Robo Defense FREE is

Please let me know if you have any comments or suggestions.


3. date picker and froyo

4. Custom Dialog with ListView

5. java.lang.OutOfMemory decoding Bitmaps

6. Web controller

7. Unable to use Fragmentation API with android compatibility package