Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set pane in vector feature style to improve ordering #212

Merged
merged 2 commits into from
Feb 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions src/smk/viewer-leaflet/layer/layer-vector-leaflet.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,9 @@ include.module( 'layer-leaflet.layer-vector-leaflet-js', [ 'layer.layer-vector-j
} )
} )
.then( function ( projectCoord ) {
const layerPaneId = layers[0].config.id;
const overlayPane = self.map.getPane('overlayPane');
const layerPane = self.map.createPane(layers[0].config.id, overlayPane);
const layerPane = self.map.createPane(layerPaneId, overlayPane);
layerPane.style.zIndex = zIndex;

var layerOptions = {
Expand All @@ -155,8 +156,7 @@ include.module( 'layer-leaflet.layer-vector-leaflet-js', [ 'layer.layer-vector-j
} )
},
renderer: L.svg(),
interactive: false,
pane: layerPane
interactive: false
};

if (layers[0].config.conditionalStyles) {
Expand All @@ -166,17 +166,17 @@ include.module( 'layer-leaflet.layer-vector-leaflet-js', [ 'layer.layer-vector-j
layers[0].config.conditionalStyles.forEach(conditionalStyle => {
if (!Object.keys(feature.properties).includes(conditionalStyle.property)) {
console.debug(`The feature property ${conditionalStyle.property} was not found; conditional styling will not be applied for this property.`);
return convertStyle(combinedStyle, feature.geometry.type);
return convertStyle(combinedStyle, feature.geometry.type, layerPaneId);
}
conditionalStyle.conditions.filter(condition => condition.value === feature.properties[conditionalStyle.property]).forEach(condition => {
Object.assign(combinedStyle, condition.style);
});
});
return convertStyle(combinedStyle, feature.geometry.type);
return convertStyle(combinedStyle, feature.geometry.type, layerPaneId);
};
} else {
layerOptions.style = function(feature) {
return convertStyle(layers[0].config.style, feature.geometry.type);
return convertStyle(layers[0].config.style, feature.geometry.type, layerPaneId);
}
}

Expand Down Expand Up @@ -272,7 +272,7 @@ include.module( 'layer-leaflet.layer-vector-leaflet-js', [ 'layer.layer-vector-j

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

function convertStyle( styleConfig, type ) {
function convertStyle( styleConfig, type, layerPaneId ) {
if ( !styleConfig ) return {}

if ( type == 'Point' || type == 'MultiPoint' )
Expand All @@ -285,6 +285,7 @@ include.module( 'layer-leaflet.layer-vector-leaflet-js', [ 'layer.layer-vector-j
fillOpacity: styleConfig.fillOpacity,
stroke: styleConfig.stroke !== false,
fill: styleConfig.fill,
pane: layerPaneId
}
else
return {
Expand All @@ -299,6 +300,7 @@ include.module( 'layer-leaflet.layer-vector-leaflet-js', [ 'layer.layer-vector-j
fill: styleConfig.fill,
fillColor: styleConfig.fillColor,
fillOpacity: styleConfig.fillOpacity,
pane: layerPaneId
// fillRule: styleConfig.,
}
}
Expand Down