MyLocationOverlay disableMyLocation() not seeming to work

我的未来我决定 提交于 2019-12-03 16:42:40

Issue was in my initilization of the MyLocationOverlay Object. Wrong Code:

private void initMyLocation() {
   myLocOverlay = new MyLocationOverlay(this, mapView); //THIS SHOULD NOT BE HERE.      
   myLocOverlay.enableMyLocation();
   myLocOverlay.enableCompass();
   mapView.getOverlays().add(myLocOverlay);
}

My initMyLocation() function gets called multiple times through-out my code. Calling this line: myLocOverlay = new MyLocationOverlay(this, mapView); multiple times was creating multiple listeners that failed to be disabled with disableMyLocation() (i think...).

Anyways I moved the MyLocationOverlay initialization to onCreate() and now it works.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!