@@ -71,11 +71,11 @@ function makeLayerInteractive(map, layerId) {
7171 } ) ;
7272
7373 map . on ( 'mouseenter' , layerId , ( ) => {
74- map . getCanvas ( ) . geoJSONStyle . cursor = 'pointer' ;
74+ map . getCanvas ( ) . style . cursor = 'pointer' ;
7575 } ) ;
7676
7777 map . on ( 'mouseleave' , layerId , ( ) => {
78- map . getCanvas ( ) . geoJSONStyle . cursor = '' ;
78+ map . getCanvas ( ) . style . cursor = '' ;
7979 } ) ;
8080}
8181
@@ -93,6 +93,8 @@ export function addLayer(
9393 linesStyle = {
9494 // manual styling (values post-fixed with Force will win over geoJSONStyle)
9595 setInvisible : false ,
96+ lineColor : 'red' ,
97+ lineColorForce : 'red' ,
9698 isDotted : false ,
9799 lineBlur : 5 ,
98100 lineWidth : 5 ,
@@ -101,7 +103,7 @@ export function addLayer(
101103 lineWidthAtZoom16 : 5 ,
102104 hasGlow : false ,
103105 glowStyle : {
104- lineWidthFactor : 2. 5,
106+ lineWidthFactor : 5 ,
105107 lineBlur : 5
106108 } ,
107109 isGlow : false // will be set programmatically, not intended for outside use
@@ -263,10 +265,15 @@ export function addLayer(
263265 // Lines
264266 // --------------------------------------
265267 } else if ( featureType === 'MultiLineString' || featureType === 'LineString' ) {
268+ console . log ( 'LINE: ' , linesStyle ) ;
269+
266270 // CHECK GLOW AND RE-RUN addLayer
267271 if ( linesStyle ?. hasGlow ) {
272+ let linesStyleOfGlow = { ...linesStyle } ; // shallow copy is important!
268273 linesStyleOfGlow . hasGlow = false ;
269274 linesStyleOfGlow . isGlow = true ;
275+
276+ //
270277 addLayer (
271278 map ,
272279 feature ,
@@ -278,24 +285,18 @@ export function addLayer(
278285 linesStyleOfGlow ,
279286 pointsStyle
280287 ) ;
281- } else if ( linesStyle ?. isGlow ) {
282- addLayer (
283- map ,
284- feature ,
285- FEATURES ,
286- sourceId ,
287- layerId ,
288- geoJSONStyle ,
289- groupNames ,
290- linesStyleOfGlow ,
291- pointsStyle
292- ) ;
288+
289+ // before continuing, make sure isGlow is false for normal line
290+ linesStyle . isGlow = false ;
293291 }
294292
295- const lineWidthFactor = linesStyle ?. isGlow ? linesStyle ?. glowStyle ?. lineWidthFactor : 1 ; // glow must be wider
296- console . log ( 'LINE: ' , linesStyle ?. lineWidthForce * lineWidthFactor , lineWidthFactor ) ;
293+ const lineWidthFactor = linesStyle ?. isGlow ? linesStyle ?. glowStyle ?. lineWidthFactor || 2.5 : 1 ; // glow must be wider
294+ const layerIdGlow = `${ layerId } -glow` ;
295+
296+ console . log ( linesStyle ?. isGlow , linesStyle ?. lineWidthForce , lineWidthFactor ) ;
297+
297298 map . addLayer ( {
298- id : linesStyle ?. isGlow ? ` ${ layerId } -glow` : layerId ,
299+ id : linesStyle ?. isGlow ? layerIdGlow : layerId ,
299300 type : 'line' ,
300301 source : sourceId ,
301302 metadata : {
@@ -307,10 +308,10 @@ export function addLayer(
307308 // 'line-cap': 'round'
308309 } ,
309310 paint : {
310- 'line-color' : [
311+ 'line-color' : linesStyle ?. lineColorForce || [
311312 'coalesce' ,
312313 [ 'get' , 'lineColor' ] ,
313- getFromStyle ( geoJSONStyle , 'lineColor' ) || 'red'
314+ getFromStyle ( geoJSONStyle , 'lineColor' ) || linesStyle ?. lineColor || 'red'
314315 ] ,
315316 'line-width' :
316317 linesStyle ?. lineWidthForce * lineWidthFactor ||
@@ -332,9 +333,11 @@ export function addLayer(
332333 }
333334 // filter: ['==', ['get', 'id'], feature.properties.id]
334335 } ) ;
335- // make sure glow is not dashed
336- if ( linesStyle ?. hasGlow ) {
337- map . setPaintProperty ( id , 'line-dasharray' , null ) ;
336+
337+ // Adjustments
338+ // Make sure glow is not dashed
339+ if ( linesStyle ?. isGlow ) {
340+ map . setPaintProperty ( layerIdGlow , 'line-dasharray' , null ) ;
338341 }
339342
340343 // PUSH TO FEATURES
0 commit comments