Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Always show zoom controls on a MapView

Is there a way to always show the zoom controls on a MapView? I have added the zoom controls using

map=(MapView)findViewById(R.id.map);
map.setBuiltInZoomControls(true);

but the zoom controls fade in and out. I want them to always be visible.

like image 555
Intrications Avatar asked May 28 '09 13:05

Intrications


2 Answers

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();
        }
    });
like image 166
Intrications Avatar answered Nov 02 '22 20:11

Intrications


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.

like image 34
Nemi Avatar answered Nov 02 '22 21:11

Nemi