Map类扩展方法之DoubleClickZoom
Map.mergeOptions({
doubleClickZoom: true,
});
export var DoubleClickZoom = Handler.extend({
addHooks: function () {
this._map.on("dblclick", this._onDoubleClick, this);
},
removeHooks: function () {
this._map.off("dblclick", this._onDoubleClick, this);
},
_onDoubleClick: function (e) {
var map = this._map,
oldZoom = map.getZoom(),
delta = map.options.zoomDelta,
zoom = e.originalEvent.shiftKey ? oldZoom - delta : oldZoom + delta;
if (map.options.doubleClickZoom === "center") {
map.setZoom(zoom);
} else {
map.setZoomAround(e.containerPoint, zoom);
}
},
});
Map.addInitHook("addHandler", "doubleClickZoom", DoubleClickZoom);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
编辑 (opens new window)
上次更新: 2025/04/07, 10:30:16