Поддержка стилей JSON

This commit is contained in:
zakhy 2025-03-21 10:27:28 +07:00
parent d658317edd
commit 8a63838ec3

View File

@ -134,7 +134,7 @@
масштабирования</label>
</div>
{% if request.user.is_superuser %}
<button id="exportGeoJSON" class="btn btn-info float-right d-none">
<button id="exportGeoJSON" class="btn btn-info float-right">
Экспортировать GeoJSON
</button>
{% endif %}
@ -676,8 +676,8 @@
map.removeLayer(vectorLayer);
}
const kmlFeatures = new ol.format.KML({extractStyles: false}).readFeatures(kml, {
featureProjection: 'EPSG:3857',
})
featureProjection: 'EPSG:3857',
})
kmlFeatures.forEach(feature => {
feature.set('layer', 'kml')
})
@ -711,10 +711,17 @@
if (vectorLayer) {
map.removeLayer(vectorLayer);
}
const geoJSONFeatures = new ol.format.GeoJSON().readFeatures(geojson, {
featureProjection: 'EPSG:3857'
})
geoJSONFeatures.forEach(feature => {
console.log(feature.get('layer'))
if (!feature.get('layer')) {
feature.set('layer', 'geojson')
}
})
vectorSource = new ol.source.Vector({
features: new ol.format.GeoJSON().readFeatures(geojson, {
featureProjection: 'EPSG:3857'
})
features: geoJSONFeatures
});
vectorSource.on("addfeature", (event) => {