draw is being constantly called in my android map overlay

后端 未结 8 1793
走了就别回头了
走了就别回头了 2021-01-04 09:30

I\'m trying to draw a route onto my MapView. I\'ve extended Overlay and implemented the draw() method. The route is displayed properly, although while debugging, I added a b

8条回答
  •  别那么骄傲
    2021-01-04 09:38

    In my app, I have an indefinite progress bar (e.g. spinning circle) show when I'm loading network data for the map. When the network data is finished loading, I was setting the progress bar's visibility to invisible. However, this caused the map to continuously redraw as it seems that any animation (I'm guessing) which takes place over the map will cause the map itself to redraw. Simple solution to this is to set the visibility to gone instead. E.g. change this:

    ProgressBar loadingIcon = (ProgressBar) findViewById(R.id.loadingIcon);
    ...
    //Network data now finished loading...
    loadingIcon.setVisibility(View.INVISIBLE);
    

    to this:

    loadingIcon.setVisibility(View.GONE);
    

    which removes it entirely from the map, no longer animates over it and therefore does not cause draw() to be called a indefinitely.

提交回复
热议问题