我希望我的应用程序中有一个选项,允许在用户需要时禁用捏合旋转。
我有一张 map :
map_object = new ol.Map({
target: 'map',
controls: controls_list,
interactions: interactions_list,
overlays: [overlay],
layers: vector_layers,
view: view
});
您会注意到我在 map 定义中以通常的方式定义了交互。我的交互列表如下:
var interactions_list = ol.interaction.defaults({altShiftDragRotate:false, pinchRotate:true, dragPan:true});
如何在创建 map 对象后禁用捏合旋转,以便在加载和显示 map 后禁用 map 旋转。
最佳答案
如果您使用 OpenLayers v3.1.1,您可以通过在交互上调用 setActive(true)
/setActive(false)
来启用/禁用交互。
首先,您需要在交互集合中找到 PinchRotate
交互:
var interactions = map.getInteractions().getArray();
var pinchRotateInteraction = interactions.filter(function(interaction) {
return interaction instanceof ol.interaction.PinchRotate;
})[0];
然后您可以根据需要启用和禁用交互:
pinchRotateInteraction.setActive(false);
pinchRotateInteraction.setActive(true);
关于jquery - 打开图层 3 加载 map 后禁用捏合旋转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27973091/