javascript 在 Google Maps API V3 中删除 Pan 控件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3944036/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-25 02:47:24  来源:igfitidea点击:

Remove Pan control in Google Maps API V3

javascriptjquerygoogle-mapsgoogle-maps-api-3

提问by T3db0t

Is there any way to remove the circular panning navigation control but keep the zoom control in the Google Maps V3 API? I've tried forcing it offscreen with jQuery but every time the map is updated it comes back. Any ideas? Thanks!

有什么方法可以删除圆形平移导航控件但保留 Google Maps V3 API 中的缩放控件?我试过用 jQuery 强迫它离屏,但每次地图更新时它都会回来。有任何想法吗?谢谢!

采纳答案by Ossama

You can use google.maps.NavigationControlStyle.SMALLto display a small plus/minus zoom control, otherwise you'll have to create your own zoom control and add it to the map.

您可以使用google.maps.NavigationControlStyle.SMALL来显示小的加/减缩放控件,否则您必须创建自己的缩放控件并将其添加到地图中。

http://code.google.com/apis/maps/documentation/javascript/controls.html

http://code.google.com/apis/maps/documentation/javascript/controls.html

回答by cdzc

You may also have a look in here, you can remove/add specific controls when you declare your map:

您也可以在这里查看,您可以在声明地图时删除/添加特定控件:

var latlng = new google.maps.LatLng(40.44062, -79.99588);
var options = {
    zoom: 14,
    center: latlng,
    disableDefaultUI: true,
    mapTypeId: google.maps.MapTypeId.ROADMAP
};

Taking Control of the Google Maps API V3 Controls

控制 Google Maps API V3 控件

回答by Erik Johnson

In V3, when you define your options - you have the option of disabling/enabling any UI features:

在 V3 中,当您定义选项时 - 您可以选择禁用/启用任何 UI 功能:

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