More efficient map overlay on Android

In my application, I draw bus routes on top of MapView . Routes have from a few dozen to several hundred GPS coordinates that describe the route that the bus takes.

Hosted by imgur.com

The problem I am facing is that when I cross out all of these lines, panning / zooming is MapViewincredibly slow (even pressing the back button takes a minute).

I'm not sure how appropriate it is, but I added the debugging code, and then checked the logcat output, and MapViewrepeatedly called the draw() Overlay method , whether something changed or not. This happens several times per second and causes a huge amount of garbage collection (2-3 MB per second).

- / , ?

+3
2

ItemizedOverlay, Overlay, . , 2D- API.

, - draw() . , , draw(). , Android Google Groups - , Chronometer . , Chronometer, draw(), .

, , , " - " - getLatitudeSpan(), getLongitudeSpan(), getZoomLevel() , , MapView. , draw() GPS . , :

  • , Canvas Bitmap, Bitmap Canvas, draw(), Bitmap.
  • , draw(), draw() - , Bitmap. №1, , ( , ).

, a Bitmap Canvas , . , Bitmap, .

, .

+5

. 4 . draw . 4 . , . , .

+1

Source: https://habr.com/ru/post/1721734/


All Articles