Update Renderer documentation to clarify tolerance option Canvas only (#7515)

* update renderer doc to clarify tolerance option Canvas only

* Revert "update renderer doc to clarify tolerance option Canvas only"

This reverts commit 6d9e82fc20.

* moved tolerance option from Render to Canvas

* Refactor _clickTolerance

Co-authored-by: johnd0e <johnd0e@mail.ua>

Co-authored-by: johnd0e <johnd0e@mail.ua>
This commit is contained in:
Eric Hippler
2021-11-26 04:14:30 -05:00
committed by GitHub
parent 649eaf37e5
commit 8fbb149371
3 changed files with 12 additions and 6 deletions

View File

@ -38,6 +38,15 @@ import {Bounds} from '../../geometry/Bounds';
*/
export var Canvas = Renderer.extend({
// @section
// @aka Canvas options
options: {
// @option tolerance: Number = 0
// How much to extend the click tolerance around a path/object on the map.
tolerance: 0
},
getEvents: function () {
var events = Renderer.prototype.getEvents.call(this);
events.viewprereset = this._onViewPreReset;

View File

@ -142,6 +142,7 @@ export var Path = Layer.extend({
_clickTolerance: function () {
// used when doing hit detection for Canvas layers
return (this.options.stroke ? this.options.weight / 2 : 0) + this._renderer.options.tolerance;
return (this.options.stroke ? this.options.weight / 2 : 0) +
(this._renderer.options.tolerance || 0);
}
});

View File

@ -34,11 +34,7 @@ export var Renderer = Layer.extend({
// @option padding: Number = 0.1
// How much to extend the clip area around the map view (relative to its size)
// e.g. 0.1 would be 10% of map view in each direction
padding: 0.1,
// @option tolerance: Number = 0
// How much to extend click tolerance round a path/object on the map
tolerance : 0
padding: 0.1
},
initialize: function (options) {