Skip to content

Commit

Permalink
Merge pull request #5568 from camptocamp/GSGMF-1225
Browse files Browse the repository at this point in the history
Allow map pan with all the mouse buttons
  • Loading branch information
fredj committed Feb 27, 2020
2 parents eba91fb + 85b36a1 commit 401ca73
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions contribs/gmf/src/controllers/AbstractAPIController.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ import angular from 'angular';
import gmfControllersAbstractAppController, {AbstractAppController, getLocationIcon}
from 'gmf/controllers/AbstractAppController.js';
import ngeoMapResizemap from 'ngeo/map/resizemap.js';
import * as olProj from 'ol/proj.js';
import {get as getProjection} from 'ol/proj.js';
import olMap from 'ol/Map.js';
import olView from 'ol/View.js';
import olControlScaleLine from 'ol/control/ScaleLine.js';
import olControlZoom from 'ol/control/Zoom.js';
import olControlRotate from 'ol/control/Rotate.js';
import * as olInteraction from 'ol/interaction.js';
import {defaults as interactionsDefaults} from 'ol/interaction.js';
import olInteractionDragPan from 'ol/interaction/DragPan.js';
import {noModifierKeys} from 'ol/events/condition.js';

/**
* API application abstract controller.
Expand All @@ -47,15 +49,15 @@ export class AbstractAPIController extends AbstractAppController {
*/
constructor(config, $scope, $injector) {
const viewConfig = {
projection: olProj.get(`EPSG:${config.srid || 2056}`)
projection: getProjection(`EPSG:${config.srid || 2056}`)
};
Object.assign(viewConfig, config.mapViewConfig || {});

const scaleline = document.getElementById('scaleline');
if (!scaleline) {
throw new Error('Missing scaleline');
}
super(config, new olMap({
const map = new olMap({
pixelRatio: config.mapPixelRatio,
layers: [],
view: new olView(viewConfig),
Expand All @@ -73,11 +75,16 @@ export class AbstractAPIController extends AbstractAppController {
tipLabel: ''
})
],
interactions: config.mapInteractions || olInteraction.defaults({
interactions: config.mapInteractions || interactionsDefaults({
pinchRotate: true,
altShiftDragRotate: true
})
}), $scope, $injector);
});
map.addInteraction(new olInteractionDragPan({
condition: noModifierKeys
}));

super(config, map, $scope, $injector);
}
}

Expand Down

0 comments on commit 401ca73

Please sign in to comment.