开发者

How should I design displaying a dynamic map? (Coordinates + Lines)

So I want to have a view (NSView, NSOpenGLView, something CG related?) which basically displays a map. Such as:

http://dump.tanaris4.com/map.png

Obviously that looks horrible, but I did it using an NSView, and it dr开发者_开发知识库aws SO slow. Clearly not designed for this.

I just need to allow users to click on the individual (x,y) coordinates to make changes, and zoom into a certain area (to see it better).

Should I go the OpenGL route? And if so - any suggestions as to how to get started? (I was able to follow the guide to draw a triangle, so that's good).

I did find this post on zooming in an NSView: How to implement zoom/scale in a Cocoa AppKit-application

My concern is if I'm drawing over 6000 coordinates and the lines connecting them, this isn't efficient at all.


I don't think using OpenGL would be of any good here. The problem does not seem to be the actual painting, but rather the rendering strategy. You would need a scene graph of some kind to dynamically handle level of detail and culling. Qt has all this packaged in a nice class class QGraphicsScene (see http://doc.qt.nokia.com/latest/qgraphicsscene.html for reference, and http://doc.qt.nokia.com/main-snapshot/demos-chip.html for an example).

Some basic concepts you should consider using:

  • http://en.wikipedia.org/wiki/Scene_graph
  • http://en.wikipedia.org/wiki/Quadtree
  • http://en.wikipedia.org/wiki/Level_of_detail


Try using core graphics for this, really there is so much that could be done. Watch the video Practical Drawing for iOS Developers from WWDC 2011 and it should give an over view of what can be done with CG.


I believe even CoreGraphics will suffice for what you want to achieve, and that should work under a UIView if you draw the rectangle of your view completely under the DrawRect method of your UIView (you must overload this method). Please see the UIView Class Reference. I have a mobile application that logs points on the UIMapKit, kind of like Nike+, and it certainly works well for massive amounts of points/line segments. There is no reason why this simple approach cannot work for you as well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜