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

get popup on olayer features

parent 1879d285
No related branches found
No related tags found
No related merge requests found
...@@ -133,8 +133,8 @@ const mapService = { ...@@ -133,8 +133,8 @@ const mapService = {
router.push({ router.push({
name: 'details-signalement', name: 'details-signalement',
params: { params: {
slug_type_signal: featureTypeSlug, //'1-polygones' slug_type_signal: featureTypeSlug,
slug_signal: featureId, //'d267c6fa-d676-45c9-8e34-ec3d1bcc7c25' slug_signal: featureId,
}, },
}); });
} }
...@@ -143,7 +143,7 @@ const mapService = { ...@@ -143,7 +143,7 @@ const mapService = {
router.push({ router.push({
name: 'details-type-signalement', name: 'details-type-signalement',
params: { params: {
feature_type_slug: featureTypeSlug, //'1-polygones' feature_type_slug: featureTypeSlug,
}, },
}); });
} }
...@@ -152,11 +152,17 @@ const mapService = { ...@@ -152,11 +152,17 @@ const mapService = {
}, },
onMapClick(event) { onMapClick(event) {
//* retrieve features under pointer
const features = this.map.getFeaturesAtPixel(event.pixel, { const features = this.map.getFeaturesAtPixel(event.pixel, {
layerFilter: (l) => l === this.mvtLayer layerFilter: (l) => l === this.mvtLayer || this.olLayer
}); });
console.log('click', features[0], this.mvtLayer, this.olLayer);
//* prepare popup content
if (features && features.length > 0) { if (features && features.length > 0) {
const popupContent = this._createContentPopup(features[0], this.mvtLayer.featureTypes); console.log(this.mvtLayer, this.olLayer);
const popupContent = this._createContentPopup(
features[0], this.mvtLayer.featureTypes || this.olLayer.featureTypes
);
this.content.innerHTML = popupContent.html; this.content.innerHTML = popupContent.html;
this.overlay.setPosition(event.coordinate); this.overlay.setPosition(event.coordinate);
this.addRouterToPopup(popupContent.feature_type.slug, popupContent.featureId); this.addRouterToPopup(popupContent.feature_type.slug, popupContent.featureId);
...@@ -471,7 +477,7 @@ const mapService = { ...@@ -471,7 +477,7 @@ const mapService = {
let retour; let retour;
// TODO verifier utilité de cette boucle et remplacer par readFeatures plutot // TODO verifier utilité de cette boucle et remplacer par readFeatures plutot
features.forEach((feature) => { features.forEach((feature) => {
retour = new GeoJSON().readFeature(feature, { dataProjection: 'EPSG:4326', featureProjection: 'EPSG:3857' }); retour = new GeoJSON().readFeature(feature, { dataProjection: 'EPSG:4326', featureProjection: 'EPSG:3857' }, featureTypes);
drawSource.addFeature(retour); drawSource.addFeature(retour);
// const featureProperties = feature.properties ? feature.properties : feature; // const featureProperties = feature.properties ? feature.properties : feature;
// const featureType = featureTypes // const featureType = featureTypes
...@@ -493,6 +499,8 @@ const mapService = { ...@@ -493,6 +499,8 @@ const mapService = {
}); });
olLayer.setZIndex(29); olLayer.setZIndex(29);
this.map.addLayer(olLayer); this.map.addLayer(olLayer);
this.olLayer = olLayer;
this.olLayer.featureTypes = featureTypes;
return drawSource; return drawSource;
}, },
......
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