Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • geocontrib/geocontrib-frontend
  • ext_matthieu/geocontrib-frontend
  • fnecas/geocontrib-frontend
  • MatthieuE/geocontrib-frontend
4 results
Show changes
Commits on Source (7)
......@@ -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;
}
let filters = [];
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"
......@@ -426,7 +409,7 @@ const mapUtil = {
className: 'myDivIcon',
});
L.marker(geomJSON.coordinates, {
icon: customMapIcon,
icon: customMapIcon,
color: color,
zIndexOffset: 100
})
......@@ -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 }
......@@ -13,7 +13,9 @@ if (workbox) {
// Make sure to return a specific response for all navigation requests.
// Since we have a SPA here, this should be index.html always.
// https://stackoverflow.com/questions/49963982/vue-router-history-mode-with-pwa-in-offline-mode
workbox.routing.registerNavigationRoute('/geocontrib/index.html')
workbox.routing.registerNavigationRoute('/geocontrib/index.html', {
blacklist: [/\/api/,/\/admin/],
})
workbox.routing.registerRoute(
new RegExp('.*/config/config.json'),
......
......@@ -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
......