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

Merge branch 'develop' into redmine-issues/11784

parents a705aa0d 1eb3e453
No related branches found
No related tags found
1 merge request!162REDMINE_ISSUE-11784
......@@ -298,24 +298,23 @@ const mapUtil = {
// Redraw the layers
this.addLayers(layers);
},
// eslint-disable-next-line no-unused-vars
retrieveFeatureColor: function (featureType, properties) {
if (featureType && featureType.colors_style && featureType.colors_style.custom_field_name) {
const currentValue = properties[featureType.colors_style.custom_field_name];
const colorStyle = featureType.colors_style.colors[currentValue];
return colorStyle ? colorStyle : featureType.color
}
},
addVectorTileLayer: function (url, project_slug, featureTypes, form_filters) {
layerMVT = L.vectorGrid.protobuf(url, {
vectorTileLayerStyles: {
"default": function (properties, zoom) {
// console.log(properties);
let featureType = featureTypes.find((x) => x.slug.split('-')[0] === '' + properties.feature_type_id);
let color = featureType.color;
if (featureType.colors_style && featureType.colors_style.custom_field_name) {
let currentValue = properties[featureType.colors_style.custom_field_name];
let colorValue = featureType.colors_style.colors[currentValue];
if (colorValue) {
color = colorValue;
}
"default": (properties) => {
const featureType = featureTypes.find((x) => x.slug.split('-')[0] === '' + properties.feature_type_id);
const color = this.retrieveFeatureColor(featureType, properties)
}
let hiddenStyle = ({
const hiddenStyle = ({
radius: 0,
fillOpacity: 0.5,
weight: 0,
......@@ -347,21 +346,19 @@ const mapUtil = {
fill: true,
color: color,
});
},
},
// subdomains: "0123",
// key: 'abcdefghi01234567890',
interactive: true,
maxNativeZoom: 14,
maxNativeZoom: 18,
getFeatureId: function (f) {
return f.properties.id;
}
});
let self = this;
layerMVT.on('click', function (e) { // The .on method attaches an event handler
console.log("click on mvt", e);
const popupContent = self._createContentPopup(e.layer, featureTypes, project_slug);
layerMVT.on('click', (e) => { // The .on method attaches an event handler
console.log("e", e);
const popupContent = this._createContentPopup(e.layer, featureTypes, project_slug);
L.popup()
.setContent(popupContent)
.setLatLng(e.latlng)
......@@ -372,16 +369,12 @@ const mapUtil = {
},
addFeatures: function (features, filter, addToMap = true, featureTypes) {
let featureGroup = new L.FeatureGroup();
const featureGroup = new L.FeatureGroup();
features.forEach((feature) => {
let featureType = featureTypes.find((x) => x.slug === feature.properties.feature_type.slug);
if (!featureType) {
featureType = feature.properties.feature_type;
}
const featureType = featureTypes.find((ft) => ft.slug === (feature.properties.feature_type.slug || feature.properties.feature_type));
let filters = [];
if (filter) {
const typeCheck = filter.featureType && feature.properties.feature_type.slug === filter.featureType;
const statusCheck = filter.featureStatus && feature.properties.status.value === filter.featureStatus;
......@@ -390,30 +383,20 @@ const mapUtil = {
}
if (!filter || !Object.values(filter).some(val => val) || Object.values(filter).some(val => val) && filters.length && filters.every(val => val !== false)) {
const geomJSON = flip(feature.geometry);
const popupContent = this._createContentPopup(feature);
// Look for a custom field
let customField;
let customFieldOption;
if (Object.keys(feature.properties).some(el => featureType.customfield_set.map(e => e.name).includes(el))) {
if (Object.keys(feature.properties).some(el => featureType.customfield_set && featureType.customfield_set.map(e => e.name).includes(el))) {
customField = Object.keys(feature.properties).filter(el => featureType.customfield_set.map(e => e.name).includes(el));
customFieldOption = feature.properties[customField[0]];
}
const color = this.retrieveFeatureColor(featureType, feature.properties) || feature.properties.color;
let color;
if (customFieldOption && featureType.colors_style) {
color = featureType.colors_style.value.colors[customFieldOption].value
} else {
color = feature.properties.color;
}
if (color == undefined) {
color = featureType.color;
}
if (geomJSON.type === 'Point') {
if (customFieldOption && featureType.colors_style) {
if (customFieldOption && featureType.colors_style && featureType.colors_style.value && featureType.colors_style.value.icons) {
const iconHTML = `
<i
class="fas fa-${featureType.colors_style.value.icons[customFieldOption]} fa-2x"
......@@ -483,9 +466,9 @@ const mapUtil = {
let feature_url = feature.properties.feature_url;
if (featureTypes) { // => VectorTile
feature_type = featureTypes.find((x) => x.slug.split('-')[0] === '' + feature.properties.feature_type_id);
status = statusList.find((x) => x.value == feature.properties.status).name;
status = statusList.find((x) => x.value === feature.properties.status).name;
date_maj = formatDate(new Date(feature.properties.updated_on));
feature_type_url = '/geocontrib/projet/' + project_slug + '/type_signalement/' + feature_type.slug + '/';
feature_type_url = '/geocontrib/projet/' + project_slug + '/type-signalement/' + feature_type.slug + '/';
feature_url = feature_type_url + 'signalement/' + feature.properties.feature_id + '/';
//status=feature.properties.status;
} else {
......@@ -520,4 +503,4 @@ const mapUtil = {
},
};
export { mapUtil }
\ No newline at end of file
export { mapUtil }
......@@ -916,7 +916,6 @@ export default {
},
updateGeomField(newGeom) {
//this.geometry = newGeom;
this.form.geom.value = newGeom.geometry;
this.updateStore();
},
......@@ -933,19 +932,16 @@ export default {
mapDefaultViewZoom,
});
const currentFeatureId = this.$route.params.slug_signal;
setTimeout(
function () {
let project_id = this.$route.params.slug.split("-")[0];
const mvtUrl = `${this.$store.state.configuration.VUE_APP_DJANGO_API_BASE}features.mvt/?tile={z}/{x}/{y}&project_id=${project_id}`;
mapUtil.addVectorTileLayer(
mvtUrl,
this.$route.params.slug,
this.$store.state.feature_type.feature_types
);
}.bind(this),
1000
);
setTimeout(() => {
let project_id = this.$route.params.slug.split("-")[0];
const mvtUrl = `${this.$store.state.configuration.VUE_APP_DJANGO_API_BASE}features.mvt/?tile={z}/{x}/{y}&project_id=${project_id}`;
mapUtil.addVectorTileLayer(
mvtUrl,
this.$route.params.slug,
this.$store.state.feature_type.feature_types
);
}, 1000);
const url = `${this.$store.state.configuration.VUE_APP_DJANGO_API_BASE}projects/${this.$route.params.slug}/feature/?feature_type__slug=${this.$route.params.slug_type_signal}&output=geojson`;
axios
.get(url)
......@@ -1029,12 +1025,9 @@ export default {
this.onFeatureTypeLoaded();
this.initExtraForms(this.feature);
setTimeout(
function () {
mapUtil.addGeocoders(this.$store.state.configuration);
}.bind(this),
1000
);
setTimeout(() => {
mapUtil.addGeocoders(this.$store.state.configuration);
}, 1000);
});
},
......
......@@ -245,6 +245,10 @@ export default {
"archived_on",
"deletion_on",
"feature_type",
"display_creator",
"display_last_editor",
"project",
"creator",
],
};
},
......
......@@ -236,6 +236,7 @@
v-if="
project &&
type.is_editable &&
type.geom_type === 'point' &&
permissions &&
permissions.can_create_feature_type &&
isOffline() != true
......
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