Map client update #216

Merged
mpeltriaux merged 1 commits from map_tst into master 2022-10-07 13:57:45 +02:00
2 changed files with 36 additions and 37 deletions

View File

@ -221,8 +221,17 @@ class Geometry(BaseResource):
polygons.append(p)
geojson = {
"type": "FeatureCollection",
"crs": {
"type": "name",
"properties": {
"name": f"urn:ogc:def:crs:EPSG::{geom.srid}"
}
},
"features": [
json.loads(x.geojson) for x in polygons
{
"type": "Feature",
"geometry": json.loads(x.geojson)
} for x in polygons
]
}
return geojson

View File

@ -394,16 +394,12 @@ netgis.MapOpenLayers.prototype.clearAll = function()
{
for ( var i = 0; i < this.layers.length; i++ )
{
if(this.layers[i] === this.editLayer){
continue;
}
this.map.removeLayer( this.layers[ i ] );
}
this.layers = [this.editLayer];
this.layers = [];
this.snapFeatures.clear();
this.snapFeatures.push(this.editLayer);
};
netgis.MapOpenLayers.prototype.onUpdateStyle = function( e )
@ -1145,14 +1141,8 @@ netgis.MapOpenLayers.prototype.updateEditLayerItem = function()
netgis.MapOpenLayers.prototype.onEditFeaturesLoaded = function( e )
{
var json = e;
var format = new ol.format.GeoJSON();
var features = format.readFeatures( json );
this.editLayer.getSource().addFeatures( features );
//this.snapFeatures.push( e.feature );
if ( features.length > 0 )
this.view.fit( this.editLayer.getSource().getExtent(), { padding: [ 40, 40, 40, 40 ] } );
var self = this;
window.setTimeout( function() { self.createLayerGeoJSON( "Import", json ); }, 10 );
};
netgis.MapOpenLayers.prototype.onDragEnter = function( e )
@ -1267,6 +1257,7 @@ netgis.MapOpenLayers.prototype.createLayerGeoJSON = function( title, data )
//NOTE: netgis.util.foreach( proj4.defs, function( k,v ) { console.info( "DEF:", k, v ); } )
var projcode = projection.getCode();
switch ( projcode )
{
case "EPSG:3857":
@ -1452,7 +1443,6 @@ netgis.MapOpenLayers.prototype.createLayerShapefile = function( title, shapeData
netgis.MapOpenLayers.prototype.addImportedFeatures = function( features )
{
// ToDO: Changes in here problematic on initial data loading
// Add To Edit Layer
this.editEventsSilent = true;
this.editLayer.getSource().addFeatures( features );