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

get map code to work again

parent 17287c2a
No related branches found
No related tags found
No related merge requests found
...@@ -31,8 +31,8 @@ ...@@ -31,8 +31,8 @@
<div class="item"> <div class="item">
<h4> <h4>
<!-- {{ featuresCount }} signalement{{ featuresCount > 1 ? "s" : "" }} --> <!-- {{ featuresCount }} signalement{{ featuresCount > 1 ? "s" : "" }} -->
{{ geojsonFeatures.length }} signalement{{ {{ filteredFeatures.length }} signalement{{
geojsonFeatures.length > 1 ? "s" : "" filteredFeatures.length > 1 ? "s" : ""
}} }}
</h4> </h4>
</div> </div>
...@@ -298,6 +298,40 @@ export default { ...@@ -298,6 +298,40 @@ export default {
return pageNumb; return pageNumb;
}); });
}, },
filteredFeatures() {
let results = this.geojsonFeatures;
if (this.form.type.selected) {
results = results.filter(
(el) => el.properties.feature_type.title === this.form.type.selected
);
}
if (this.form.status.selected.value) {
console.log("filter by" + this.form.status.selected.value);
results = results.filter(
(el) => el.properties.status.value === this.form.status.selected.value
);
}
if (this.form.title) {
results = results.filter((el) => {
if (el.properties.title) {
return el.properties.title
.toLowerCase()
.includes(this.form.title.toLowerCase());
} else
return el.id.toLowerCase().includes(this.form.title.toLowerCase());
});
}
return results;
},
},
watch: {
filteredFeatures(newValue, oldValue) {
if (newValue && newValue !== oldValue) {
this.onFilterChange();
}
},
}, },
methods: { methods: {
...@@ -345,9 +379,8 @@ export default { ...@@ -345,9 +379,8 @@ export default {
}, },
onFilterChange() { onFilterChange() {
console.log("onFilterChange", this.featureGroup);
if (this.featureGroup) { if (this.featureGroup) {
const features = this.geojsonFeatures; const features = this.filteredFeatures;
this.featureGroup.clearLayers(); this.featureGroup.clearLayers();
this.featureGroup = mapUtil.addFeatures( this.featureGroup = mapUtil.addFeatures(
features, features,
...@@ -410,7 +443,6 @@ export default { ...@@ -410,7 +443,6 @@ export default {
}, },
getNloadGeojsonFeatures() { getNloadGeojsonFeatures() {
console.log("getNloadGeojsonFeatures");
const url = `${this.$store.state.configuration.VUE_APP_DJANGO_API_BASE}projects/${this.$route.params.slug}/feature/?output=geojson`; const url = `${this.$store.state.configuration.VUE_APP_DJANGO_API_BASE}projects/${this.$route.params.slug}/feature/?output=geojson`;
this.$store.commit( this.$store.commit(
"DISPLAY_LOADER", "DISPLAY_LOADER",
...@@ -419,7 +451,6 @@ export default { ...@@ -419,7 +451,6 @@ export default {
axios axios
.get(url) .get(url)
.then((response) => { .then((response) => {
console.log(response);
if (response.status === 200 && response.data.features.length > 0) { if (response.status === 200 && response.data.features.length > 0) {
this.geojsonFeatures = response.data.features; this.geojsonFeatures = response.data.features;
this.loadFeatures(); this.loadFeatures();
...@@ -471,7 +502,6 @@ export default { ...@@ -471,7 +502,6 @@ export default {
}, },
buildFilterParams({ filterType, filterValue }) { buildFilterParams({ filterType, filterValue }) {
console.log({ filterType, filterValue });
let params = ""; let params = "";
let typeFilter, statusFilter; let typeFilter, statusFilter;
//*** feature type ***// //*** feature type ***//
......
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