Beautiful map components. 100% Free, Zero config, one command setup.
TypeScript
Update: popup maxwidth for custom styling
Anmoldeep Singhd24d3fb7acc3
diff --git a/public/maps/map.json b/public/maps/map.jsonindex beefaea..8a84cdc 100644--- a/public/maps/map.json+++ b/public/maps/map.json@@ -12,7 +12,7 @@"files": [{"path": "src/registry/map.tsx",- "content": "\"use client\";\n\nimport MapLibreGL, { type PopupOptions, type MarkerOptions } from \"maplibre-gl\";\nimport \"maplibre-gl/dist/maplibre-gl.css\";\nimport { useTheme } from \"next-themes\";\nimport {\n createContext,\n useContext,\n useEffect,\n useId,\n useRef,\n useState,\n type ReactNode,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { X, Minus, Plus, Locate, Maximize, Loader2 } from \"lucide-react\";\n\nimport { cn } from \"@/lib/utils\";\n\ntype MapContextValue = {\n map: MapLibreGL.Map | null;\n isLoaded: boolean;\n};\n\nconst MapContext = createContext<MapContextValue | null>(null);\n\nfunction useMap() {\n const context = useContext(MapContext);\n if (!context) {\n throw new Error(\"useMap must be used within a Map component\");\n }\n return context;\n}\n\nconst mapStyles = {\n dark: \"https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json\",\n light: \"https://basemaps.cartocdn.com/gl/positron-gl-style/style.json\",\n};\n\ntype MapProps = {\n children?: ReactNode;\n} & Omit<MapLibreGL.MapOptions, \"container\">;\n\nconst DefaultLoader = () => (\n <div className=\"absolute inset-0 flex items-center justify-center\">\n <div className=\"flex gap-1\">\n <span className=\"size-1.5 rounded-full bg-muted-foreground/60 animate-pulse\" />\n <span className=\"size-1.5 rounded-full bg-muted-foreground/60 animate-pulse [animation-delay:150ms]\" />\n <span className=\"size-1.5 rounded-full bg-muted-foreground/60 animate-pulse [animation-delay:300ms]\" />\n </div>\n </div>\n);\n\nfunction Map({ children, ...props }: MapProps) {\n const containerRef = useRef<HTMLDivElement>(null);\n const mapRef = useRef<MapLibreGL.Map | null>(null);\n const [isLoaded, setIsLoaded] = useState(false);\n const [isStyleLoaded, setIsStyleLoaded] = useState(false);\n const { resolvedTheme } = useTheme();\n\n useEffect(() => {\n if (!containerRef.current) return;\n\n const mapStyle =\n resolvedTheme === \"dark\" ? mapStyles.dark : mapStyles.light;\n\n const mapInstance = new MapLibreGL.Map({\n container: containerRef.current,\n style: mapStyle,\n attributionControl: false,\n ...props,\n });\n\n const styleDataHandler = () => setIsStyleLoaded(true);\n const loadHandler = () => setIsLoaded(true);\n\n mapInstance.on(\"load\", loadHandler);\n mapInstance.on(\"styledata\", styleDataHandler);\n mapRef.current = mapInstance;\n\n return () => {\n mapInstance.off(\"load\", loadHandler);\n mapInstance.off(\"styledata\", styleDataHandler);\n mapInstance.remove();\n mapRef.current = null;\n };\n }, []);\n\n useEffect(() => {\n if (mapRef.current) {\n setIsStyleLoaded(false);\n mapRef.current.setStyle(\n resolvedTheme === \"dark\" ? mapStyles.dark : mapStyles.light,\n { diff: true }\n );\n }\n }, [resolvedTheme]);\n\n const isLoading = !isLoaded || !isStyleLoaded;\n\n return (\n <MapContext.Provider\n value={{ map: mapRef.current, isLoaded: isLoaded && isStyleLoaded }}\n >\n <div ref={containerRef} className=\"relative w-full h-full\">\n {isLoading && <DefaultLoader />}\n {children}\n </div>\n </MapContext.Provider>\n );\n}\n\ntype MarkerContextValue = {\n markerRef: React.RefObject<MapLibreGL.Marker | null>;\n markerElementRef: React.RefObject<HTMLDivElement | null>;\n map: MapLibreGL.Map | null;\n isReady: boolean;\n};\n\nconst MarkerContext = createContext<MarkerContextValue | null>(null);\n\nfunction useMarkerContext() {\n const context = useContext(MarkerContext);\n if (!context) {\n throw new Error(\"Marker components must be used within MapMarker\");\n }\n return context;\n}\n\ntype MapMarkerProps = {\n longitude: number;\n latitude: number;\n children: ReactNode;\n onClick?: (e: MouseEvent) => void;\n onMouseEnter?: (e: MouseEvent) => void;\n onMouseLeave?: (e: MouseEvent) => void;\n onDragStart?: (lngLat: { lng: number; lat: number }) => void;\n onDrag?: (lngLat: { lng: number; lat: number }) => void;\n onDragEnd?: (lngLat: { lng: number; lat: number }) => void;\n} & Omit<MarkerOptions, \"element\">;\n\nfunction MapMarker({\n longitude,\n latitude,\n children,\n onClick,\n onMouseEnter,\n onMouseLeave,\n onDragStart,\n onDrag,\n onDragEnd,\n draggable = false,\n ...markerOptions\n}: MapMarkerProps) {\n const { map, isLoaded } = useMap();\n const markerRef = useRef<MapLibreGL.Marker | null>(null);\n const markerElementRef = useRef<HTMLDivElement | null>(null);\n const [isReady, setIsReady] = useState(false);\n\n useEffect(() => {\n if (!isLoaded || !map) return;\n\n const container = document.createElement(\"div\");\n markerElementRef.current = container;\n\n const marker = new MapLibreGL.Marker({\n ...markerOptions,\n element: container,\n draggable,\n })\n .setLngLat([longitude, latitude])\n .addTo(map);\n\n markerRef.current = marker;\n\n if (onClick) container.addEventListener(\"click\", onClick);\n if (onMouseEnter) container.addEventListener(\"mouseenter\", onMouseEnter);\n if (onMouseLeave) container.addEventListener(\"mouseleave\", onMouseLeave);\n\n const handleDragStart = () => {\n const lngLat = marker.getLngLat();\n onDragStart?.({ lng: lngLat.lng, lat: lngLat.lat });\n };\n const handleDrag = () => {\n const lngLat = marker.getLngLat();\n onDrag?.({ lng: lngLat.lng, lat: lngLat.lat });\n };\n const handleDragEnd = () => {\n const lngLat = marker.getLngLat();\n onDragEnd?.({ lng: lngLat.lng, lat: lngLat.lat });\n };\n\n if (draggable) {\n marker.on(\"dragstart\", handleDragStart);\n marker.on(\"drag\", handleDrag);\n marker.on(\"dragend\", handleDragEnd);\n }\n\n setIsReady(true);\n\n return () => {\n if (onClick) container.removeEventListener(\"click\", onClick);\n if (onMouseEnter)\n container.removeEventListener(\"mouseenter\", onMouseEnter);\n if (onMouseLeave)\n container.removeEventListener(\"mouseleave\", onMouseLeave);\n if (draggable) {\n marker.off(\"dragstart\", handleDragStart);\n marker.off(\"drag\", handleDrag);\n marker.off(\"dragend\", handleDragEnd);\n }\n marker.remove();\n markerRef.current = null;\n markerElementRef.current = null;\n setIsReady(false);\n };\n }, [isLoaded]);\n\n useEffect(() => {\n markerRef.current?.setLngLat([longitude, latitude]);\n }, [longitude, latitude]);\n\n useEffect(() => {\n markerRef.current?.setDraggable(draggable);\n }, [draggable]);\n\n return (\n <MarkerContext.Provider\n value={{ markerRef, markerElementRef, map, isReady }}\n >\n {children}\n </MarkerContext.Provider>\n );\n}\n\ntype MarkerContentProps = {\n children?: ReactNode;\n className?: string;\n};\n\nfunction MarkerContent({ children, className }: MarkerContentProps) {\n const { markerElementRef, isReady } = useMarkerContext();\n\n if (!isReady || !markerElementRef.current) return null;\n\n return createPortal(\n <div className={cn(\"relative cursor-pointer\", className)}>\n {children || <DefaultMarkerIcon />}\n </div>,\n markerElementRef.current\n );\n}\n\nfunction DefaultMarkerIcon() {\n return (\n <div className=\"relative h-4 w-4 rounded-full border-2 border-white bg-blue-500 shadow-lg\" />\n );\n}\n\ntype MarkerPopupProps = {\n children: ReactNode;\n className?: string;\n closeButton?: boolean;\n} & Omit<PopupOptions, \"className\">;\n\nfunction MarkerPopup({\n children,\n className,\n closeButton = false,\n ...popupOptions\n}: MarkerPopupProps) {\n const { markerRef, isReady } = useMarkerContext();\n const containerRef = useRef<HTMLDivElement | null>(null);\n const popupRef = useRef<MapLibreGL.Popup | null>(null);\n const [mounted, setMounted] = useState(false);\n\n useEffect(() => {\n if (!isReady || !markerRef.current) return;\n\n const container = document.createElement(\"div\");\n containerRef.current = container;\n\n const popup = new MapLibreGL.Popup({\n offset: 16,\n ...popupOptions,\n closeButton: false,\n }).setDOMContent(container);\n\n popupRef.current = popup;\n markerRef.current.setPopup(popup);\n setMounted(true);\n\n return () => {\n popup.remove();\n popupRef.current = null;\n containerRef.current = null;\n setMounted(false);\n };\n }, [isReady]);\n\n const handleClose = () => popupRef.current?.remove();\n\n if (!mounted || !containerRef.current) return null;\n\n return createPortal(\n <div\n className={cn(\n \"relative rounded-md border bg-popover p-3 text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95\",\n className\n )}\n >\n {closeButton && (\n <button\n type=\"button\"\n onClick={handleClose}\n className=\"absolute top-1 right-1 z-10 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2\"\n aria-label=\"Close popup\"\n >\n <X className=\"h-4 w-4\" />\n <span className=\"sr-only\">Close</span>\n </button>\n )}\n {children}\n </div>,\n containerRef.current\n );\n}\n\ntype MarkerTooltipProps = {\n children: ReactNode;\n className?: string;\n} & Omit<PopupOptions, \"className\" | \"closeButton\" | \"closeOnClick\">;\n\nfunction MarkerTooltip({\n children,\n className,\n ...popupOptions\n}: MarkerTooltipProps) {\n const { markerRef, markerElementRef, map, isReady } = useMarkerContext();\n const containerRef = useRef<HTMLDivElement | null>(null);\n const popupRef = useRef<MapLibreGL.Popup | null>(null);\n const [mounted, setMounted] = useState(false);\n\n useEffect(() => {\n if (!isReady || !markerRef.current || !markerElementRef.current || !map)\n return;\n\n const container = document.createElement(\"div\");\n containerRef.current = container;\n\n const popup = new MapLibreGL.Popup({\n offset: 16,\n ...popupOptions,\n closeOnClick: true,\n closeButton: false,\n }).setDOMContent(container);\n\n popupRef.current = popup;\n\n const markerElement = markerElementRef.current;\n const marker = markerRef.current;\n\n const handleMouseEnter = () => {\n popup.setLngLat(marker.getLngLat()).addTo(map);\n };\n const handleMouseLeave = () => popup.remove();\n\n markerElement.addEventListener(\"mouseenter\", handleMouseEnter);\n markerElement.addEventListener(\"mouseleave\", handleMouseLeave);\n setMounted(true);\n\n return () => {\n markerElement.removeEventListener(\"mouseenter\", handleMouseEnter);\n markerElement.removeEventListener(\"mouseleave\", handleMouseLeave);\n popup.remove();\n popupRef.current = null;\n containerRef.current = null;\n setMounted(false);\n };\n }, [isReady, map]);\n\n if (!mounted || !containerRef.current) return null;\n\n return createPortal(\n <div\n className={cn(\n \"rounded-md bg-foreground px-2 py-1 text-xs text-background shadow-md animate-in fade-in-0 zoom-in-95\",\n className\n )}\n >\n {children}\n </div>,\n containerRef.current\n );\n}\n\ntype MarkerLabelProps = {\n children: ReactNode;\n className?: string;\n position?: \"top\" | \"bottom\";\n};\n\nfunction MarkerLabel({\n children,\n className,\n position = \"top\",\n}: MarkerLabelProps) {\n const positionClasses = {\n top: \"bottom-full mb-1\",\n bottom: \"top-full mt-1\",\n };\n\n return (\n <div\n className={cn(\n \"absolute left-1/2 -translate-x-1/2 whitespace-nowrap\",\n \"text-[10px] font-medium text-foreground\",\n positionClasses[position],\n className\n )}\n >\n {children}\n </div>\n );\n}\n\ntype MapControlsProps = {\n position?: \"top-left\" | \"top-right\" | \"bottom-left\" | \"bottom-right\";\n showZoom?: boolean;\n showCompass?: boolean;\n showLocate?: boolean;\n showFullscreen?: boolean;\n className?: string;\n onLocate?: (coords: { longitude: number; latitude: number }) => void;\n};\n\nconst positionClasses = {\n \"top-left\": \"top-2 left-2\",\n \"top-right\": \"top-2 right-2\",\n \"bottom-left\": \"bottom-2 left-2\",\n \"bottom-right\": \"bottom-2 right-2\",\n};\n\nfunction ControlGroup({ children }: { children: React.ReactNode }) {\n return (\n <div className=\"flex flex-col rounded-md border border-border bg-background shadow-sm overflow-hidden [&>button:not(:last-child)]:border-b [&>button:not(:last-child)]:border-border\">\n {children}\n </div>\n );\n}\n\nfunction ControlButton({\n onClick,\n label,\n children,\n disabled = false,\n}: {\n onClick: () => void;\n label: string;\n children: React.ReactNode;\n disabled?: boolean;\n}) {\n return (\n <button\n onClick={onClick}\n aria-label={label}\n type=\"button\"\n className={cn(\n \"flex items-center justify-center size-8 hover:bg-accent dark:hover:bg-accent/40 transition-colors\",\n disabled && \"opacity-50 pointer-events-none cursor-not-allowed\"\n )}\n disabled={disabled}\n >\n {children}\n </button>\n );\n}\n\nfunction MapControls({\n position = \"bottom-right\",\n showZoom = true,\n showCompass = false,\n showLocate = false,\n showFullscreen = false,\n className,\n onLocate,\n}: MapControlsProps) {\n const { map, isLoaded } = useMap();\n const [waitingForLocation, setWaitingForLocation] = useState(false);\n\n if (!isLoaded) return null;\n\n const handleZoomIn = () => map?.zoomTo(map.getZoom() + 1, { duration: 300 });\n const handleZoomOut = () => map?.zoomTo(map.getZoom() - 1, { duration: 300 });\n const handleResetBearing = () => map?.resetNorthPitch({ duration: 300 });\n\n const handleLocate = () => {\n setWaitingForLocation(true);\n if (\"geolocation\" in navigator) {\n navigator.geolocation.getCurrentPosition(\n (position) => {\n const coords = {\n longitude: position.coords.longitude,\n latitude: position.coords.latitude,\n };\n map?.flyTo({\n center: [coords.longitude, coords.latitude],\n zoom: 14,\n duration: 1500,\n });\n onLocate?.({\n longitude: coords.longitude,\n latitude: coords.latitude,\n });\n setWaitingForLocation(false);\n },\n (error) => {\n console.error(\"Error getting location:\", error);\n setWaitingForLocation(false);\n }\n );\n }\n };\n\n const handleFullscreen = () => {\n const container = map?.getContainer();\n if (!container) return;\n if (document.fullscreenElement) {\n document.exitFullscreen();\n } else {\n container.requestFullscreen();\n }\n };\n\n return (\n <div\n className={cn(\n \"absolute z-10 flex flex-col gap-1.5\",\n positionClasses[position],\n className\n )}\n >\n {showZoom && (\n <ControlGroup>\n <ControlButton onClick={handleZoomIn} label=\"Zoom in\">\n <Plus className=\"size-4\" />\n </ControlButton>\n <ControlButton onClick={handleZoomOut} label=\"Zoom out\">\n <Minus className=\"size-4\" />\n </ControlButton>\n </ControlGroup>\n )}\n {showCompass && (\n <ControlGroup>\n <CompassButton onClick={handleResetBearing} />\n </ControlGroup>\n )}\n {showLocate && (\n <ControlGroup>\n <ControlButton\n onClick={handleLocate}\n label=\"Find my location\"\n disabled={waitingForLocation}\n >\n {waitingForLocation ? (\n <Loader2 className=\"size-4 animate-spin\" />\n ) : (\n <Locate className=\"size-4\" />\n )}\n </ControlButton>\n </ControlGroup>\n )}\n {showFullscreen && (\n <ControlGroup>\n <ControlButton onClick={handleFullscreen} label=\"Toggle fullscreen\">\n <Maximize className=\"size-4\" />\n </ControlButton>\n </ControlGroup>\n )}\n </div>\n );\n}\n\nfunction CompassButton({ onClick }: { onClick?: () => void }) {\n const { isLoaded, map } = useMap();\n const compassRef = useRef<SVGSVGElement>(null);\n\n useEffect(() => {\n if (!isLoaded || !map || !compassRef.current) return;\n\n const compass = compassRef.current;\n\n const updateRotation = () => {\n const bearing = map.getBearing();\n const pitch = map.getPitch();\n compass.style.transform = `rotateX(${pitch}deg) rotateZ(${-bearing}deg)`;\n };\n\n map.on(\"rotate\", updateRotation);\n map.on(\"pitch\", updateRotation);\n updateRotation();\n\n return () => {\n map.off(\"rotate\", updateRotation);\n map.off(\"pitch\", updateRotation);\n };\n }, [isLoaded, map]);\n\n return (\n <button\n onClick={onClick}\n aria-label=\"Reset bearing to north\"\n type=\"button\"\n className=\"flex items-center justify-center size-8 hover:bg-accent transition-colors\"\n >\n <svg\n ref={compassRef}\n viewBox=\"0 0 24 24\"\n className=\"size-5 transition-transform duration-200\"\n style={{ transformStyle: \"preserve-3d\" }}\n >\n <path d=\"M12 2L16 12H12V2Z\" className=\"fill-red-500\" />\n <path d=\"M12 2L8 12H12V2Z\" className=\"fill-red-300\" />\n <path d=\"M12 22L16 12H12V22Z\" className=\"fill-muted-foreground/60\" />\n <path d=\"M12 22L8 12H12V22Z\" className=\"fill-muted-foreground/30\" />\n </svg>\n </button>\n );\n}\n\ntype MapPopupProps = {\n longitude: number;\n latitude: number;\n open?: boolean;\n onClose?: () => void;\n children: ReactNode;\n className?: string;\n closeButton?: boolean;\n} & Omit<PopupOptions, \"className\">;\n\nfunction MapPopup({\n longitude,\n latitude,\n open = true,\n onClose,\n children,\n className,\n closeButton = true,\n ...popupOptions\n}: MapPopupProps) {\n const { map, isLoaded } = useMap();\n const containerRef = useRef<HTMLDivElement | null>(null);\n const popupRef = useRef<MapLibreGL.Popup | null>(null);\n const [mounted, setMounted] = useState(false);\n\n useEffect(() => {\n if (!isLoaded || !map) return;\n\n const container = document.createElement(\"div\");\n containerRef.current = container;\n\n const popup = new MapLibreGL.Popup({\n offset: 12,\n ...popupOptions,\n closeButton: false,\n })\n .setDOMContent(container)\n .setLngLat([longitude, latitude]);\n\n popup.on(\"close\", () => onClose?.());\n\n popupRef.current = popup;\n setMounted(true);\n\n return () => {\n popup.remove();\n popupRef.current = null;\n containerRef.current = null;\n setMounted(false);\n };\n }, [isLoaded, map]);\n\n useEffect(() => {\n if (!popupRef.current || !map) return;\n\n if (open) {\n popupRef.current.addTo(map);\n } else {\n popupRef.current.remove();\n }\n }, [open, map, mounted]);\n\n useEffect(() => {\n popupRef.current?.setLngLat([longitude, latitude]);\n }, [longitude, latitude]);\n\n const handleClose = () => {\n popupRef.current?.remove();\n onClose?.();\n };\n\n if (!mounted || !containerRef.current) return null;\n\n return createPortal(\n <div\n className={cn(\n \"relative rounded-md border bg-popover p-3 text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95\",\n className\n )}\n >\n {closeButton && (\n <button\n type=\"button\"\n onClick={handleClose}\n className=\"absolute top-1 right-1 z-10 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2\"\n aria-label=\"Close popup\"\n >\n <X className=\"h-4 w-4\" />\n <span className=\"sr-only\">Close</span>\n </button>\n )}\n {children}\n </div>,\n containerRef.current\n );\n}\n\ntype MapRouteProps = {\n coordinates: [number, number][];\n color?: string;\n width?: number;\n opacity?: number;\n dashArray?: [number, number];\n};\n\nfunction MapRoute({\n coordinates,\n color = \"#4285F4\",\n width = 3,\n opacity = 0.8,\n dashArray,\n}: MapRouteProps) {\n const { map, isLoaded } = useMap();\n const id = useId();\n const sourceId = `route-source-${id}`;\n const layerId = `route-layer-${id}`;\n\n useEffect(() => {\n if (!isLoaded || !map || coordinates.length < 2) return;\n\n const addRoute = () => {\n if (map.getLayer(layerId)) map.removeLayer(layerId);\n if (map.getSource(sourceId)) map.removeSource(sourceId);\n\n map.addSource(sourceId, {\n type: \"geojson\",\n data: {\n type: \"Feature\",\n properties: {},\n geometry: { type: \"LineString\", coordinates },\n },\n });\n\n map.addLayer({\n id: layerId,\n type: \"line\",\n source: sourceId,\n layout: { \"line-join\": \"round\", \"line-cap\": \"round\" },\n paint: {\n \"line-color\": color,\n \"line-width\": width,\n \"line-opacity\": opacity,\n ...(dashArray && { \"line-dasharray\": dashArray }),\n },\n });\n };\n\n addRoute();\n\n return () => {\n try {\n if (map.getLayer(layerId)) map.removeLayer(layerId);\n if (map.getSource(sourceId)) map.removeSource(sourceId);\n } catch {\n // ignore\n }\n };\n }, [\n isLoaded,\n map,\n coordinates,\n color,\n width,\n opacity,\n dashArray,\n sourceId,\n layerId,\n ]);\n\n return null;\n}\n\nexport {\n Map,\n useMap,\n MapMarker,\n MarkerContent,\n MarkerPopup,\n MarkerTooltip,\n MarkerLabel,\n MapPopup,\n MapControls,\n MapRoute,\n};\n",+ "content": "\"use client\";\n\nimport MapLibreGL, { type PopupOptions, type MarkerOptions } from \"maplibre-gl\";\nimport \"maplibre-gl/dist/maplibre-gl.css\";\nimport { useTheme } from \"next-themes\";\nimport {\n createContext,\n useContext,\n useEffect,\n useId,\n useRef,\n useState,\n type ReactNode,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { X, Minus, Plus, Locate, Maximize, Loader2 } from \"lucide-react\";\n\nimport { cn } from \"@/lib/utils\";\n\ntype MapContextValue = {\n map: MapLibreGL.Map | null;\n isLoaded: boolean;\n};\n\nconst MapContext = createContext<MapContextValue | null>(null);\n\nfunction useMap() {\n const context = useContext(MapContext);\n if (!context) {\n throw new Error(\"useMap must be used within a Map component\");\n }\n return context;\n}\n\nconst mapStyles = {\n dark: \"https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json\",\n light: \"https://basemaps.cartocdn.com/gl/positron-gl-style/style.json\",\n};\n\ntype MapProps = {\n children?: ReactNode;\n} & Omit<MapLibreGL.MapOptions, \"container\">;\n\nconst DefaultLoader = () => (\n <div className=\"absolute inset-0 flex items-center justify-center\">\n <div className=\"flex gap-1\">\n <span className=\"size-1.5 rounded-full bg-muted-foreground/60 animate-pulse\" />\n <span className=\"size-1.5 rounded-full bg-muted-foreground/60 animate-pulse [animation-delay:150ms]\" />\n <span className=\"size-1.5 rounded-full bg-muted-foreground/60 animate-pulse [animation-delay:300ms]\" />\n </div>\n </div>\n);\n\nfunction Map({ children, ...props }: MapProps) {\n const containerRef = useRef<HTMLDivElement>(null);\n const mapRef = useRef<MapLibreGL.Map | null>(null);\n const [isLoaded, setIsLoaded] = useState(false);\n const [isStyleLoaded, setIsStyleLoaded] = useState(false);\n const { resolvedTheme } = useTheme();\n\n useEffect(() => {\n if (!containerRef.current) return;\n\n const mapStyle =\n resolvedTheme === \"dark\" ? mapStyles.dark : mapStyles.light;\n\n const mapInstance = new MapLibreGL.Map({\n container: containerRef.current,\n style: mapStyle,\n attributionControl: false,\n ...props,\n });\n\n const styleDataHandler = () => setIsStyleLoaded(true);\n const loadHandler = () => setIsLoaded(true);\n\n mapInstance.on(\"load\", loadHandler);\n mapInstance.on(\"styledata\", styleDataHandler);\n mapRef.current = mapInstance;\n\n return () => {\n mapInstance.off(\"load\", loadHandler);\n mapInstance.off(\"styledata\", styleDataHandler);\n mapInstance.remove();\n mapRef.current = null;\n };\n }, []);\n\n useEffect(() => {\n if (mapRef.current) {\n setIsStyleLoaded(false);\n mapRef.current.setStyle(\n resolvedTheme === \"dark\" ? mapStyles.dark : mapStyles.light,\n { diff: true }\n );\n }\n }, [resolvedTheme]);\n\n const isLoading = !isLoaded || !isStyleLoaded;\n\n return (\n <MapContext.Provider\n value={{ map: mapRef.current, isLoaded: isLoaded && isStyleLoaded }}\n >\n <div ref={containerRef} className=\"relative w-full h-full\">\n {isLoading && <DefaultLoader />}\n {children}\n </div>\n </MapContext.Provider>\n );\n}\n\ntype MarkerContextValue = {\n markerRef: React.RefObject<MapLibreGL.Marker | null>;\n markerElementRef: React.RefObject<HTMLDivElement | null>;\n map: MapLibreGL.Map | null;\n isReady: boolean;\n};\n\nconst MarkerContext = createContext<MarkerContextValue | null>(null);\n\nfunction useMarkerContext() {\n const context = useContext(MarkerContext);\n if (!context) {\n throw new Error(\"Marker components must be used within MapMarker\");\n }\n return context;\n}\n\ntype MapMarkerProps = {\n longitude: number;\n latitude: number;\n children: ReactNode;\n onClick?: (e: MouseEvent) => void;\n onMouseEnter?: (e: MouseEvent) => void;\n onMouseLeave?: (e: MouseEvent) => void;\n onDragStart?: (lngLat: { lng: number; lat: number }) => void;\n onDrag?: (lngLat: { lng: number; lat: number }) => void;\n onDragEnd?: (lngLat: { lng: number; lat: number }) => void;\n} & Omit<MarkerOptions, \"element\">;\n\nfunction MapMarker({\n longitude,\n latitude,\n children,\n onClick,\n onMouseEnter,\n onMouseLeave,\n onDragStart,\n onDrag,\n onDragEnd,\n draggable = false,\n ...markerOptions\n}: MapMarkerProps) {\n const { map, isLoaded } = useMap();\n const markerRef = useRef<MapLibreGL.Marker | null>(null);\n const markerElementRef = useRef<HTMLDivElement | null>(null);\n const [isReady, setIsReady] = useState(false);\n\n useEffect(() => {\n if (!isLoaded || !map) return;\n\n const container = document.createElement(\"div\");\n markerElementRef.current = container;\n\n const marker = new MapLibreGL.Marker({\n ...markerOptions,\n element: container,\n draggable,\n })\n .setLngLat([longitude, latitude])\n .addTo(map);\n\n markerRef.current = marker;\n\n if (onClick) container.addEventListener(\"click\", onClick);\n if (onMouseEnter) container.addEventListener(\"mouseenter\", onMouseEnter);\n if (onMouseLeave) container.addEventListener(\"mouseleave\", onMouseLeave);\n\n const handleDragStart = () => {\n const lngLat = marker.getLngLat();\n onDragStart?.({ lng: lngLat.lng, lat: lngLat.lat });\n };\n const handleDrag = () => {\n const lngLat = marker.getLngLat();\n onDrag?.({ lng: lngLat.lng, lat: lngLat.lat });\n };\n const handleDragEnd = () => {\n const lngLat = marker.getLngLat();\n onDragEnd?.({ lng: lngLat.lng, lat: lngLat.lat });\n };\n\n if (draggable) {\n marker.on(\"dragstart\", handleDragStart);\n marker.on(\"drag\", handleDrag);\n marker.on(\"dragend\", handleDragEnd);\n }\n\n setIsReady(true);\n\n return () => {\n if (onClick) container.removeEventListener(\"click\", onClick);\n if (onMouseEnter)\n container.removeEventListener(\"mouseenter\", onMouseEnter);\n if (onMouseLeave)\n container.removeEventListener(\"mouseleave\", onMouseLeave);\n if (draggable) {\n marker.off(\"dragstart\", handleDragStart);\n marker.off(\"drag\", handleDrag);\n marker.off(\"dragend\", handleDragEnd);\n }\n marker.remove();\n markerRef.current = null;\n markerElementRef.current = null;\n setIsReady(false);\n };\n }, [isLoaded]);\n\n useEffect(() => {\n markerRef.current?.setLngLat([longitude, latitude]);\n }, [longitude, latitude]);\n\n useEffect(() => {\n markerRef.current?.setDraggable(draggable);\n }, [draggable]);\n\n return (\n <MarkerContext.Provider\n value={{ markerRef, markerElementRef, map, isReady }}\n >\n {children}\n </MarkerContext.Provider>\n );\n}\n\ntype MarkerContentProps = {\n children?: ReactNode;\n className?: string;\n};\n\nfunction MarkerContent({ children, className }: MarkerContentProps) {\n const { markerElementRef, isReady } = useMarkerContext();\n\n if (!isReady || !markerElementRef.current) return null;\n\n return createPortal(\n <div className={cn(\"relative cursor-pointer\", className)}>\n {children || <DefaultMarkerIcon />}\n </div>,\n markerElementRef.current\n );\n}\n\nfunction DefaultMarkerIcon() {\n return (\n <div className=\"relative h-4 w-4 rounded-full border-2 border-white bg-blue-500 shadow-lg\" />\n );\n}\n\ntype MarkerPopupProps = {\n children: ReactNode;\n className?: string;\n closeButton?: boolean;\n} & Omit<PopupOptions, \"className\">;\n\nfunction MarkerPopup({\n children,\n className,\n closeButton = false,\n ...popupOptions\n}: MarkerPopupProps) {\n const { markerRef, isReady } = useMarkerContext();\n const containerRef = useRef<HTMLDivElement | null>(null);\n const popupRef = useRef<MapLibreGL.Popup | null>(null);\n const [mounted, setMounted] = useState(false);\n\n useEffect(() => {\n if (!isReady || !markerRef.current) return;\n\n const container = document.createElement(\"div\");\n containerRef.current = container;\n\n const popup = new MapLibreGL.Popup({\n offset: 16,\n ...popupOptions,\n closeButton: false,\n })\n .setMaxWidth(\"none\")\n .setDOMContent(container);\n\n popupRef.current = popup;\n markerRef.current.setPopup(popup);\n setMounted(true);\n\n return () => {\n popup.remove();\n popupRef.current = null;\n containerRef.current = null;\n setMounted(false);\n };\n }, [isReady]);\n\n const handleClose = () => popupRef.current?.remove();\n\n if (!mounted || !containerRef.current) return null;\n\n return createPortal(\n <div\n className={cn(\n \"relative rounded-md border bg-popover p-3 text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95\",\n className\n )}\n >\n {closeButton && (\n <button\n type=\"button\"\n onClick={handleClose}\n className=\"absolute top-1 right-1 z-10 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2\"\n aria-label=\"Close popup\"\n >\n <X className=\"h-4 w-4\" />\n <span className=\"sr-only\">Close</span>\n </button>\n )}\n {children}\n </div>,\n containerRef.current\n );\n}\n\ntype MarkerTooltipProps = {\n children: ReactNode;\n className?: string;\n} & Omit<PopupOptions, \"className\" | \"closeButton\" | \"closeOnClick\">;\n\nfunction MarkerTooltip({\n children,\n className,\n ...popupOptions\n}: MarkerTooltipProps) {\n const { markerRef, markerElementRef, map, isReady } = useMarkerContext();\n const containerRef = useRef<HTMLDivElement | null>(null);\n const popupRef = useRef<MapLibreGL.Popup | null>(null);\n const [mounted, setMounted] = useState(false);\n\n useEffect(() => {\n if (!isReady || !markerRef.current || !markerElementRef.current || !map)\n return;\n\n const container = document.createElement(\"div\");\n containerRef.current = container;\n\n const popup = new MapLibreGL.Popup({\n offset: 16,\n ...popupOptions,\n closeOnClick: true,\n closeButton: false,\n })\n .setMaxWidth(\"none\")\n .setDOMContent(container);\n\n popupRef.current = popup;\n\n const markerElement = markerElementRef.current;\n const marker = markerRef.current;\n\n const handleMouseEnter = () => {\n popup.setLngLat(marker.getLngLat()).addTo(map);\n };\n const handleMouseLeave = () => popup.remove();\n\n markerElement.addEventListener(\"mouseenter\", handleMouseEnter);\n markerElement.addEventListener(\"mouseleave\", handleMouseLeave);\n setMounted(true);\n\n return () => {\n markerElement.removeEventListener(\"mouseenter\", handleMouseEnter);\n markerElement.removeEventListener(\"mouseleave\", handleMouseLeave);\n popup.remove();\n popupRef.current = null;\n containerRef.current = null;\n setMounted(false);\n };\n }, [isReady, map]);\n\n if (!mounted || !containerRef.current) return null;\n\n return createPortal(\n <div\n className={cn(\n \"rounded-md bg-foreground px-2 py-1 text-xs text-background shadow-md animate-in fade-in-0 zoom-in-95\",\n className\n )}\n >\n {children}\n </div>,\n containerRef.current\n );\n}\n\ntype MarkerLabelProps = {\n children: ReactNode;\n className?: string;\n position?: \"top\" | \"bottom\";\n};\n\nfunction MarkerLabel({\n children,\n className,\n position = \"top\",\n}: MarkerLabelProps) {\n const positionClasses = {\n top: \"bottom-full mb-1\",\n bottom: \"top-full mt-1\",\n };\n\n return (\n <div\n className={cn(\n \"absolute left-1/2 -translate-x-1/2 whitespace-nowrap\",\n \"text-[10px] font-medium text-foreground\",\n positionClasses[position],\n className\n )}\n >\n {children}\n </div>\n );\n}\n\ntype MapControlsProps = {\n position?: \"top-left\" | \"top-right\" | \"bottom-left\" | \"bottom-right\";\n showZoom?: boolean;\n showCompass?: boolean;\n showLocate?: boolean;\n showFullscreen?: boolean;\n className?: string;\n onLocate?: (coords: { longitude: number; latitude: number }) => void;\n};\n\nconst positionClasses = {\n \"top-left\": \"top-2 left-2\",\n \"top-right\": \"top-2 right-2\",\n \"bottom-left\": \"bottom-2 left-2\",\n \"bottom-right\": \"bottom-2 right-2\",\n};\n\nfunction ControlGroup({ children }: { children: React.ReactNode }) {\n return (\n <div className=\"flex flex-col rounded-md border border-border bg-background shadow-sm overflow-hidden [&>button:not(:last-child)]:border-b [&>button:not(:last-child)]:border-border\">\n {children}\n </div>\n );\n}\n\nfunction ControlButton({\n onClick,\n label,\n children,\n disabled = false,\n}: {\n onClick: () => void;\n label: string;\n children: React.ReactNode;\n disabled?: boolean;\n}) {\n return (\n <button\n onClick={onClick}\n aria-label={label}\n type=\"button\"\n className={cn(\n \"flex items-center justify-center size-8 hover:bg-accent dark:hover:bg-accent/40 transition-colors\",\n disabled && \"opacity-50 pointer-events-none cursor-not-allowed\"\n )}\n disabled={disabled}\n >\n {children}\n </button>\n );\n}\n\nfunction MapControls({\n position = \"bottom-right\",\n showZoom = true,\n showCompass = false,\n showLocate = false,\n showFullscreen = false,\n className,\n onLocate,\n}: MapControlsProps) {\n const { map, isLoaded } = useMap();\n const [waitingForLocation, setWaitingForLocation] = useState(false);\n\n if (!isLoaded) return null;\n\n const handleZoomIn = () => map?.zoomTo(map.getZoom() + 1, { duration: 300 });\n const handleZoomOut = () => map?.zoomTo(map.getZoom() - 1, { duration: 300 });\n const handleResetBearing = () => map?.resetNorthPitch({ duration: 300 });\n\n const handleLocate = () => {\n setWaitingForLocation(true);\n if (\"geolocation\" in navigator) {\n navigator.geolocation.getCurrentPosition(\n (position) => {\n const coords = {\n longitude: position.coords.longitude,\n latitude: position.coords.latitude,\n };\n map?.flyTo({\n center: [coords.longitude, coords.latitude],\n zoom: 14,\n duration: 1500,\n });\n onLocate?.({\n longitude: coords.longitude,\n latitude: coords.latitude,\n });\n setWaitingForLocation(false);\n },\n (error) => {\n console.error(\"Error getting location:\", error);\n setWaitingForLocation(false);\n }\n );\n }\n };\n\n const handleFullscreen = () => {\n const container = map?.getContainer();\n if (!container) return;\n if (document.fullscreenElement) {\n document.exitFullscreen();\n } else {\n container.requestFullscreen();\n }\n };\n\n return (\n <div\n className={cn(\n \"absolute z-10 flex flex-col gap-1.5\",\n positionClasses[position],\n className\n )}\n >\n {showZoom && (\n <ControlGroup>\n <ControlButton onClick={handleZoomIn} label=\"Zoom in\">\n <Plus className=\"size-4\" />\n </ControlButton>\n <ControlButton onClick={handleZoomOut} label=\"Zoom out\">\n <Minus className=\"size-4\" />\n </ControlButton>\n </ControlGroup>\n )}\n {showCompass && (\n <ControlGroup>\n <CompassButton onClick={handleResetBearing} />\n </ControlGroup>\n )}\n {showLocate && (\n <ControlGroup>\n <ControlButton\n onClick={handleLocate}\n label=\"Find my location\"\n disabled={waitingForLocation}\n >\n {waitingForLocation ? (\n <Loader2 className=\"size-4 animate-spin\" />\n ) : (\n <Locate className=\"size-4\" />\n )}\n </ControlButton>\n </ControlGroup>\n )}\n {showFullscreen && (\n <ControlGroup>\n <ControlButton onClick={handleFullscreen} label=\"Toggle fullscreen\">\n <Maximize className=\"size-4\" />\n </ControlButton>\n </ControlGroup>\n )}\n </div>\n );\n}\n\nfunction CompassButton({ onClick }: { onClick?: () => void }) {\n const { isLoaded, map } = useMap();\n const compassRef = useRef<SVGSVGElement>(null);\n\n useEffect(() => {\n if (!isLoaded || !map || !compassRef.current) return;\n\n const compass = compassRef.current;\n\n const updateRotation = () => {\n const bearing = map.getBearing();\n const pitch = map.getPitch();\n compass.style.transform = `rotateX(${pitch}deg) rotateZ(${-bearing}deg)`;\n };\n\n map.on(\"rotate\", updateRotation);\n map.on(\"pitch\", updateRotation);\n updateRotation();\n\n return () => {\n map.off(\"rotate\", updateRotation);\n map.off(\"pitch\", updateRotation);\n };\n }, [isLoaded, map]);\n\n return (\n <button\n onClick={onClick}\n aria-label=\"Reset bearing to north\"\n type=\"button\"\n className=\"flex items-center justify-center size-8 hover:bg-accent transition-colors\"\n >\n <svg\n ref={compassRef}\n viewBox=\"0 0 24 24\"\n className=\"size-5 transition-transform duration-200\"\n style={{ transformStyle: \"preserve-3d\" }}\n >\n <path d=\"M12 2L16 12H12V2Z\" className=\"fill-red-500\" />\n <path d=\"M12 2L8 12H12V2Z\" className=\"fill-red-300\" />\n <path d=\"M12 22L16 12H12V22Z\" className=\"fill-muted-foreground/60\" />\n <path d=\"M12 22L8 12H12V22Z\" className=\"fill-muted-foreground/30\" />\n </svg>\n </button>\n );\n}\n\ntype MapPopupProps = {\n longitude: number;\n latitude: number;\n open?: boolean;\n onClose?: () => void;\n children: ReactNode;\n className?: string;\n closeButton?: boolean;\n} & Omit<PopupOptions, \"className\">;\n\nfunction MapPopup({\n longitude,\n latitude,\n open = true,\n onClose,\n children,\n className,\n closeButton = true,\n ...popupOptions\n}: MapPopupProps) {\n const { map, isLoaded } = useMap();\n const containerRef = useRef<HTMLDivElement | null>(null);\n const popupRef = useRef<MapLibreGL.Popup | null>(null);\n const [mounted, setMounted] = useState(false);\n\n useEffect(() => {\n if (!isLoaded || !map) return;\n\n const container = document.createElement(\"div\");\n containerRef.current = container;\n\n const popup = new MapLibreGL.Popup({\n offset: 12,\n ...popupOptions,\n closeButton: false,\n })\n .setMaxWidth(\"none\")\n .setDOMContent(container)\n .setLngLat([longitude, latitude]);\n\n popup.on(\"close\", () => onClose?.());\n\n popupRef.current = popup;\n setMounted(true);\n\n return () => {\n popup.remove();\n popupRef.current = null;\n containerRef.current = null;\n setMounted(false);\n };\n }, [isLoaded, map]);\n\n useEffect(() => {\n if (!popupRef.current || !map) return;\n\n if (open) {\n popupRef.current.addTo(map);\n } else {\n popupRef.current.remove();\n }\n }, [open, map, mounted]);\n\n useEffect(() => {\n popupRef.current?.setLngLat([longitude, latitude]);\n }, [longitude, latitude]);\n\n const handleClose = () => {\n popupRef.current?.remove();\n onClose?.();\n };\n\n if (!mounted || !containerRef.current) return null;\n\n return createPortal(\n <div\n className={cn(\n \"relative rounded-md border bg-popover p-3 text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95\",\n className\n )}\n >\n {closeButton && (\n <button\n type=\"button\"\n onClick={handleClose}\n className=\"absolute top-1 right-1 z-10 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2\"\n aria-label=\"Close popup\"\n >\n <X className=\"h-4 w-4\" />\n <span className=\"sr-only\">Close</span>\n </button>\n )}\n {children}\n </div>,\n containerRef.current\n );\n}\n\ntype MapRouteProps = {\n coordinates: [number, number][];\n color?: string;\n width?: number;\n opacity?: number;\n dashArray?: [number, number];\n};\n\nfunction MapRoute({\n coordinates,\n color = \"#4285F4\",\n width = 3,\n opacity = 0.8,\n dashArray,\n}: MapRouteProps) {\n const { map, isLoaded } = useMap();\n const id = useId();\n const sourceId = `route-source-${id}`;\n const layerId = `route-layer-${id}`;\n\n useEffect(() => {\n if (!isLoaded || !map || coordinates.length < 2) return;\n\n const addRoute = () => {\n if (map.getLayer(layerId)) map.removeLayer(layerId);\n if (map.getSource(sourceId)) map.removeSource(sourceId);\n\n map.addSource(sourceId, {\n type: \"geojson\",\n data: {\n type: \"Feature\",\n properties: {},\n geometry: { type: \"LineString\", coordinates },\n },\n });\n\n map.addLayer({\n id: layerId,\n type: \"line\",\n source: sourceId,\n layout: { \"line-join\": \"round\", \"line-cap\": \"round\" },\n paint: {\n \"line-color\": color,\n \"line-width\": width,\n \"line-opacity\": opacity,\n ...(dashArray && { \"line-dasharray\": dashArray }),\n },\n });\n };\n\n addRoute();\n\n return () => {\n try {\n if (map.getLayer(layerId)) map.removeLayer(layerId);\n if (map.getSource(sourceId)) map.removeSource(sourceId);\n } catch {\n // ignore\n }\n };\n }, [\n isLoaded,\n map,\n coordinates,\n color,\n width,\n opacity,\n dashArray,\n sourceId,\n layerId,\n ]);\n\n return null;\n}\n\nexport {\n Map,\n useMap,\n MapMarker,\n MarkerContent,\n MarkerPopup,\n MarkerTooltip,\n MarkerLabel,\n MapPopup,\n MapControls,\n MapRoute,\n};\n","type": "registry:ui","target": "components/ui/map.tsx"}diff --git a/src/app/docs/api-reference/page.tsx b/src/app/docs/api-reference/page.tsxindex e48847e..4fed8a6 100644--- a/src/app/docs/api-reference/page.tsx+++ b/src/app/docs/api-reference/page.tsx@@ -266,8 +266,14 @@ export default function ApiReferencePage() {>PopupOptions</DocsLink>{" "}- from MapLibre GL.+ from MapLibre GL (excluding <DocsCode>className</DocsCode>).</p>+ <DocsNote>+ The <DocsCode>className</DocsCode> from MapLibre's PopupOptions+ is excluded to prevent style conflicts. Use the component's own{" "}+ <DocsCode>className</DocsCode> prop to style the popup content.+ MapLibre's default popup styles are reset via CSS.+ </DocsNote><DocsPropTableprops={[{@@ -304,10 +310,17 @@ export default function ApiReferencePage() {>PopupOptions</DocsLink>{" "}- from MapLibre GL (excluding <DocsCode>closeButton</DocsCode> and{" "}+ from MapLibre GL (excluding <DocsCode>className</DocsCode>,{" "}+ <DocsCode>closeButton</DocsCode>, and{" "}<DocsCode>closeOnClick</DocsCode> as tooltips auto-dismiss on hoverout).</p>+ <DocsNote>+ The <DocsCode>className</DocsCode> from MapLibre's PopupOptions+ is excluded to prevent style conflicts. Use the component's own{" "}+ <DocsCode>className</DocsCode> prop to style the tooltip content.+ MapLibre's default popup styles are reset via CSS.+ </DocsNote><DocsPropTableprops={[{@@ -366,8 +379,14 @@ export default function ApiReferencePage() {>PopupOptions</DocsLink>{" "}- from MapLibre GL.+ from MapLibre GL (excluding <DocsCode>className</DocsCode>).</p>+ <DocsNote>+ The <DocsCode>className</DocsCode> from MapLibre's PopupOptions+ is excluded to prevent style conflicts. Use the component's own{" "}+ <DocsCode>className</DocsCode> prop to style the popup content.+ MapLibre's default popup styles are reset via CSS.+ </DocsNote><DocsPropTableprops={[{diff --git a/src/app/globals.css b/src/app/globals.cssindex 145f0d9..a358b36 100644--- a/src/app/globals.css+++ b/src/app/globals.css@@ -125,15 +125,13 @@}.maplibregl-popup-content {@apply bg-transparent! shadow-none! p-0! rounded-none!;- @apply bg-transparent! shadow-none! p-0! rounded-none!;}.maplibregl-popup-tip {@apply hidden!;- @apply hidden!;}}-/* Custom animations */+/* animations for the home page */@keyframes fade-up {from {opacity: 0;@@ -184,16 +182,7 @@.delay-500 { animation-delay: 500ms; }.delay-600 { animation-delay: 600ms; }-@layer base {- * {- @apply border-border outline-ring/50;- }- body {- @apply bg-background text-foreground;- }-}--/* Shiki dual theme support */+/* Shiki dual theme support for code blocks */html .shiki,html .shiki span {color: var(--shiki-light) !important;diff --git a/src/registry/map.tsx b/src/registry/map.tsxindex 4018309..b2c7f30 100644--- a/src/registry/map.tsx+++ b/src/registry/map.tsx@@ -284,7 +284,9 @@ function MarkerPopup({offset: 16,...popupOptions,closeButton: false,- }).setDOMContent(container);+ })+ .setMaxWidth("none")+ .setDOMContent(container);popupRef.current = popup;markerRef.current.setPopup(popup);@@ -353,7 +355,9 @@ function MarkerTooltip({...popupOptions,closeOnClick: true,closeButton: false,- }).setDOMContent(container);+ })+ .setMaxWidth("none")+ .setDOMContent(container);popupRef.current = popup;@@ -664,6 +668,7 @@ function MapPopup({...popupOptions,closeButton: false,})+ .setMaxWidth("none").setDOMContent(container).setLngLat([longitude, latitude]);