Skip to content
Snippets Groups Projects
Commit 84fd72e3 authored by Timothee P's avatar Timothee P :sunflower:
Browse files

add snap on feature edition & fix undefined feature_type in popup

parent 7655fd95
No related branches found
No related tags found
No related merge requests found
import { Draw } from 'ol/interaction'; import { Draw, Snap } from 'ol/interaction';
import GeometryType from 'ol/geom/GeometryType'; import GeometryType from 'ol/geom/GeometryType';
import Modify from 'ol/interaction/Modify'; import Modify from 'ol/interaction/Modify';
import Select from 'ol/interaction/Select'; import Select from 'ol/interaction/Select';
...@@ -267,6 +267,28 @@ const editionService = { ...@@ -267,6 +267,28 @@ const editionService = {
removeActiveFeatures() { removeActiveFeatures() {
this.drawnFeature = null; this.drawnFeature = null;
this.featureToEdit = null; this.featureToEdit = null;
},
addSnapInteraction(map) {
// The snap interaction must be added after the Modify and Draw interactions
// in order for its map browser event handlers to be fired first. Its handlers
// are responsible of doing the snapping.
// Since we can't give a list of source to snap,
// we use this workaround, an interaction collection: https://github.com/openlayers/openlayers/issues/7100
let interactions = [];
map.getLayers().forEach((layer) => {
if (layer instanceof VectorLayer) {
let interaction = new Snap({
source: layer.getSource()
});
interactions.push(interaction);
}
});
for(let snap of interactions ) {
map.addInteraction(snap);
}
} }
}; };
......
...@@ -554,7 +554,7 @@ const mapService = { ...@@ -554,7 +554,7 @@ const mapService = {
Statut : ${status} Statut : ${status}
</div> </div>
<div> <div>
Type : <a id="goToFeatureTypeDetail" class="pointer"> ${feature_type.title} </a> Type : ${ feature_type ? '<a id="goToFeatureTypeDetail" class="pointer">' + feature_type.title + '</a>' : 'Type de signalement inconnu' }
</div> </div>
<div> <div>
Dernière&nbsp;mise&nbsp;à&nbsp;jour&nbsp;:&nbsp;${date_maj} Dernière&nbsp;mise&nbsp;à&nbsp;jour&nbsp;:&nbsp;${date_maj}
......
...@@ -888,6 +888,7 @@ export default { ...@@ -888,6 +888,7 @@ export default {
)[0]; )[0];
editionService.setFeatureToEdit(currentFeature); editionService.setFeatureToEdit(currentFeature);
this.updateMap(currentFeature); this.updateMap(currentFeature);
editionService.addSnapInteraction(this.map);
} }
} }
this.mapLoading = false; this.mapLoading = false;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment