Skip to content

Commit

Permalink
fix(VectorTile): supp order in Style as it's only a Label properties …
Browse files Browse the repository at this point in the history
…in VT
  • Loading branch information
ftoromanoff committed Nov 26, 2024
1 parent 48e7916 commit b70b32d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 15 deletions.
18 changes: 4 additions & 14 deletions src/Core/Style.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,15 +302,12 @@ function _addIcon(icon, domElement, opt) {
}

/**
* An object that can contain any properties (order, zoom, fill, stroke, point,
* An object that can contain any properties (zoom, fill, stroke, point,
* text or/and icon) and sub properties of a Style.<br/>
* Used for the instanciation of a {@link Style}.
*
* @typedef {Object} StyleOptions
*
* @property {Number} [order] - Order of the features that will be associated to
* the style. It can helps sorting and prioritizing features if needed.
*
* @property {Object} [zoom] - Level on which to display the feature
* @property {Number} [zoom.max] - max level
* @property {Number} [zoom.min] - min level
Expand Down Expand Up @@ -468,8 +465,6 @@ function _addIcon(icon, domElement, opt) {
* The first parameter of functions used to set `Style` properties is always an object containing
* the properties of the features displayed with the current `Style` instance.
*
* @property {Number} order - Order of the features that will be associated to
* the style. It can helps sorting and prioritizing features if needed.
* @property {Object} fill - Polygons and fillings style.
* @property {String|Function|THREE.Color} fill.color - Defines the main color of the filling. Can be
* any [valid color
Expand Down Expand Up @@ -619,15 +614,13 @@ function _addIcon(icon, domElement, opt) {
class Style {
/**
* @param {StyleOptions} [params={}] An object that contain any properties
* (order, zoom, fill, stroke, point, text or/and icon)
* (zoom, fill, stroke, point, text or/and icon)
* and sub properties of a Style ({@link StyleOptions}).
*/
constructor(params = {}) {
this.isStyle = true;
this.context = new StyleContext();

this.order = params.order || 0;

params.zoom = params.zoom || {};
params.fill = params.fill || {};
params.stroke = params.stroke || {};
Expand Down Expand Up @@ -767,13 +760,12 @@ class Style {
* set Style from vector tile layer properties.
* @param {Object} layer vector tile layer.
* @param {Object} sprites vector tile layer.
* @param {Number} [order=0]
* @param {Boolean} [symbolToCircle=false]
* @param {Set} warn Set storing all warnings encountered by the source.
*
* @returns {StyleOptions} containing all properties for itowns.Style
*/
static setFromVectorTileLayer(layer, sprites, order = 0, symbolToCircle = false, warn) {
static setFromVectorTileLayer(layer, sprites, symbolToCircle = false, warn) {
const style = {
fill: {},
stroke: {},
Expand All @@ -785,8 +777,6 @@ class Style {
layer.layout = layer.layout || {};
layer.paint = layer.paint || {};

style.order = order;

if (layer.type === 'fill') {
const { color, opacity } = rgba2rgb(readVectorProperty(layer.paint['fill-color'] || layer.paint['fill-pattern'], { type: 'color' }));
style.fill.color = color;
Expand Down Expand Up @@ -848,7 +838,7 @@ class Style {

// content
style.text.field = readVectorProperty(layer.layout['text-field']);
style.text.wrap = readVectorProperty(layer.layout['text-max-width']);
style.text.wrap = readVectorProperty(layer.layout['text-max-width']);// Units ems
style.text.spacing = readVectorProperty(layer.layout['text-letter-spacing']);
style.text.transform = readVectorProperty(layer.layout['text-transform']);
style.text.justify = readVectorProperty(layer.layout['text-justify']);
Expand Down
1 change: 1 addition & 0 deletions src/Layer/LabelLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ class LabelLayer extends GeometryLayer {
const label = new Label(content, coord.clone(), this.style);

label.layerId = this.id;
label.order = f.order;
label.padding = this.margin || label.padding;

labels.push(label);
Expand Down
2 changes: 1 addition & 1 deletion src/Source/VectorTilesSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class VectorTilesSource extends TMSSource {
layer[prop] = refLayer[prop];
});
}
const style = Style.setFromVectorTileLayer(layer, this.sprites, order, this.symbolToCircle, this.warn);
const style = Style.setFromVectorTileLayer(layer, this.sprites, this.symbolToCircle, this.warn);
this.styles[layer.id] = style;

if (!this.layers[layer['source-layer']]) {
Expand Down

0 comments on commit b70b32d

Please sign in to comment.