Skip to content

Commit

Permalink
Deactivate map query on long press
Browse files Browse the repository at this point in the history
  • Loading branch information
fredj committed Aug 23, 2019
1 parent 15001cf commit 9977e19
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
1 change: 1 addition & 0 deletions contribs/gmf/apps/desktop/index.html.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@
gmf-map-manage-resize="mainCtrl.manageResize"
gmf-map-resize-transition="mainCtrl.resizeTransition"
gmf-contextualdata=""
gmf-contextualdata-displayed="mainCtrl.contextdataActive"
gmf-contextualdata-map="::mainCtrl.map"
gmf-contextualdata-projections="::[21781, 4326]"
ngeo-map-query=""
Expand Down
1 change: 1 addition & 0 deletions contribs/gmf/apps/oeedit/index.html.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
</div>
<gmf-map class="gmf-map" gmf-map-map="mainCtrl.map"
gmf-contextualdata=""
gmf-contextualdata-displayed="mainCtrl.contextdataActive"
gmf-contextualdata-map="::mainCtrl.map"
gmf-contextualdata-projections="::[21781, 4326]"
ngeo-map-query=""
Expand Down
20 changes: 18 additions & 2 deletions contribs/gmf/src/contextualdata/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ function contextualDataComponent() {
scope: false,
controller: 'GmfContextualdataController as cdCtrl',
bindToController: {
'displayed': '=gmfContextualdataDisplayed',
'map': '<gmfContextualdataMap',
'projections': '<gmfContextualdataProjections',
'callback': '<gmfContextualdataCallback'
Expand Down Expand Up @@ -100,6 +101,11 @@ export function ContextualdataController($compile, $timeout, $scope, gmfRaster,
*/
this.projections = [];

/**
* @type {boolean}
*/
this.displayed = false;

/**
* @type {function(import("ol/coordinate.js").Coordinate, Object):Object}
*/
Expand Down Expand Up @@ -148,7 +154,11 @@ export function ContextualdataController($compile, $timeout, $scope, gmfRaster,
this.gmfContextualdataOptions_ = $injector.has('gmfContextualdataOptions') ?
$injector.get('gmfContextualdataOptions') : {};

document.body.addEventListener('mousedown', this.hidePopover.bind(this));
document.body.addEventListener('mousedown', () => {
this.$scope_.$apply(() => {
this.hidePopover();
});
});
}

/**
Expand All @@ -171,7 +181,11 @@ ContextualdataController.prototype.init = function() {
mapDiv.addEventListener('touchmove', this.handleMapTouchEnd_.bind(this));
mapDiv.addEventListener('touchend', this.handleMapTouchEnd_.bind(this));

this.map.on('pointerdown', this.hidePopover.bind(this));
this.map.on('pointerdown', () => {
this.$scope_.$apply(() => {
this.hidePopover();
});
});
};


Expand Down Expand Up @@ -300,6 +314,7 @@ ContextualdataController.prototype.showPopover = function() {
throw new Error('Missing element');
}
element.style.display = 'block';
this.displayed = true;
};

ContextualdataController.prototype.hidePopover = function() {
Expand All @@ -311,6 +326,7 @@ ContextualdataController.prototype.hidePopover = function() {
throw new Error('Missing element');
}
element.style.display = 'none';
this.displayed = false;
};

module.controller('GmfContextualdataController', ContextualdataController);
Expand Down
8 changes: 8 additions & 0 deletions contribs/gmf/src/controllers/AbstractAppController.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,11 @@ export function AbstractAppController(config, map, $scope, $injector) {
*/
this.printPanelActive = false;

/**
* @type {boolean}
*/
this.contextdataActive;

/**
* @type {boolean}
*/
Expand Down Expand Up @@ -499,6 +504,9 @@ export function AbstractAppController(config, map, $scope, $injector) {
const printPanelActivate = new ngeoMiscToolActivate(this, 'printPanelActive');
ngeoToolActivateMgr.registerTool(mapTools, printPanelActivate, false);

const contextdataActivate = new ngeoMiscToolActivate(this, 'contextdataActive');
ngeoToolActivateMgr.registerTool(mapTools, contextdataActivate, false);

$scope.$root.$on(ThemeEventType.THEME_NAME_SET, (event, name) => {
this.gmfThemes_.getThemeObject(name).then((theme) => {
this.setDefaultBackground_(theme);
Expand Down

0 comments on commit 9977e19

Please sign in to comment.