allow scale to be two dimensional
add getScaleArray() method test two dimension scale icons test two dimension scale text add example of icon and label scaling use smaller icon and larger interval test two dimensional scale icons test two dimensional scale icons
This commit is contained in:
@@ -2,13 +2,14 @@
|
||||
* @module ol/style/Image
|
||||
*/
|
||||
import {abstract} from '../util.js';
|
||||
import {toSize} from '../size.js';
|
||||
|
||||
/**
|
||||
* @typedef {Object} Options
|
||||
* @property {number} opacity
|
||||
* @property {boolean} rotateWithView
|
||||
* @property {number} rotation
|
||||
* @property {number} scale
|
||||
* @property {number|import("../size.js").Size} scale
|
||||
* @property {Array<number>} displacement
|
||||
*/
|
||||
|
||||
@@ -45,10 +46,16 @@ class ImageStyle {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {number}
|
||||
* @type {number|import("../size.js").Size}
|
||||
*/
|
||||
this.scale_ = options.scale;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {import("../size.js").Size}
|
||||
*/
|
||||
this.scaleArray_ = toSize(options.scale);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {Array<number>}
|
||||
@@ -62,9 +69,10 @@ class ImageStyle {
|
||||
* @api
|
||||
*/
|
||||
clone() {
|
||||
const scale = this.getScale();
|
||||
return new ImageStyle({
|
||||
opacity: this.getOpacity(),
|
||||
scale: this.getScale(),
|
||||
scale: Array.isArray(scale) ? scale.slice() : scale,
|
||||
rotation: this.getRotation(),
|
||||
rotateWithView: this.getRotateWithView(),
|
||||
displacement: this.getDisplacement().slice(),
|
||||
@@ -100,13 +108,21 @@ class ImageStyle {
|
||||
|
||||
/**
|
||||
* Get the symbolizer scale.
|
||||
* @return {number} Scale.
|
||||
* @return {number|import("../size.js").Size} Scale.
|
||||
* @api
|
||||
*/
|
||||
getScale() {
|
||||
return this.scale_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the symbolizer scale array.
|
||||
* @return {import("../size.js").Size} Scale array.
|
||||
*/
|
||||
getScaleArray() {
|
||||
return this.scaleArray_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the displacement of the shape
|
||||
* @return {Array<number>} Shape's center displacement
|
||||
@@ -219,11 +235,12 @@ class ImageStyle {
|
||||
/**
|
||||
* Set the scale.
|
||||
*
|
||||
* @param {number} scale Scale.
|
||||
* @param {number|import("../size.js").Size} scale Scale.
|
||||
* @api
|
||||
*/
|
||||
setScale(scale) {
|
||||
this.scale_ = scale;
|
||||
this.scaleArray_ = toSize(scale);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user