@@ -131,6 +131,7 @@ export default class MapWidget {
131
131
}
132
132
133
133
// TODO: Obsolete
134
+ /*
134
135
transformCenter(viewOptions: ViewOptions): ViewOptions {
135
136
const center = viewOptions.center;
136
137
if (center && viewOptions.projection !== "EPSG:4326") {
@@ -141,28 +142,27 @@ export default class MapWidget {
141
142
}
142
143
return viewOptions;
143
144
}
144
-
145
+ */
145
146
146
147
getMap ( ) : Map {
147
148
return this . _map ;
148
149
}
149
150
151
+ getMetadata ( ) : Metadata {
152
+ return this . _metadata ;
153
+ }
154
+
150
155
// TODO: Obsolete
151
156
getLayerOld ( layerId : string ) : Layer {
152
157
return this . _layerStore [ layerId ] ;
153
158
}
154
159
155
160
// TODO: Obsolete
161
+ /*
156
162
getControlOld(controlId: string): Control {
157
163
return this._controlStore[controlId];
158
164
}
159
-
160
- getControl ( controId : string ) : Control | undefined {
161
- for ( let control of this . _map . getControls ( ) . getArray ( ) ) {
162
- if ( control . get ( "id" ) === controId )
163
- return control ;
164
- }
165
- }
165
+ */
166
166
167
167
setViewFromSource ( layerId : string ) : void {
168
168
const layer = this . getLayer ( layerId ) ; // this._layerStore[layerId];
@@ -175,6 +175,7 @@ export default class MapWidget {
175
175
176
176
}
177
177
178
+ /*
178
179
addGeoJSONToSource(layer: Layer, geoJSONObject: any): void {
179
180
if (geoJSONObject === undefined)
180
181
return;
@@ -183,6 +184,7 @@ export default class MapWidget {
183
184
source.addFeatures(new GeoJSON().readFeatures(geoJSONObject));
184
185
console.log("geojsonObject added to VectorSource", geoJSONObject);
185
186
}
187
+ */
186
188
187
189
/*
188
190
addLayerOld(layerJSONDef: JSONDef): void {
@@ -198,6 +200,7 @@ export default class MapWidget {
198
200
}
199
201
*/
200
202
203
+ // --- Layers
201
204
getLayer ( layerId : string ) : Layer | undefined {
202
205
for ( let layer of this . _map . getLayers ( ) . getArray ( ) ) {
203
206
if ( layer . get ( "id" ) === layerId )
@@ -210,8 +213,7 @@ export default class MapWidget {
210
213
this . _map . addLayer ( layer ) ;
211
214
this . _metadata . layers . push ( {
212
215
id : layer . get ( "id" ) ,
213
- type : layerDef [ TYPE_IDENTIFIER ] ,
214
- extent : layer . getExtent ( )
216
+ type : layerDef [ TYPE_IDENTIFIER ]
215
217
} ) ;
216
218
console . log ( "layer" , layer . get ( "id" ) , "added" , this . _metadata ) ;
217
219
}
@@ -222,42 +224,56 @@ export default class MapWidget {
222
224
return ;
223
225
224
226
this . _map . removeLayer ( layer ) ;
225
- // delete this._layerStore[layerId];
226
227
this . _metadata . layers = this . _metadata . layers . filter ( item => item [ "id" ] != layerId ) ;
227
228
console . log ( "layer" , layerId , "removed" , this . _metadata ) ;
228
229
}
229
230
230
- addControl ( controlJSONDef : JSONDef ) : void {
231
- const control = jsonConverter . parse ( controlJSONDef ) ;
232
- control . set ( "id" , controlJSONDef . id ) ;
233
- // ...
231
+ // --- Controls
232
+ getControl ( controlId : string ) : Control | undefined {
233
+ for ( let control of this . _map . getControls ( ) . getArray ( ) ) {
234
+ if ( control . get ( "id" ) === controlId )
235
+ return control ;
236
+ }
237
+ }
238
+
239
+ addControl ( controlDef : JSONDef ) : void {
240
+ const control = jsonConverter . parse ( controlDef ) ;
241
+ control . set ( "id" , controlDef . id ) ;
234
242
this . _map . addControl ( control ) ;
235
- this . _controlStore [ controlJSONDef . id ] = control ;
236
- console . log ( "controlStore" , this . _controlStore ) ;
243
+ this . _metadata . controls . push ( {
244
+ id : control . get ( "id" ) ,
245
+ type : controlDef [ TYPE_IDENTIFIER ] ,
246
+ } ) ;
247
+ console . log ( "control" , control . get ( "id" ) , "added" , this . _metadata ) ;
237
248
}
238
249
239
250
removeControl ( controlId : string ) : void {
240
251
const control = this . getControl ( controlId ) ;
241
- if ( control === undefined ) return ;
242
-
243
- this . _map . removeControl ( control ) ;
244
- delete this . _controlStore [ controlId ] ;
245
- console . log ( "control" , controlId , "removed" , this . _controlStore ) ;
252
+ if ( control ) {
253
+ this . _map . removeControl ( control ) ;
254
+ this . _metadata . controls = this . _metadata . controls . filter ( item => item [ "id" ] != controlId ) ;
255
+ console . log ( "control" , controlId , "removed" , this . _metadata ) ;
256
+ }
246
257
}
247
258
259
+ // --- Misc
248
260
setLayerStyle ( layerId : string , style : any ) : void {
249
261
const layer = this . getLayer ( layerId ) as VectorLayer | WebGLVectorLayer ;
250
- layer . setStyle ( style )
262
+ if ( layer ) {
263
+ console . log ( "set layer style" , layerId , style ) ;
264
+ layer . setStyle ( style )
265
+ }
251
266
}
252
267
253
268
applyCallToLayer ( layerId : string , call : OLAnyWidgetCall ) : void {
254
- console . log ( "layer call" , "layerId ", layerId ) ;
269
+ console . log ( "run layer method " , layerId ) ;
255
270
const layer = this . getLayer ( layerId ) ;
256
271
257
272
// @ts -expect-error
258
273
layer [ call . method ] ( ...call . args )
259
274
}
260
275
276
+ // TODO: Remove
261
277
testJSONDef ( jsonDef : JSONDef ) : any {
262
278
return jsonConverter . parse ( jsonDef ) ;
263
279
}
@@ -266,7 +282,7 @@ export default class MapWidget {
266
282
debugData ( data : any ) : void {
267
283
}
268
284
269
- // ...
285
+ // TODO: Test only at the moment
270
286
addOverlay ( position : Coordinate | undefined ) : void {
271
287
const el = document . createElement ( "div" ) ;
272
288
el . style . cssText = "" ;
@@ -277,7 +293,6 @@ export default class MapWidget {
277
293
278
294
// ...
279
295
addTooltip ( prop : string | null ) : void {
280
- // addTooltipTo(this._map, prop);
281
296
addTooltip2 ( this . _map , prop ) ;
282
297
}
283
298
}
0 commit comments