Sensible defaults
This commit is contained in:
@@ -4,7 +4,7 @@ title: Icon modification
|
||||
shortdesc: Example using a Modify interaction to edit an icon.
|
||||
docs: >
|
||||
The icon on this map can be dragged to modify its location.
|
||||
<p>The Modify interaction can be configured with a `layer` option. With this option, hit detection will be used to determine the modification candidate.</p>
|
||||
<p>The Modify interaction can be configured with a `hitDetection` option. With this option, the modification candidate will not be determined by the `pixelTolerance`, but match the visual appearance of the geometry.</p>
|
||||
tags: "vector, modify, icon, marker"
|
||||
---
|
||||
<div id="map" class="map"></div>
|
||||
|
||||
@@ -128,9 +128,8 @@ const ModifyEventType = {
|
||||
* provided, a vector source must be provided with the `source` option.
|
||||
* @property {boolean} [wrapX=false] Wrap the world horizontally on the sketch
|
||||
* overlay.
|
||||
* @property {boolean} [snapToPointer=false] The vertex, point or segment being modified snaps to the
|
||||
* pointer coordinate when clicked within the `pixelTolerance`. Setting this to `true` is recommended
|
||||
* when the `Snap` interaction is used and the source geometry is not a snap target.
|
||||
* @property {boolean} [snapToPointer=!hitDetection] The vertex, point or segment being modified snaps to the
|
||||
* pointer coordinate when clicked within the `pixelTolerance`.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -393,7 +392,10 @@ class Modify extends PointerInteraction {
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
this.snapToPointer_ = options.snapToPointer || false;
|
||||
this.snapToPointer_ =
|
||||
options.snapToPointer === undefined
|
||||
? !this.hitDetection_
|
||||
: options.snapToPointer;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1045,9 +1045,8 @@ describe('ol.interaction.Modify', function () {
|
||||
);
|
||||
});
|
||||
|
||||
it('snaps to pointer when snapToPointer is true', function () {
|
||||
it('snaps to pointer by default', function () {
|
||||
const modify = new Modify({
|
||||
snapToPointer: true,
|
||||
source: source,
|
||||
});
|
||||
map.addInteraction(modify);
|
||||
@@ -1061,9 +1060,10 @@ describe('ol.interaction.Modify', function () {
|
||||
expect(pointFeature.getGeometry().getCoordinates()).to.eql([2, -2]);
|
||||
});
|
||||
|
||||
it('does not snap to pointer by default', function () {
|
||||
it('does not snap to pointer when snapToPointer is false', function () {
|
||||
const modify = new Modify({
|
||||
source: source,
|
||||
snapToPointer: false,
|
||||
});
|
||||
map.addInteraction(modify);
|
||||
source.clear();
|
||||
|
||||
Reference in New Issue
Block a user