Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update selectionmanager.js
Browse files Browse the repository at this point in the history
jokd committed Oct 26, 2023
1 parent 43306b4 commit d4bcbf0
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions src/selectionmanager.js
Original file line number Diff line number Diff line change
@@ -166,22 +166,24 @@ const Selectionmanager = function Selectionmanager(options = {}) {
}

/**
* Callback function that styles a feature when it is drawn.
* @param {any} feature
* Returns a style function to be used when a feature is drawn.
* @param {any} selectionGroup
*/
function featureStyler(feature) {
console.log(feature);
if (highlightedFeatures.includes(feature)) {
return Style.createStyleRule(multiselectStyleOptions.highlighted);
} else if (feature.getId() && feature.getId().toString().split('.')[0] === infowindow.getActiveSelectionGroup()) {
return Style.createStyleRule(multiselectStyleOptions.inActiveLayer ? multiselectStyleOptions.inActiveLayer : multiselectStyleOptions.selected);
function getFeatureStyler(selectionGroup) {
function featureStyler(feature) {
if (highlightedFeatures.includes(feature)) {
return Style.createStyleRule(multiselectStyleOptions.highlighted);
} else if (selectionGroup === infowindow.getActiveSelectionGroup()) {
return Style.createStyleRule(multiselectStyleOptions.inActiveLayer ? multiselectStyleOptions.inActiveLayer : multiselectStyleOptions.selected);
}
return Style.createStyleRule(multiselectStyleOptions.selected);
}
return Style.createStyleRule(multiselectStyleOptions.selected);
return featureStyler;
}

function createSelectionGroup(selectionGroup, selectionGroupTitle) {
const urvalLayer = featurelayer(null, map);
urvalLayer.setStyle(featureStyler);
urvalLayer.setStyle(getFeatureStyler(selectionGroup));
urval.set(selectionGroup, urvalLayer);
infowindow.createUrvalElement(selectionGroup, selectionGroupTitle);
}
@@ -285,11 +287,6 @@ const Selectionmanager = function Selectionmanager(options = {}) {
const item = event.element;

const selectionGroup = event.element.getSelectionGroup();
if (selectionGroup === infowindow.getActiveSelectionGroup()) {
item.getFeature().set('inActiveLayer', true);
} else {
item.getFeature().set('inActiveLayer', false);
}
const selectionGroupTitle = event.element.getSelectionGroupTitle();

if (!urval.has(selectionGroup)) {

0 comments on commit d4bcbf0

Please sign in to comment.