File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ function displayImportedShapes(importedShapes)
8282 }
8383
8484 let classificationId = importedShapes [ i ] . classificationId ;
85- let geoJson = importedShapes [ i ] . geoJson ;
85+ let geoJsonObj = JSON . parse ( importedShapes [ i ] . geoJson ) ;
8686
8787 let shapeId = "Shape-" + id ;
8888 let mapId = "map-" + shapeId ;
@@ -129,19 +129,22 @@ function displayImportedShapes(importedShapes)
129129 "name" : "EPSG:4326"
130130 }
131131 } ,
132- "features" : [ { "type" :"Feature" , "properties" :{ } , "geometry" : JSON . parse ( geoJson ) } ]
132+ "features" : [ { "type" :"Feature" , "properties" :{ } , "geometry" : geoJsonObj } ]
133133 } ;
134134
135- var vectorSource = new ol . source . Vector ( {
135+ let vectorSource = new ol . source . Vector ( {
136136 features : ( new ol . format . GeoJSON ( ) ) . readFeatures ( geojsonObject )
137137 } ) ;
138138
139139
140- var vectorLayer = new ol . layer . Vector ( {
140+ let vectorLayer = new ol . layer . Vector ( {
141141 source : vectorSource
142142 } ) ;
143143
144- var map = new ol . Map ( {
144+ let center = [ 0 , 0 ] ;
145+ if ( geoJsonObj . coordinates [ 0 ] [ 0 ] [ 0 ] )
146+ center = geoJsonObj . coordinates [ 0 ] [ 0 ] [ 0 ] ;
147+ let map = new ol . Map ( {
145148 target : mapId ,
146149 layers : [
147150 new ol . layer . Tile ( {
@@ -151,8 +154,8 @@ function displayImportedShapes(importedShapes)
151154 ] ,
152155 view : new ol . View ( {
153156 projection : 'EPSG:4326' ,
154- center : [ 0 , 0 ] ,
155- zoom : 2
157+ center : center ,
158+ zoom : 8
156159 } )
157160 } ) ;
158161 }
You can’t perform that action at this time.
0 commit comments