@@ -30,10 +30,13 @@ const pointData = {type: 'FeatureCollection','features': [{'type': 'Feature','pr
3030
3131const interactPlugin = createInteractPlugin ( {
3232 dataLayers : [ {
33- layerId : 'field-parcels' ,
33+ layerId : 'field-parcels-130 ' ,
3434 // idProperty: 'gid'
3535 } , {
36- layerId : 'linked-parcels' ,
36+ layerId : 'field-parcels-332' ,
37+ // idProperty: 'gid'
38+ } , {
39+ layerId : 'field-parcels-other' ,
3740 // idProperty: 'gid'
3841 } , {
3942 layerId : 'OS/TopographicArea_1/Agricultural Land' ,
@@ -98,8 +101,7 @@ const datasetsPlugin = createDatasetsPlugin({
98101 // ],
99102 // tiles: ['https://farming-tiles-702a60f45633.herokuapp.com/field_parcels_with_hedges/{z}/{x}/{y}'],
100103 // sourceLayer: 'field_parcels_filtered',
101- featureLayer : '' ,
102- vectorTileLayer : '' ,
104+ // featureLayer: '',
103105 // idProperty: 'id', // Enables dynamic fetching + deduplication
104106 // filter: ['get', ['propertyName', 'warning']],
105107 query : { } ,
@@ -110,39 +112,90 @@ const datasetsPlugin = createDatasetsPlugin({
110112 showInKey : true ,
111113 toggleVisibility : true ,
112114 // visibility: 'hidden',
113- stroke : { outdoor : '#0000ff' , dark : '#ffffff' } ,
114- strokeWidth : 2 ,
115- // symbol: '',
116- // symbolSvgContent: '',
117- // symbolForegroundColor: '',
118- // symbolBackgroundColor: '',
119- // symbolDescription: { outdoor: 'blue outline' },
120- // symbolOffset: [],
121- // fill: 'rgba(0,0,255,0.1)',
122- fillPattern : 'diagonal-cross-hatch' ,
123- fillPatternForegroundColor : { outdoor : '#0000ff' , dark : '#ffffff' } ,
124- fillPatternBackgroundColor : 'transparent' ,
125- featureStyleRules : [ {
115+ // style: {
116+ // stroke: { outdoor: '#0000ff', dark: '#ffffff' },
117+ // strokeWidth: 2,
118+ // symbol: '',
119+ // symbolSvgContent: '',
120+ // symbolForegroundColor: '',
121+ // symbolBackgroundColor: '',
122+ // symbolDescription: { outdoor: 'blue outline' },
123+ // symbolOffset: [],
124+ // fill: 'rgba(0,0,255,0.1)',
125+ // fillPattern: 'diagonal-cross-hatch',
126+ // fillPatternForegroundColor: { outdoor: '#0000ff', dark: '#ffffff' },
127+ // fillPatternBackgroundColor: 'transparent'
128+ // },
129+ sublayers : [ {
130+ id : '130' ,
131+ label : 'Permanent grassland' ,
132+ filter : [ '==' , [ 'get' , 'dominant_land_cover' ] , '130' ] , // 'dominant_land_cover = "130"'
133+ toggleVisibility : true ,
134+ style : {
135+ stroke : { outdoor : '#82F584' , dark : '#ffffff' } ,
136+ fillPattern : 'diagonal-cross-hatch' ,
137+ fillPatternForegroundColor : { outdoor : '#82F584' , dark : '#ffffff' } ,
138+ fillPatternBackgroundColor : 'transparent'
139+ }
140+ } , {
126141 id : '332' ,
127142 label : 'Woodland' ,
128143 filter : [ '==' , [ 'get' , 'dominant_land_cover' ] , '332' ] ,
129- stroke : { outdoor : '#00ff00' , dark : '#ffffff' } ,
130- fillPattern : 'cross-hatch' ,
131- fillPatternForegroundColor : { outdoor : '#00ff00' , dark : '#ffffff' } ,
132- fillPatternBackgroundColor : 'transparent' ,
133- toggleVisibility : true
144+ toggleVisibility : true ,
145+ style : {
146+ stroke : { outdoor : '#66CA7A' , dark : '#ffffff' } ,
147+ fillPattern : 'dot' ,
148+ fillPatternForegroundColor : { outdoor : '#66CA7A' , dark : '#ffffff' } ,
149+ fillPatternBackgroundColor : 'transparent'
150+ }
134151 } , {
135152 id : 'other' ,
136153 label : 'Others' ,
137- filter : [ '!=' , [ 'get' , 'dominant_land_cover' ] , '332' ] ,
138- stroke : { outdoor : '#0000ff' , dark : '#ffffff' } ,
154+ filter : [ '!' , [ 'in' , [ 'get' , 'dominant_land_cover' ] , [ 'literal' , [ '130' , '332' ] ] ] ] ,
155+ toggleVisibility : true ,
156+ style : {
157+ stroke : { outdoor : ' #1d70b8' , dark : '#ffffff' } ,
158+ fill : 'rgba(0,0,255,0.1)' ,
159+ fillPattern : 'vertical-hatch' ,
160+ fillPatternForegroundColor : { outdoor : '#1d70b8' , dark : '#ffffff' } ,
161+ // fillPatternBackgroundColor: 'transparent'
162+ }
163+ } ]
164+ } , {
165+ id : 'hedge-control' ,
166+ label : 'Hedge control' ,
167+ // groupLabel: 'Test group',
168+ tiles : [ 'https://farming-tiles-702a60f45633.herokuapp.com/field_parcels_with_hedges/{z}/{x}/{y}' ] ,
169+ sourceLayer : 'hedge_control' ,
170+ minZoom : 10 ,
171+ maxZoom : 24 ,
172+ showInKey : true ,
173+ toggleVisibility : true ,
174+ visibility : 'hidden' ,
175+ keySymbolShape : 'line' ,
176+ style : {
177+ stroke : '#b58840' ,
178+ fill : 'transparent' ,
179+ strokeWidth : 4 ,
180+ symbolDescription : { outdoor : 'blue outline' }
181+ }
182+ } , {
183+ id : 'linked-parcels' ,
184+ label : 'Existing fields' ,
185+ // groupLabel: 'Test group',
186+ filter : [ 'all' , [ '==' , [ 'get' , 'sbi' ] , '106223377' ] , [ '==' , [ 'get' , 'is_dominant_land_cover' ] , true ] ] ,
187+ tiles : [ 'https://farming-tiles-702a60f45633.herokuapp.com/field_parcels_with_hedges/{z}/{x}/{y}' ] ,
188+ sourceLayer : 'field_parcels_filtered' ,
189+ minZoom : 10 ,
190+ maxZoom : 24 ,
191+ showInKey : true ,
192+ toggleVisibility : true ,
193+ style : {
194+ stroke : '#0000ff' ,
195+ strokeWidth : 2 ,
139196 fill : 'rgba(0,0,255,0.1)' ,
140- // fillPattern: 'cross-hatch',
141- // fillPatternForegroundColor: { outdoor: '#00ff00', dark: '#ffffff' },
142- // fillPatternBackgroundColor: 'transparent',
143- toggleVisibility : true
144- } ] ,
145- opacity : 0.5
197+ symbolDescription : { outdoor : 'blue outline' }
198+ }
146199 } ]
147200} )
148201
@@ -217,8 +270,9 @@ interactiveMap.on('map:ready', function (e) {
217270} )
218271
219272interactiveMap . on ( 'datasets:ready' , function ( ) {
220- // setTimeout(() => datasetsPlugin.hideDataset('field-parcels'), 2000)
221- // setTimeout(() => datasetsPlugin.showDataset('field-parcels'), 4000)
273+ // setTimeout(() => datasetsPlugin.setFeatureVisibility(false, [55], { datasetId: 'field-parcels', idProperty: null }), 2000)
274+ // setTimeout(() => datasetsPlugin.setFeatureVisibility(true, [55], { datasetId: 'field-parcels', idProperty: null }), 4000)
275+ // setTimeout(() => datasetsPlugin.setStyle({ stroke: { outdoor: '#ff0000', dark: '#ffffff' }, fillPattern: 'horizontal-hatch', fillPatternForegroundColor: { outdoor: '#ff0000', dark: '#ffffff' } }, { datasetId: 'field-parcels', sublayerId: '130' }), 2000)
222276} )
223277
224278// Ref to the selected features
0 commit comments