Reputation: 870
More specifically... Does iOS's MapKit framework have a built-in generalization of the MKPolyline and MKPolygon overlay before rendering?
The simulator appears quite rough with the display of several polylines composed of hundreds of points. Am I reaching the peak of the iPhone's draw performance or is MapKit not programmed to automatically generalize the data thereby peaking out the device's draw performance?
I know I could make a test case to compare, but creating/integrating such an algorithm for a test case is quite intensive. I am hoping someone has some inside on this before I need to resort to that.
thanks!
Upvotes: 2
Views: 208
Reputation: 391
I don't know about the generalize
part but you might be able to keep performance up by using another approach:
Multiple MKPolygons etc. cause heavy memory-usage when drawing on the map. This is due the NOT reusing of overlays by MapKit. As annotations have the reuseWithIdentifier, overlays however don't. Each overlay creates a new layer as a MKOverlayView on the map with the overlay in it. In that way memory-usage will rise quite fast and scrolling becomes... let's say sluggish to almost impossible.
Therefore there is a work-around: Instead of plotting each overlay individually, you can add all of the MKOverlays (in your case MKPolygons and MKPolylines) to one MKOverlayView. This way you're in fact creating only one MKOverlayView and thus there's no need to reuse.
The answer in this question contains a link to the Apple Developer Forum with the work around.
I've used this approach in a way with multiple MKPolygons
and it works great. Also I'm planning to use MKPolylines
to in the future for my app. I believe it is possible to draw them all in one MKOverlayView
...
Using this approach you might not need to generalize
the drawing of the MKPolygon overlay. Also it is a lot easier to implement and test IMO ;-)
Upvotes: 1