Android: Map drawing performance, 1K drawings !
So I have an application that draws line, polyline, circles, etc over an Open Streen Map. I keep a list of drawings, when the map is invalidated I iterate thou开发者_StackOverflow社区gh the list redrawing each item within the onDraw method of an Overlay. This works fine until my drawing count gets around 300+. Then some serious UI delay kicks in.
I'm looking for an efficient way to do this?
I've done bitmap cache drawing on a "board" drawing application. Although that will not work for this situation as the projection in the background can change, thus the drawing must move.
I was saving GeoPoints and then doing a heavy conversion to the "MapView Point" during each redraw. Turns out the Projection has an "Intermediate Point" which can be stored and easily projected to the "MapView Point". So the heavy computational part only done once.
Steps
- Motion Event(x,y) to GeoPoint using (fromPixels)
- GeoPoint to Intermediate value using (toMapPixelsProjected)
- Cache the intermediate values for drawing display
- OnDraw -> intermediate values to screen coordinates using (toMapPixelsTranslated)
精彩评论