i would like to modify the below code in a such way that it only deactivate the zoom on double-click event please.
i tried the below posted code, but it disabled all the interactions including the mouse-wheel
code
this.map.getInteractions().forEach(x => x.setActive(false));
asked May 2, 2023 at 7:14
Amrmsmb
11.6k33 gold badges125 silver badges263 bronze badges
-
1try map.getInteractions().forEach(interaction => { if(interaction instanceof DoubleClickZoom){ interaction.setActive(false) } })BR75– BR752023年05月02日 07:49:58 +00:00Commented May 2, 2023 at 7:49
2 Answers 2
i solved it as shown in the follwoing code:
code:
import interactionDoubleClickZoom from 'ol/interaction/DoubleClickZoom';
this.map.getInteractions().forEach(x => {
if (x instanceof interactionDoubleClickZoom) {
x.setActive(false)
}
});
answered May 3, 2023 at 6:02
Amrmsmb
11.6k33 gold badges125 silver badges263 bronze badges
Sign up to request clarification or add additional context in comments.
You could disable default behaviour on Map initialisation:
export default function defaultMapInteractions(): Interaction[] {
return defaultInteractions({
doubleClickZoom: false,
shiftDragZoom: false,
dragPan: false,
altShiftDragRotate: true,
keyboard: false,
}).extend([
new DragPan({
condition: (event) => {
return (
(primaryAction(event) && (noModifierKeys(event) || altKeyOnly(event))) ||
(event.originalEvent as PointerEvent).button === 1
);
},
}),
]).getArray();
}
....
this.map = new olMap({
interactions: [
...defaultMapInteractions(),
],....
Comments
Explore related questions
See similar questions with these tags.