@@ -23,9 +23,10 @@ export interface LayerEditorProps<TConfig = any> {
2323 onChange : ( options : ExtendMapLayerOptions < TConfig > ) => void ;
2424 filter : ( item : ExtendMapLayerRegistryItem ) => boolean ;
2525 showNameField ?: boolean ; // Show the name field in the options
26+ isBaselayerEditor ?: boolean ;
2627}
2728
28- export const LayerEditor : FC < LayerEditorProps > = ( { options, onChange, data, filter, showNameField } ) => {
29+ export const LayerEditor : FC < LayerEditorProps > = ( { options, onChange, data, filter, showNameField, isBaselayerEditor = false } ) => {
2930 // all basemaps
3031 const layerTypes = useMemo ( ( ) => {
3132 return geomapLayerRegistry . selectOptions (
@@ -210,23 +211,31 @@ export const LayerEditor: FC<LayerEditorProps> = ({ options, onChange, data, fil
210211 builder . addSliderInput ( {
211212 path : 'opacity' ,
212213 name : 'Opacity' ,
213- defaultValue : 1 ,
214214 settings : {
215215 min : 0 ,
216216 max : 1 ,
217217 step : 0.1 ,
218218 } ,
219+ defaultValue : 1 ,
220+ } ) ;
221+ }
222+
223+ if ( ! isBaselayerEditor ) {
224+ builder . addBooleanSwitch ( {
225+ path : 'visible' ,
226+ name : 'Layer is selected by default in the layer switch control' ,
227+ description : 'If toggled the layer is selected by default in the layer switch control. Uncheck to have the layer invisible by default.' ,
228+ settings : { } ,
229+ defaultValue : true
219230 } ) ;
220231 }
221232
222233 if ( layer . registerOptionsUI ) {
223234 layer . registerOptionsUI ( builder ) ;
224235 }
225236
226-
227-
228237 return builder ;
229- } , [ options ?. type , showNameField ] ) ;
238+ } , [ options ?. type , showNameField , isBaselayerEditor ] ) ;
230239
231240 // The react components
232241 const layerOptions = useMemo ( ( ) => {
@@ -243,11 +252,13 @@ export const LayerEditor: FC<LayerEditorProps> = ({ options, onChange, data, fil
243252 const context : StandardEditorContext < any > = {
244253 data,
245254 // options: options,
246- options : { ...options , opacity : options ?. opacity === undefined && layer . showOpacity ? 1.0 : options ?. opacity }
255+ options : {
256+ ...options ,
257+ opacity : options ?. opacity === undefined && layer . showOpacity ? 1.0 : options ?. opacity ,
258+ visible : options ?. visible === undefined ? true : options ?. visible
259+ }
247260 } ;
248261
249-
250-
251262 const currentOptions = { ...options , type : layer . id , config : { ...layer . defaultOptions , ...options ?. config } } ;
252263
253264 // Update the panel options if not set
0 commit comments