English 中文(简体)
Optimizing map drawing
原标题:

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

最佳回答

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.

问题回答

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.

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.




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签