Skip to content

Commit

Permalink
Merge pull request origo-map#1202 from origo-map/share-__-wfs-layer-s…
Browse files Browse the repository at this point in the history
…election-amelioration

handle selected features in wfs layers with "__" in the name in a shared map
  • Loading branch information
Grammostola authored Mar 17, 2021
2 parents fb23d80 + 442063a commit 41d0186
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/featureinfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ const Featureinfo = function Featureinfo(options = {}) {
selection.coordinates = firstFeature.getGeometry().getCoordinates();
selection.id = firstFeature.getId() != null ? firstFeature.getId() : firstFeature.ol_uid;
selection.type = typeof selectionLayer.getSourceLayer() === 'string' ? selectionLayer.getFeatureLayer().type : selectionLayer.getSourceLayer().get('type');
if (selection.type === 'WFS') {
const idSuffix = selection.id.substring(selection.id.lastIndexOf('.') + 1, selection.id.length);
selection.id = `${selectionLayer.getSourceLayer().get('name')}.${idSuffix}`;
}
if (selection.type !== 'WFS') {
const name = typeof selectionLayer.getSourceLayer() === 'string' ? selectionLayer.getSourceLayer() : selectionLayer.getSourceLayer().get('name');
const id = firstFeature.getId() || selection.id;
Expand Down
5 changes: 4 additions & 1 deletion src/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ const Viewer = function Viewer(targetOption, options = {}) {
});

if (urlParams.feature) {
const featureId = urlParams.feature;
let featureId = urlParams.feature;
const layerName = featureId.split('.')[0];
const layer = getLayer(layerName);
const type = layer.get('type');
Expand All @@ -420,6 +420,9 @@ const Viewer = function Viewer(targetOption, options = {}) {
if (type === 'WFS' && clusterSource) {
feature = clusterSource.getFeatureById(featureId);
} else if (type === 'WFS') {
if (featureId.includes('__')) {
featureId = featureId.replace(featureId.substring(featureId.lastIndexOf('__'), featureId.lastIndexOf('.')), '');
}
feature = layer.getSource().getFeatureById(featureId);
} else if (clusterSource) {
feature = clusterSource.getFeatureById(id);
Expand Down

0 comments on commit 41d0186

Please sign in to comment.