Support declutter mode for image styles
Allows to specify for each image style, whether the image should be decluttered, always drawn but still serving as obstacle, or drawn without being an obstacle for other images/texts. The layer must still have declutter = true set for this property to have any effect.
This commit is contained in:
@@ -16,6 +16,7 @@ import RegularShape from './RegularShape.js';
|
||||
* (positive rotation clockwise, meaningful only when used in conjunction with a two dimensional scale).
|
||||
* @property {boolean} [rotateWithView=false] Whether to rotate the shape with the view
|
||||
* (meaningful only when used in conjunction with a two dimensional scale).
|
||||
* @property {"declutter"|"obstacle"|"none"|undefined} [declutterMode] Declutter mode
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -41,6 +42,7 @@ class CircleStyle extends RegularShape {
|
||||
options.rotateWithView !== undefined ? options.rotateWithView : false,
|
||||
displacement:
|
||||
options.displacement !== undefined ? options.displacement : [0, 0],
|
||||
declutterMode: options.declutterMode,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -59,6 +61,7 @@ class CircleStyle extends RegularShape {
|
||||
rotation: this.getRotation(),
|
||||
rotateWithView: this.getRotateWithView(),
|
||||
displacement: this.getDisplacement().slice(),
|
||||
declutterMode: this.getDeclutterMode(),
|
||||
});
|
||||
style.setOpacity(this.getOpacity());
|
||||
return style;
|
||||
|
||||
@@ -44,6 +44,7 @@ import {getUid} from '../util.js';
|
||||
* @property {import("../size.js").Size} [imgSize] Image size in pixels. Only required if `img` is set and `src` is not, and
|
||||
* for SVG images in Internet Explorer 11. The provided `imgSize` needs to match the actual size of the image.
|
||||
* @property {string} [src] Image source URI.
|
||||
* @property {"declutter"|"obstacle"|"none"|undefined} [declutterMode] Declutter mode
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -86,6 +87,7 @@ class Icon extends ImageStyle {
|
||||
displacement:
|
||||
options.displacement !== undefined ? options.displacement : [0, 0],
|
||||
rotateWithView: rotateWithView,
|
||||
declutterMode: options.declutterMode,
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
+17
-1
@@ -11,7 +11,7 @@ import {toSize} from '../size.js';
|
||||
* @property {number} rotation Rotation.
|
||||
* @property {number|import("../size.js").Size} scale Scale.
|
||||
* @property {Array<number>} displacement Displacement.
|
||||
*/
|
||||
* @property {"declutter"|"obstacle"|"none"|undefined} declutterMode Declutter mode: `declutter`, `obstacle`, 'none */
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
@@ -61,6 +61,12 @@ class ImageStyle {
|
||||
* @type {Array<number>}
|
||||
*/
|
||||
this.displacement_ = options.displacement;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {"declutter"|"obstacle"|"none"|undefined}
|
||||
*/
|
||||
this.declutterMode_ = options.declutterMode;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,6 +82,7 @@ class ImageStyle {
|
||||
rotation: this.getRotation(),
|
||||
rotateWithView: this.getRotateWithView(),
|
||||
displacement: this.getDisplacement().slice(),
|
||||
declutterMode: this.getDeclutterMode(),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -132,6 +139,15 @@ class ImageStyle {
|
||||
return this.displacement_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the declutter mode of the shape
|
||||
* @return {"declutter"|"obstacle"|"none"|undefined} Shape's declutter mode
|
||||
* @api
|
||||
*/
|
||||
getDeclutterMode() {
|
||||
return this.declutterMode_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the anchor point in pixels. The anchor determines the center point for the
|
||||
* symbolizer.
|
||||
|
||||
@@ -31,6 +31,7 @@ import {
|
||||
* @property {boolean} [rotateWithView=false] Whether to rotate the shape with the view.
|
||||
* @property {number|import("../size.js").Size} [scale=1] Scale. Unless two dimensional scaling is required a better
|
||||
* result may be obtained with appropriate settings for `radius`, `radius1` and `radius2`.
|
||||
* @property {"declutter"|"obstacle"|"none"|undefined} [declutterMode] Declutter mode
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -69,6 +70,7 @@ class RegularShape extends ImageStyle {
|
||||
scale: options.scale !== undefined ? options.scale : 1,
|
||||
displacement:
|
||||
options.displacement !== undefined ? options.displacement : [0, 0],
|
||||
declutterMode: options.declutterMode,
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -159,6 +161,7 @@ class RegularShape extends ImageStyle {
|
||||
rotateWithView: this.getRotateWithView(),
|
||||
scale: Array.isArray(scale) ? scale.slice() : scale,
|
||||
displacement: this.getDisplacement().slice(),
|
||||
declutterMode: this.getDeclutterMode(),
|
||||
});
|
||||
style.setOpacity(this.getOpacity());
|
||||
return style;
|
||||
|
||||
Reference in New Issue
Block a user