简体   繁体   English

在Google地图上禁用缩放和链接

[英]Disable zoom and links on google map

I have disabled all the controls on google map , Using following parameters , 我已禁用google map上的所有控件,使用以下参数,

var mapOptions = {
        zoom: 15,
        center: new google.maps.LatLng(latitude,longitude),
        mapTypeId: google.maps.MapTypeId.ROADMAP,
        disableDefaultUI: true,
        draggable: false, 
                zoomControl: false, 
                scrollwheel: false,     
    };

But the user can still zoom in and zoom out for the map using double click. 但是,用户仍然可以使用双击放大和缩小地图。 Also there are some popups on map which displays some information about that place. 在地图上也有一些弹出窗口,显示有关该地点的一些信息。 How can i disable double click zoom in and the popups that gives information. 我如何禁用双击放大以及提供信息的弹出窗口。 Is there is something missed in this settings ? 此设置中是否缺少某些内容?

Update 更新

Finally got solution for disabling popups and links on Google map here . 最终获得了在此处禁用Google地图上的弹出窗口和链接的解决方案。

Here is demo 这是演示

Call this function when map is finished loading. 地图加载完成后调用此函数。

function fixInfoWindow() {
    var set = google.maps.InfoWindow.prototype.set;
    google.maps.InfoWindow.prototype.set = function (key, val) {
        if (key === 'map') {
            if (!this.get('noSupress')) {
                return;
            }
        }
        set.apply(this, arguments);
    }
}
disableDefaultUI: true,
scrollwheel: false,
navigationControl: false,
mapTypeControl: false,
scaleControl: false,

should do it if you're using V3 of Google Maps. 如果您使用的是Google Maps V3,则应这样做。 If not, you can call map.disableScrollWheelZoom(); 如果没有,则可以调用map.disableScrollWheelZoom();

To disable popups you could use something like.. 要禁用弹出窗口,您可以使用类似..

markerOptions : {
    visible: true,
    clickable: false
}

If you are trying to disable clickable poi-s, you can hide them using styles option of the map: 如果您要禁用可点击的Poi,则可以使用地图的样式选项将其隐藏:

var mapOptions = {
    styles: [
        {
            featureType: 'poi.business',
            elementType: 'labels',
            stylers: [
                { visibility: 'off' }
            ]
        }
    ]
};  
map = new google.maps.Map(document.getElementById(mapId),mapOptions);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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