@@ -9,15 +9,26 @@ export function highlightMatchedDivisions(map, divisions) {
99
1010 console . log ( 'Highlighting divisions:' , divisions )
1111
12- // Reset all divisions to default style
13- map . setPaintProperty ( 'divisions-fill' , 'fill-color' , '#627BC1' )
14- map . setPaintProperty ( 'divisions-fill' , 'fill-opacity' , 0.2 )
1512 // Reset text styling to defaults
16- map . setPaintProperty ( 'divisions-labels' , 'text-color' , '#ffffff' )
17- map . setPaintProperty ( 'divisions-labels' , 'text-halo-color' , '#ff474c' )
18- map . setPaintProperty ( 'divisions-labels' , 'text-halo-width' , 2 )
13+ map . setPaintProperty ( 'divisions-labels' , 'text-color' , [
14+ 'case' ,
15+ [ 'any' ,
16+ [ '==' , [ 'typeof' , [ 'get' , 'count' ] ] , 'null' ] ,
17+ [ '<=' , [ 'to-number' , [ 'get' , 'count' ] ] , 0 ]
18+ ] ,
19+ '#666666' , // Dark gray for zero/null values
20+ '#ffffff' // White for non-zero values
21+ ] )
22+ map . setPaintProperty ( 'divisions-labels' , 'text-halo-color' , '#000000' )
23+ map . setPaintProperty ( 'divisions-labels' , 'text-halo-width' , 1 )
24+
25+ // Reset line styling
26+ map . setPaintProperty ( 'divisions-layer' , 'line-color' , '#627BC1' )
27+ map . setPaintProperty ( 'divisions-layer' , 'line-width' , 1 )
1928
2029 if ( ! divisions || divisions . length === 0 ) {
30+ // Clear highlight effects
31+ map . setPaintProperty ( 'divisions-highlight' , 'fill-opacity' , 0 )
2132 return [ ]
2233 }
2334
@@ -33,41 +44,57 @@ export function highlightMatchedDivisions(map, divisions) {
3344
3445 console . log ( 'Applying match filter:' , JSON . stringify ( matchFilter ) )
3546
36- // Highlight matched divisions
37- map . setPaintProperty ( 'divisions-fill' , 'fill-color' , [
47+ // Update highlight overlay for matched divisions
48+ map . setPaintProperty ( 'divisions-highlight' , 'fill-opacity' , [
49+ 'case' ,
50+ matchFilter ,
51+ 0.4 , // Semi-transparent highlight for matches
52+ 0 // Invisible for non-matches
53+ ] )
54+
55+ // Add a bright border for highlighted divisions
56+ map . setPaintProperty ( 'divisions-layer' , 'line-color' , [
3857 'case' ,
3958 matchFilter ,
40- '#ff474c' , // Highlight color for matches
41- '#627BC1' // Default color
59+ '#ff474c' , // Highlight color for matches
60+ '#627BC1' // Default color
4261 ] )
4362
44- map . setPaintProperty ( 'divisions-fill ' , 'fill-opacity ' , [
63+ map . setPaintProperty ( 'divisions-layer ' , 'line-width ' , [
4564 'case' ,
4665 matchFilter ,
47- 0 .5, // Higher opacity for matches
48- 0.2 // Default opacity
66+ 2 .5, // Thicker line for matches
67+ 1 // Default line width
4968 ] )
5069
5170 // Update text styling based on highlight state
5271 map . setPaintProperty ( 'divisions-labels' , 'text-color' , [
5372 'case' ,
5473 matchFilter ,
55- '#333333' , // Dark text for highlighted divisions
56- '#ffffff' // White text for normal divisions
74+ '#000000' , // Black text for highlighted divisions
75+ [
76+ 'case' ,
77+ [ 'any' ,
78+ [ '==' , [ 'typeof' , [ 'get' , 'count' ] ] , 'null' ] ,
79+ [ '<=' , [ 'to-number' , [ 'get' , 'count' ] ] , 0 ]
80+ ] ,
81+ '#666666' , // Dark gray for zero/null values
82+ '#ffffff' // White for non-zero values
83+ ]
5784 ] )
5885
5986 map . setPaintProperty ( 'divisions-labels' , 'text-halo-color' , [
6087 'case' ,
6188 matchFilter ,
6289 '#ffffff' , // White halo for highlighted divisions
63- '#ff474c' // Red halo for normal divisions
90+ '#000000' // Black halo for normal divisions
6491 ] )
6592
6693 map . setPaintProperty ( 'divisions-labels' , 'text-halo-width' , [
6794 'case' ,
6895 matchFilter ,
6996 2.5 , // Wider halo for highlighted divisions
70- 2 // Normal halo width for others
97+ 1 // Normal halo width for others
7198 ] )
7299
73100 return convertedDivisions
0 commit comments