简体   繁体   中英

How do I disable zoom in/out buttons in Javascript?

I am very beginner in Phonegap. I have implemented zoom in/out by using websettings in .java file but at a particular place I need to disable?enable the zoom in/out buttons and stop scrolling. I have tried by viewport in meta tag but No Luck. This code I use in JS

meta.setAttribute("name", "viewport");
meta.setAttribute("content", "width=device-width, "
+ "height=device-height, " + "target-densitydpi=device dpi,"
            + "initial-scale=1.0," + " minimum-scale=1.0,"
            + " maximum-scale=1.0, user-scalable=no");
    head.appendChild(meta);

this code I used in .Java file

package com.m2f;

import android.os.Bundle;
import android.os.Handler;
import android.webkit.WebSettings;
import android.webkit.WebSettings.ZoomDensity;

import org.apache.cordova.*;

public class Adventure extends DroidGap {
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //super.setIntegerProperty("splashscreen", R.drawable.loading);
    super.setStringProperty("loadingDialog", "Loading..");
    super.loadUrl("file:///android_asset/www/index.html");

    WebSettings settings = appView.getSettings();
    settings.setBuiltInZoomControls(true);
    settings.setSupportZoom(true);
    settings.setDefaultZoom(ZoomDensity.MEDIUM);

}
} 

How do I use this

settings.setBuiltInZoomControls(false);

in Javascript? Is it possible to achieve this? Please anybody help me to get resolve this?

function initialize() {
  var mapOptions = {
    zoom: 4,
    center: new google.maps.LatLng(-33, 151),
    panControl: false,
    zoomControl: false,
    scaleControl: true,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  }
  var map = new google.maps.Map(document.getElementById("map-canvas"),
        mapOptions);
}

this is according to google map api v3 which is supportable in cordova, but not android,Where I mentioned

zoomControl: false

in that function....

(or)

In Android file Adventure class

settings.setBuiltInZoomControls(false);

make it as false

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM