首页 / 浏览问题 / WebGIS / 问题详情
如何屏蔽默认的双击放大地图事件,使用自定义事件
24EXP 2021年02月01日
iClient 8C

如何屏蔽默认的双击放大地图事件,使用自定义事件

1个回答

你好,你可以使用doubleClickZoom:false,来禁止地图双击放大事件。
3,740EXP 2021年02月01日
iClient8c没有提供这个属性

你好,我在官网leaflet的示例(https://iclient.supermap.io/examples/leaflet/editor.html#01_tiledMapLayer4326)里面测试了是没问题的

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title data-i18n="resources.title_tiledMapLayer4326"></title>
<script type="text/javascript" src="../js/include-web.js"></script>
</head>
<body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
<div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
<script type="text/javascript" src="../../dist/leaflet/include-leaflet.js"></script>
<script type="text/javascript">
    var host = window.isLocal ? window.server : "https://iserver.supermap.io";
    var map, url = host + "/iserver/services/map-world/rest/maps/World";
    map = L.map('map', {
        crs: L.CRS.EPSG4326,
        center: [0, 0],
        maxZoom: 18,
        zoom: 1,
        doubleClickZoom:false
    });
    L.supermap.tiledMapLayer(url).addTo(map);

</script>
</body>
</html>

openlayer示例(https://iclient.supermap.io/examples/openlayers/editor.html#01_tiledMapLayer4326)里面也可以实现


<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title data-i18n="resources.title_tiledMapLayer4326"></title>
<script type="text/javascript" src="../js/include-web.js"></script>
<script type="text/javascript" src="../../dist/ol/include-ol.js"></script>
</head>
<body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%; position: absolute;top: 0;">
<div id="map" style="width: 100%;height:100%"></div>
<script type="text/javascript">
    var map, url = (window.isLocal ? window.server : "https://iserver.supermap.io")+"/iserver/services/map-world/rest/maps/World";
    map = new ol.Map({
        target: 'map',
        controls: ol.control.defaults({attributionOptions: {collapsed: false}})
            .extend([new ol.supermap.control.Logo()]),
        view: new ol.View({
            center: [0, 0],
            zoom: 2,
            projection: 'EPSG:4326',
            multiWorld: true
        })
    });
    const dblClickInteraction = map
        .getInteractions()
        .getArray()
        .find(interaction => {
          return interaction instanceof ol.interaction.DoubleClickZoom;
        });
    map.removeInteraction(dblClickInteraction);
    var layer = new ol.layer.Tile({
        source: new ol.source.TileSuperMapRest({
            url: url,
            wrapX: true
        }),
        projection: 'EPSG:4326'
    });
    map.addLayer(layer);
    map.addControl(new ol.supermap.control.ScaleLine());
</script>
</body>
</html>

我用的是classic

你好,你可以使用这个方式,用classic的https://iclient.supermap.io/examples/classic/editor.html#map_4326Map

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title data-i18n="resources.title_zoom"></title>
<script type="text/javascript" src="../js/include-web.js"></script>
</head>
<body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
<div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
<script type="text/javascript" exclude="iclient-classic" src="../../dist/classic/include-classic.js"></script>
<script type="text/javascript">
    var host = window.isLocal ? window.server : "https://iserver.supermap.io";
    var map, layerWorld;
    var url = host + "/iserver/services/map-world/rest/maps/World";
    map = new SuperMap.Map("map", {
        controls: []
    });
    //初始化简易缩放控件类
    var zoom = new SuperMap.Control.Zoom();
    var navigation = new SuperMap.Control.Navigation();
    //加载控件
    map.addControl(zoom);
    map.addControl(navigation);
    navigation.handlers.click.deactivate();
    //获取图层服务地址
    layerWorld = new SuperMap.Layer.TiledDynamicRESTLayer("World", url, {
        transparent: true,
        cacheEnabled: true
    }, {maxResolution: "auto"});
    layerWorld.events.on({"layerInitialized": addLayer});
    //添加地图图层、缩放控件到map
    function addLayer() {
        map.addLayer(layerWorld);
        map.setCenter(new SuperMap.LonLat(0, 0), 2);
    }
</script>
</body>
</html>

好的谢谢
...