Skip to content

Commit

Permalink
Merge pull request #5085 from camptocamp/GSGMF-1057
Browse files Browse the repository at this point in the history
Increase query tolerance on 'touch' devices
  • Loading branch information
fredj committed Aug 27, 2019
2 parents 2ec7b54 + 2406d37 commit 8e6a1ae
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
4 changes: 0 additions & 4 deletions contribs/gmf/src/controllers/AbstractMobileController.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,5 @@ module.controller('AbstractMobileController', AbstractMobileController);

module.value('isMobile', true);

module.value('ngeoQueryOptions', {
'tolerance': 10
});


export default module;
11 changes: 9 additions & 2 deletions src/query/MapQuerent.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import angular from 'angular';
import {hasCoarsePointingDevice} from 'ngeo/utils.js';
import ngeoQueryAction from 'ngeo/query/Action.js';
import ngeoQueryQuerent from 'ngeo/query/Querent.js';
import ngeoDatasourceDataSources from 'ngeo/datasource/DataSources.js';
Expand Down Expand Up @@ -32,6 +33,7 @@ import ngeoMiscFeatureHelper from 'ngeo/misc/FeatureHelper.js';
* @property {number} [tolerance=3] When issuing an identify feature request at a click position, either a
* WMS GetFeatureInfo or a WFS GetFeature request will be used. For GetFeature requests a bbox is built
* around the position. This `tolerance` in pixel determines the size of the bbox.
* @property {number} [toleranceTouch=10] The tolerance on touch devices.
* @property {string} [featureNS='http://mapserver.gis.umn.edu/mapserver'] The feature namespace for WFS
* GetFeature requests.
* @property {string} [featurePrefix='feature'] The feature prefix for WFS GetFeature requests.
Expand Down Expand Up @@ -123,8 +125,13 @@ export class MapQuerent {
* @type {number}
* @private
*/
this.tolerancePx_ = options.tolerance !== undefined ?
options.tolerance : 3;
this.tolerancePx_;

if (hasCoarsePointingDevice()) {
this.tolerancePx_ = options.toleranceTouch !== undefined ? options.toleranceTouch : 10;
} else {
this.tolerancePx_ = options.tolerance !== undefined ? options.tolerance : 3;
}

/**
* @type {boolean}
Expand Down
10 changes: 10 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ import olGeomPolygon from 'ol/geom/Polygon.js';
import {getTopLeft, getTopRight, getBottomLeft, getBottomRight} from 'ol/extent.js';


/**
* Return whether the primary pointing device is coarse or 'false' if unsupported (Internet Explorer).
* See https://developer.mozilla.org/en-US/docs/Web/CSS/@media/pointer
* @return {boolean}
*/
export function hasCoarsePointingDevice() {
return matchMedia('(pointer: coarse)').matches;
}


/**
* @param {string[]} availableLanguages Available languages.
* @return {string} The "best" language code.
Expand Down

0 comments on commit 8e6a1ae

Please sign in to comment.