Always show zoom controls on a MapView

佐手、 提交于 2019-11-29 23:10:05

Solved this by putting my own ZoomControls in my layout xml:

<ZoomControls android:id="@+id/zoomcontrols"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

and then setting up onClickListeners for then to handle the zoom:

    zoomControls = (ZoomControls) findViewById(R.id.zoomcontrols);
    zoomControls.setOnZoomInClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mapController.zoomIn();
        }
    });
    zoomControls.setOnZoomOutClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mapController.zoomOut();
        }
    });
Nemi

Intrications' solution does work, but you lose the built in functionality where the button disables when you have zoomed in or out all the way. You can retain this functionality by using the following instead:

localMapView.getZoomButtonsController().setAutoDismissed(false);

However, this does not let you place the controls wherer you want in the panel, and although it does not go away, it does not show up the first time until the user touches the screen once. I tried calling setVisible(true) on the controller, but that does not seem to work for some reason.

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