views:

189

answers:

3

Hello, I have problem optimizing drawing Google-like map. It works OK for hundreds of points, but when it comes to larger amounts like thousands it gets fuzzy and slow. Also unzoomed it looks weird.

I'd like to know how to optimize drawing algorithm to draw fewer places so it looks like unzooming on Google Maps.

However I also draw links between places, and I can't optimize that.

Please, post anything you can think of, I have to finish this and send it tomorrow.

Here's how it looks like:

zoomed in zoomed out

A: 

some hints:

  1. clip region, to draw points only in the clip region
  2. you can check opensource GIS project, see how they optimize drawing.
Benny
Yes, I draw only points inside visible area + some pixels on top (I guess 20). The problem is maybe with links
mnn
+1  A: 

Here's two ideas:

  1. Every object that we draw on a map has an extra value in the database, "Zoom Level". When zooming in extra items will be shown based on that value.

  2. A second way to this is to use grouping. If items start to overlap show one point with [10 items]. Only show the items beneath it when zooming in.

Carra
first is good, but points and links are user-defined, so I can't just guess zoom level :), second is also good, I take a look on that one
mnn
A: 

I think I would be tempted to not draw lines that are shorter than a threshold (and I mean this in terms of the viewport, not absolute distance terms). That means that when the map is zoomed out, you will have less to draw and the map will look less busy and when the map is zoomed in the lines between these nearby points will become visible. Edit: actually, thinking about it some more, I think I would only apply this length restriction when there are a large number of lines on screen — or make the length threshold a function of the number of lines on screen.

I think I would also be tempted to not draw lines that are from points that are off screen (out of the viewport) or, at least, quite a way off screen (a threshold away from the viewport's centre). I would suggest trying this change first.

These changes may seem like they will be hiding information (and they will) but, as it stands, the map is so busy this information presented is near useless anyway.

Paul Ruane
Thanks that reduced lags a little bit, but I was late, I submitted non-optimized version, because I wasn't sure I could make it till deadline (which was delayed until 2.12.2009 23:59)
mnn