Always show zoom controls on a MapView - android

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.

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();
}
});

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.

Related

android zoom in button only with webview

I have a simple android webview app and I want to add zoom in button only,
I added the zoom in button in the graphical layout:
but how can I make it work in the java file ?
In your activity, add an on click listener to your button that zooms in the webview:
findViewById(R.id.zoom_in_btn).setOnClickListener(
new View.OnClickListener() {
#Override
public void onClick(View v)
{
webviewer.zoomIn();
}
});

Change position of ZoomControls

I am working on a project related with Maps. The problem stands that the MapControls are positioned in right bottom. That position get covered with something else. So i want to remove the controls from there and place them somewhere else. I don't want to use custom positioning. Thanks in advance!
Create your own ZoomControls
<ZoomControls android:id="#+id/zoomcontrols"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
and you can set onclicklistener to that.
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();
}
});

AchartEngine disable only zoomout button

I'm using AchartEngine to draw graphs,
is it possible to disable only the zoom out button ?
thanks.
You can disable the original zoom buttons with below code
mRenderer.setZoomButtonsVisible(false);
and write your own button just to zoom-in inside your xml file and do something like below:
ImageButton btnZoomIn= (ImageButton) findViewById(R.id.btnZoomIn);
btnZoomIn.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
mChartView.zoomIn();
}
});

Android: enable temporary touch/click for all views but one

I have a set of buttons and views displayed on the screen. At some point, I would like to be able to interact only with one of them and block all the others.
And I need to retain all the listeners to restore theirs behaviors later.
Any ideas?
Thanks!
For disabling buttons, when you clicking on a specific button/view, disable other buttons/views in the specific onClickListener like
//button1 onClickListener
button1.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
button2.setClickable(false); //disable button2
view1.setClickable(false); //disable view1
}
});
likewise for all other buttons and views, then you may enable those by calling
button2.setClickable(true);
view1.setClickable(true);

Change zoom controls in a MapView

I would like to change the predefined style of the zoom controls in my application to appear like the new zoom controls in the google maps application. See below:
How can I do it? I have been looking around and I haven't found anything.
Thanks in advance.
You should have four image drawables namely:
Zoom in (+) enable/disable
Zoom out (-) enable/disable
Put them in MapView layout an ImageView or Button with background image as the above drawables.
Then you should assign onClickListeners like:
zoomIn.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
mapView.getController.zoomIn()
checkzoom();
}
});
zoomOut.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
mapView.getController.zoomOut()
checkzoom();
}
});
public void checkzoom() {
if(mapView.getZoomLevel()==1) // dont know if 0 or 1, just wrote it
{
zoomOut.setEnabled(false);
// or u can change drawable and disable click
}
if(mapView.getZoomLevel()==18) {
zoomIn.setEnabled(false);
// or u can change drawable and disable click
}
}
EDIT:
I solved the problem this way: disabled built in zoom controls (setBuiltInZoomControls(false)), added my own buttons to UI and added handlers for click on button events.

Categories

Resources