@@ -13,7 +13,6 @@ export default function useCurrentLocationLayer(map: Map, locationState: Current
13
13
const accuracyFeatureRef = useRef < Feature | null > ( null )
14
14
const headingFeatureRef = useRef < Feature | null > ( null )
15
15
16
- // Create layer once when enabled
17
16
useEffect ( ( ) => {
18
17
if ( ! locationState . enabled ) {
19
18
if ( layerRef . current ) {
@@ -65,12 +64,13 @@ export default function useCurrentLocationLayer(map: Map, locationState: Current
65
64
positionFeatureRef . current . setGeometry ( new Point ( coord ) )
66
65
accuracyFeatureRef . current . setGeometry ( new Circle ( coord , locationState . accuracy ) )
67
66
68
- // Set heading feature position (style will handle the triangle and rotation)
67
+ // set heading feature position (style will handle the triangle and rotation)
69
68
if ( locationState . heading != null ) {
70
69
headingFeatureRef . current . setGeometry ( new Point ( coord ) )
71
70
headingFeatureRef . current . set ( 'heading' , locationState . heading )
72
71
} else {
73
72
headingFeatureRef . current . setGeometry ( undefined )
73
+ headingFeatureRef . current . unset ( 'heading' ) // not strictly necessary
74
74
}
75
75
76
76
if ( locationState . syncView ) {
@@ -99,23 +99,22 @@ function createLocationLayer(): VectorLayer<VectorSource> {
99
99
style : feature => {
100
100
const geometry = feature . getGeometry ( )
101
101
if ( geometry instanceof Point ) {
102
- // Check if this is the heading feature
103
102
const heading = feature . get ( 'heading' )
104
103
if ( heading !== undefined ) {
105
- // Triangle style for heading direction
104
+ // triangle style for heading direction
106
105
return new Style ( {
107
106
image : new RegularShape ( {
108
107
points : 3 ,
109
108
radius : 8 ,
110
109
displacement : [ 0 , 9 ] ,
111
- rotation : ( heading * Math . PI ) / 180 , // Convert degrees to radians
110
+ rotation : ( heading * Math . PI ) / 180 , // convert degrees to radians
112
111
fill : new Fill ( { color : '#368fe8' } ) ,
113
112
stroke : new Stroke ( { color : '#FFFFFF' , width : 1 } ) ,
114
113
} ) ,
115
114
zIndex : 1 ,
116
115
} )
117
116
} else {
118
- // Blue dot style for position
117
+ // blue dot style for position
119
118
return new Style ( {
120
119
image : new CircleStyle ( {
121
120
radius : 8 ,
@@ -126,7 +125,7 @@ function createLocationLayer(): VectorLayer<VectorSource> {
126
125
} )
127
126
}
128
127
} else if ( geometry instanceof CircleGeom ) {
129
- // Accuracy circle style
128
+ // accuracy circle style
130
129
return new Style ( {
131
130
fill : new Fill ( { color : 'rgba(66, 133, 244, 0.1)' } ) ,
132
131
stroke : new Stroke ( { color : 'rgba(66, 133, 244, 0.3)' , width : 1 } ) ,
@@ -135,6 +134,6 @@ function createLocationLayer(): VectorLayer<VectorSource> {
135
134
}
136
135
return [ ]
137
136
} ,
138
- zIndex : 4 , // Above paths and query points
137
+ zIndex : 4 , // layer itself should be above paths and query points
139
138
} )
140
139
}
0 commit comments