1+ import { Marker as MapLibreMarker } from "maplibre-gl" ;
12import { useContext , useEffect , useRef } from "preact/hooks" ;
2- import { ParentMap , GeoMouseEvent } from "./map" ;
3- import maplibregl from "maplibre-gl " ;
3+
4+ import { GeoMouseEvent , ParentMap } from "./map " ;
45
56export interface MarkerProps {
67 coordinates : [ number , number ] ;
@@ -16,7 +17,7 @@ export interface MarkerProps {
1617
1718export default function Marker ( { coordinates, iconHtml, iconSize, iconAnchor, draggable, onClick, onDragged, onMouseDown, onContextMenu } : MarkerProps ) {
1819 const parentMap = useContext ( ParentMap ) ;
19- const markerRef = useRef < maplibregl . Marker > ( null ) ;
20+ const markerRef = useRef < MapLibreMarker > ( null ) ;
2021
2122 useEffect ( ( ) => {
2223 if ( ! parentMap ) return ;
@@ -31,13 +32,13 @@ export default function Marker({ coordinates, iconHtml, iconSize, iconAnchor, dr
3132 el . style . height = `${ iconSize [ 1 ] } px` ;
3233 }
3334
34- const newMarker = new maplibregl . Marker ( {
35+ const newMarker = new MapLibreMarker ( {
3536 element : el ,
3637 draggable : ! ! draggable ,
3738 anchor : "bottom"
3839 } )
39- . setLngLat ( [ coordinates [ 1 ] , coordinates [ 0 ] ] )
40- . addTo ( parentMap ) ;
40+ . setLngLat ( [ coordinates [ 1 ] , coordinates [ 0 ] ] )
41+ . addTo ( parentMap ) ;
4142
4243 markerRef . current = newMarker ;
4344
@@ -99,7 +100,7 @@ export function GpxTrack({ gpxXmlString, trackColor, startIconHtml, endIconHtml,
99100 useEffect ( ( ) => {
100101 if ( ! parentMap ) return ;
101102
102- const markers : maplibregl . Marker [ ] = [ ] ;
103+ const markers : MapLibreMarker [ ] = [ ] ;
103104 const sourceId = `gpx-source-${ Math . random ( ) . toString ( 36 ) . slice ( 2 ) } ` ;
104105 const layerId = `gpx-layer-${ sourceId } ` ;
105106
@@ -145,7 +146,7 @@ export function GpxTrack({ gpxXmlString, trackColor, startIconHtml, endIconHtml,
145146 const startEl = document . createElement ( "div" ) ;
146147 startEl . className = "geo-marker" ;
147148 startEl . innerHTML = startIconHtml ;
148- const startMarker = new maplibregl . Marker ( { element : startEl , anchor : "bottom" } )
149+ const startMarker = new MapLibreMarker ( { element : startEl , anchor : "bottom" } )
149150 . setLngLat ( coordinates [ 0 ] )
150151 . addTo ( parentMap ) ;
151152 markers . push ( startMarker ) ;
@@ -156,7 +157,7 @@ export function GpxTrack({ gpxXmlString, trackColor, startIconHtml, endIconHtml,
156157 const endEl = document . createElement ( "div" ) ;
157158 endEl . className = "geo-marker" ;
158159 endEl . innerHTML = endIconHtml ;
159- const endMarker = new maplibregl . Marker ( { element : endEl , anchor : "bottom" } )
160+ const endMarker = new MapLibreMarker ( { element : endEl , anchor : "bottom" } )
160161 . setLngLat ( coordinates [ coordinates . length - 1 ] )
161162 . addTo ( parentMap ) ;
162163 markers . push ( endMarker ) ;
@@ -172,7 +173,7 @@ export function GpxTrack({ gpxXmlString, trackColor, startIconHtml, endIconHtml,
172173 const wptEl = document . createElement ( "div" ) ;
173174 wptEl . className = "geo-marker" ;
174175 wptEl . innerHTML = waypointIconHtml ;
175- const wptMarker = new maplibregl . Marker ( { element : wptEl , anchor : "bottom" } )
176+ const wptMarker = new MapLibreMarker ( { element : wptEl , anchor : "bottom" } )
176177 . setLngLat ( [ lon , lat ] )
177178 . addTo ( parentMap ) ;
178179 markers . push ( wptMarker ) ;
0 commit comments