Issue
I have an app based on Google MapView with a number of large vector overlays. There can be up to 500 complex polygons on the screen at once. On my phone (Android 2.3.4) the redraw of MapView is triggered automatically on a short time interval no matter whether it is needed or not.
The problem:
Because of the large map redraw time UI response can be slow. For example it may take about a second to open a menu. Any dialogs have poor response as well.
The question:
Is it possible to turn off automatic redraws for MapView? Or any other thoughts how to improve the UI response?
*MapView.SetEnabled(false) doesn't do it, MapView only becomes unclickable. MapView.setWillNotDraw(true) leaves me with a black screen.
*As far as I know on Android 2.2 no automatic redraw occurs (MapView.Invalidate() is needed to see any changes). Maybe it's not only OS/library version but also hardware issues.
Solution
As far as my knowledge of MapView goes, the map is only redrawn when you drag the map or zoom in/zoom out OR unless you call map.postInvalidate(). Now to answer your question:
"Is it possible to turn off automatic redraws for MapView?" Yes. You will have to override the onDraw() method of MapView because it's the onDraw() method that is called whenever the map is drawn/redrawn, basically, you will need to have a boolean control variable that you can use to change whether the entire map should be drawn (default drawing is done by using the super.onDraw() call) or if you need to only specifically draw some of the overlays etc.
Answered By - Vishwa Patel
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.