@@ -200,6 +200,7 @@ class MapManager {
200200 */
201201 addObservationLayer ( geojsonData , visible = true , options = { } ) {
202202 const fillColor = options . fillColor || options . color || '#ffd92f' ;
203+ const fillColorAbsence = options . fillColorAbsence || '#a6cee3' ;
203204 const strokeColor = options . strokeColor || '#000000' ;
204205 const radius = options . radius || 6 ;
205206 const strokeWidth = options . strokeWidth !== undefined ? options . strokeWidth : 1.25 ;
@@ -218,13 +219,21 @@ class MapManager {
218219 data : geojsonData
219220 } ) ;
220221
222+ // Use data-driven styling for presence/absence coloring
223+ const colorExpression = [
224+ 'case' ,
225+ [ '==' , [ 'get' , 'presence' ] , true ] ,
226+ fillColor ,
227+ fillColorAbsence
228+ ] ;
229+
221230 this . mbMap . addLayer ( {
222231 id : this . observationLayerId ,
223232 type : 'circle' ,
224233 source : this . observationSourceId ,
225234 paint : {
226235 'circle-radius' : radius ,
227- 'circle-color' : fillColor ,
236+ 'circle-color' : colorExpression ,
228237 'circle-opacity' : opacity ,
229238 'circle-stroke-color' : strokeColor ,
230239 'circle-stroke-width' : strokeWidth
@@ -239,14 +248,18 @@ class MapManager {
239248
240249 if ( this . map ) {
241250 this . layers . observations = L . geoJSON ( geojsonData , {
242- pointToLayer : ( _ , latlng ) => L . circleMarker ( latlng , {
243- radius : radius ,
244- color : strokeColor ,
245- weight : strokeWidth ,
246- fillColor : fillColor ,
247- fillOpacity : opacity ,
248- opacity : opacity
249- } )
251+ pointToLayer : ( feature , latlng ) => {
252+ const isPresent = feature . properties ?. presence === true ;
253+ const color = isPresent ? fillColor : fillColorAbsence ;
254+ return L . circleMarker ( latlng , {
255+ radius : radius ,
256+ color : strokeColor ,
257+ weight : strokeWidth ,
258+ fillColor : color ,
259+ fillOpacity : opacity ,
260+ opacity : opacity
261+ } ) ;
262+ }
250263 } ) ;
251264
252265 if ( visible ) {
0 commit comments