@@ -14,7 +14,7 @@ import { Env } from '@/lib/env';
1414mapboxgl . accessToken = Env . UNIT_MAPBOX_PUBKEY ;
1515
1616// Context to share map instance with child components
17- export const MapContext = React . createContext < mapboxgl . Map | null > ( null ) ;
17+ export const MapContext = React . createContext < any | null > ( null ) ;
1818
1919// StyleURL constants matching native Mapbox SDK
2020export const StyleURL = {
@@ -76,7 +76,7 @@ export const MapView = forwardRef<any, MapViewProps>(
7676 ref
7777 ) => {
7878 const mapContainer = useRef < HTMLDivElement > ( null ) ;
79- const map = useRef < mapboxgl . Map | null > ( null ) ;
79+ const map = useRef < any | null > ( null ) ;
8080 const [ isLoaded , setIsLoaded ] = useState ( false ) ;
8181
8282 useImperativeHandle ( ref , ( ) => ( {
@@ -166,7 +166,7 @@ interface CameraProps {
166166// Camera component
167167export const Camera = forwardRef < any , CameraProps > ( ( { centerCoordinate, zoomLevel, heading, pitch, animationDuration = 1000 , followUserLocation, followZoomLevel } , ref ) => {
168168 const map = React . useContext ( MapContext ) ;
169- const geolocateControl = useRef < mapboxgl . GeolocateControl | null > ( null ) ;
169+ const geolocateControl = useRef < any | null > ( null ) ;
170170
171171 useImperativeHandle ( ref , ( ) => ( {
172172 setCamera : ( options : { centerCoordinate ?: [ number , number ] ; zoomLevel ?: number ; heading ?: number ; pitch ?: number ; animationDuration ?: number } ) => {
@@ -203,6 +203,8 @@ export const Camera = forwardRef<any, CameraProps>(({ centerCoordinate, zoomLeve
203203 useEffect ( ( ) => {
204204 if ( ! map || ! followUserLocation ) return ;
205205
206+ let triggerTimeoutId : any ;
207+
206208 // Add geolocate control for following user
207209 if ( ! geolocateControl . current ) {
208210 geolocateControl . current = new mapboxgl . GeolocateControl ( {
@@ -216,11 +218,14 @@ export const Camera = forwardRef<any, CameraProps>(({ centerCoordinate, zoomLeve
216218 }
217219
218220 // Trigger tracking after control is added
219- setTimeout ( ( ) => {
221+ triggerTimeoutId = setTimeout ( ( ) => {
220222 geolocateControl . current ?. trigger ( ) ;
221223 } , 100 ) ;
222224
223225 return ( ) => {
226+ if ( triggerTimeoutId ) {
227+ clearTimeout ( triggerTimeoutId ) ;
228+ }
224229 if ( geolocateControl . current ) {
225230 map . removeControl ( geolocateControl . current ) ;
226231 geolocateControl . current = null ;
@@ -246,7 +251,7 @@ interface PointAnnotationProps {
246251// PointAnnotation component
247252export const PointAnnotation : React . FC < PointAnnotationProps > = ( { id, coordinate, title, children, anchor = { x : 0.5 , y : 0.5 } , onSelected } ) => {
248253 const map = React . useContext ( MapContext ) ;
249- const markerRef = useRef < mapboxgl . Marker | null > ( null ) ;
254+ const markerRef = useRef < any | null > ( null ) ;
250255 const containerRef = useRef < HTMLDivElement | null > ( null ) ;
251256 const containerRootRef = useRef < any > ( null ) ;
252257
@@ -266,18 +271,16 @@ export const PointAnnotation: React.FC<PointAnnotationProps> = ({ id, coordinate
266271 }
267272
268273 // Determine marker options based on anchor prop
269- const markerOptions : mapboxgl . MarkerOptions = {
274+ const markerOptions : any = {
270275 element : container ,
271276 } ;
272277
273278 // Handle anchor prop - if it's a string, use it as mapbox anchor
274279 if ( typeof anchor === 'string' ) {
275- markerOptions . anchor = anchor as mapboxgl . Anchor ;
280+ markerOptions . anchor = anchor as any ;
276281 }
277282
278- markerRef . current = new mapboxgl . Marker ( markerOptions )
279- . setLngLat ( coordinate )
280- . addTo ( map ) ;
283+ markerRef . current = new mapboxgl . Marker ( markerOptions ) . setLngLat ( coordinate ) . addTo ( map ) ;
281284
282285 // If anchor is an {x, y} object, convert to pixel offset
283286 if ( typeof anchor === 'object' && anchor !== null && 'x' in anchor && 'y' in anchor ) {
0 commit comments