File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -127,14 +127,17 @@ export function createLayer(layerConfig, map) {
127
127
splitscreen : layerConfig . splitscreen ,
128
128
displayInLayerSwitcher : layerConfig . userVisible ,
129
129
source : new VectorSource ( {
130
- features : layerConfig . source . data ? new GeoJSON ( ) . readFeatures (
131
- ( typeof layerConfig . source . data == "string" ) ?
130
+ features : new GeoJSON ( ) . readFeatures (
131
+ ( layerConfig . source . data && typeof layerConfig . source . data == "string" ) ?
132
132
layerConfig . source . data :
133
- JSON . stringify ( layerConfig . source . data || { } ) , {
133
+ JSON . stringify ( layerConfig . source . data || {
134
+ "type" : "FeatureCollection" ,
135
+ "features" : [ ]
136
+ } ) , {
134
137
// Ensure the features are read with the correct projection
135
138
dataProjection : layerConfig . source . projection || 'EPSG:4326' , // Assuming the GeoJSON is in WGS 84
136
139
featureProjection : map . getView ( ) . getProjection ( ) || 'EPSG:3857' // Assuming the map projection
137
- } ) : [ ]
140
+ } )
138
141
} ) ,
139
142
// Add this line to apply a generic style to the layer
140
143
style : geoJsonStyleFunction
You can’t perform that action at this time.
0 commit comments