Beautiful map components. 100% Free, Zero config, one command setup.
TypeScript
Docs update
Anmoldeep Singhcbd8ccde76a0
diff --git a/next.config.ts b/next.config.tsindex e9ffa30..6be334a 100644--- a/next.config.ts+++ b/next.config.ts@@ -2,6 +2,14 @@ import type { NextConfig } from "next";const nextConfig: NextConfig = {/* config options here */+ images: {+ remotePatterns: [+ {+ protocol: "https",+ hostname: "images.unsplash.com",+ },+ ],+ },};export default nextConfig;diff --git a/src/app/docs/_components/examples/advanced-usage-example.tsx b/src/app/docs/_components/examples/advanced-usage-example.tsxnew file mode 100644index 0000000..08bd898--- /dev/null+++ b/src/app/docs/_components/examples/advanced-usage-example.tsx@@ -0,0 +1,73 @@+"use client";++import { useEffect, useState } from "react";+import { Map, useMap } from "@/registry/map";+import { Button } from "@/components/ui/button";+import { RotateCcw, Mountain } from "lucide-react";++function MapController() {+ const { map, isLoaded } = useMap();+ const [pitch, setPitch] = useState(0);+ const [bearing, setBearing] = useState(0);++ useEffect(() => {+ if (!map || !isLoaded) return;++ const handleMove = () => {+ setPitch(Math.round(map.getPitch()));+ setBearing(Math.round(map.getBearing()));+ };++ map.on("move", handleMove);+ return () => {+ map.off("move", handleMove);+ };+ }, [map, isLoaded]);++ const handle3DView = () => {+ map?.easeTo({+ pitch: 60,+ bearing: -20,+ duration: 1000,+ });+ };++ const handleReset = () => {+ map?.easeTo({+ pitch: 0,+ bearing: 0,+ duration: 1000,+ });+ };++ if (!isLoaded) return null;++ return (+ <div className="absolute top-3 left-3 z-10 flex flex-col gap-2">+ <div className="flex gap-2">+ <Button size="sm" variant="secondary" onClick={handle3DView}>+ <Mountain className="size-4 mr-1.5" />+ 3D View+ </Button>+ <Button size="sm" variant="secondary" onClick={handleReset}>+ <RotateCcw className="size-4 mr-1.5" />+ Reset+ </Button>+ </div>+ <div className="rounded-md bg-background/90 backdrop-blur px-3 py-2 text-xs font-mono border">+ <div>Pitch: {pitch}°</div>+ <div>Bearing: {bearing}°</div>+ </div>+ </div>+ );+}++export function AdvancedUsageExample() {+ return (+ <div className="h-[450px] w-full overflow-hidden">+ <Map center={[-73.9857, 40.7484]} zoom={15}>+ <MapController />+ </Map>+ </div>+ );+}diff --git a/src/app/docs/_components/examples/custom-layer-example.tsx b/src/app/docs/_components/examples/custom-layer-example.tsxnew file mode 100644index 0000000..25d44b9--- /dev/null+++ b/src/app/docs/_components/examples/custom-layer-example.tsx@@ -0,0 +1,174 @@+"use client";++import { useCallback, useEffect, useState } from "react";+import { Map, MapControls, useMap } from "@/registry/map";+import { Button } from "@/components/ui/button";+import { Layers, X } from "lucide-react";++const geojsonData = {+ type: "FeatureCollection" as const,+ features: [+ {+ type: "Feature" as const,+ properties: { name: "Central Park", type: "park" },+ geometry: {+ type: "Polygon" as const,+ coordinates: [+ [+ [-73.9731, 40.7644],+ [-73.9819, 40.7681],+ [-73.958, 40.8006],+ [-73.9493, 40.7969],+ [-73.9731, 40.7644],+ ],+ ],+ },+ },+ {+ type: "Feature" as const,+ properties: { name: "Bryant Park", type: "park" },+ geometry: {+ type: "Polygon" as const,+ coordinates: [+ [+ [-73.9837, 40.7536],+ [-73.9854, 40.7542],+ [-73.984, 40.7559],+ [-73.9823, 40.7553],+ [-73.9837, 40.7536],+ ],+ ],+ },+ },+ ],+};++function CustomLayer() {+ const { map, isLoaded } = useMap();+ const [isLayerVisible, setIsLayerVisible] = useState(false);+ const [hoveredPark, setHoveredPark] = useState<string | null>(null);++ const addLayers = useCallback(() => {+ if (!map) return;+ // Add source if it doesn't exist+ if (!map.getSource("parks")) {+ map.addSource("parks", {+ type: "geojson",+ data: geojsonData,+ });+ }++ // Add fill layer if it doesn't exist+ if (!map.getLayer("parks-fill")) {+ map.addLayer({+ id: "parks-fill",+ type: "fill",+ source: "parks",+ paint: {+ "fill-color": "#22c55e",+ "fill-opacity": 0.4,+ },+ layout: {+ visibility: isLayerVisible ? "visible" : "none",+ },+ });+ }++ // Add outline layer if it doesn't exist+ if (!map.getLayer("parks-outline")) {+ map.addLayer({+ id: "parks-outline",+ type: "line",+ source: "parks",+ paint: {+ "line-color": "#16a34a",+ "line-width": 2,+ },+ layout: {+ visibility: isLayerVisible ? "visible" : "none",+ },+ });+ }+ }, [map, isLayerVisible]);++ useEffect(() => {+ if (!map || !isLoaded) return;++ // Add layers on mount+ addLayers();++ // Hover effect+ const handleMouseEnter = () => {+ map.getCanvas().style.cursor = "pointer";+ };++ const handleMouseLeave = () => {+ map.getCanvas().style.cursor = "";+ setHoveredPark(null);+ };++ const handleMouseMove = (e: maplibregl.MapMouseEvent) => {+ const features = map.queryRenderedFeatures(e.point, {+ layers: ["parks-fill"],+ });+ if (features.length > 0) {+ setHoveredPark(features[0].properties?.name || null);+ }+ };++ map.on("mouseenter", "parks-fill", handleMouseEnter);+ map.on("mouseleave", "parks-fill", handleMouseLeave);+ map.on("mousemove", "parks-fill", handleMouseMove);++ return () => {+ map.off("mouseenter", "parks-fill", handleMouseEnter);+ map.off("mouseleave", "parks-fill", handleMouseLeave);+ map.off("mousemove", "parks-fill", handleMouseMove);+ };+ }, [map, isLoaded, isLayerVisible]);++ const toggleLayer = () => {+ if (!map) return;++ const visibility = isLayerVisible ? "none" : "visible";+ map.setLayoutProperty("parks-fill", "visibility", visibility);+ map.setLayoutProperty("parks-outline", "visibility", visibility);+ setIsLayerVisible(!isLayerVisible);+ };++ return (+ <>+ <div className="absolute top-3 left-3 z-10">+ <Button+ size="sm"+ variant={isLayerVisible ? "default" : "secondary"}+ onClick={toggleLayer}+ >+ {isLayerVisible ? (+ <X className="size-4 mr-1.5" />+ ) : (+ <Layers className="size-4 mr-1.5" />+ )}+ {isLayerVisible ? "Hide Parks" : "Show Parks"}+ </Button>+ </div>++ {hoveredPark && (+ <div className="absolute bottom-3 left-3 z-10 rounded-md bg-background/90 backdrop-blur px-3 py-2 text-sm font-medium border">+ {hoveredPark}+ </div>+ )}+ </>+ );+}++export function CustomLayerExample() {+ return (+ <div className="h-[400px] w-full overflow-hidden">+ <Map center={[-73.97, 40.78]} zoom={11.8}>+ <MapControls />+ <CustomLayer />+ </Map>+ </div>+ );+}diff --git a/src/app/docs/_components/examples/markers-example.tsx b/src/app/docs/_components/examples/markers-example.tsxnew file mode 100644index 0000000..78c812b--- /dev/null+++ b/src/app/docs/_components/examples/markers-example.tsx@@ -0,0 +1,54 @@+"use client";++import {+ Map,+ MapMarker,+ MarkerContent,+ MarkerPopup,+ MarkerTooltip,+} from "@/registry/map";++const locations = [+ {+ id: 1,+ name: "Empire State Building",+ lng: -73.9857,+ lat: 40.7484,+ },+ {+ id: 2,+ name: "Central Park",+ lng: -73.9654,+ lat: 40.7829,+ },+ { id: 3, name: "Times Square", lng: -73.9855, lat: 40.758 },+];++export function MarkersExample() {+ return (+ <div className="h-[400px] w-full overflow-hidden">+ <Map center={[-73.98, 40.76]} zoom={12}>+ {locations.map((location) => (+ <MapMarker+ key={location.id}+ longitude={location.lng}+ latitude={location.lat}+ >+ <MarkerContent>+ <div className="size-4 rounded-full bg-primary border-2 border-white shadow-lg" />+ </MarkerContent>+ <MarkerTooltip>{location.name}</MarkerTooltip>+ <MarkerPopup>+ <div className="space-y-1">+ <p className="font-medium text-foreground">{location.name}</p>+ <p className="text-xs text-muted-foreground">+ {location.lat.toFixed(4)}, {location.lng.toFixed(4)}+ </p>+ </div>+ </MarkerPopup>+ </MapMarker>+ ))}+ </Map>+ </div>+ );+}diff --git a/src/app/docs/_components/examples/osrm-route-example.tsx b/src/app/docs/_components/examples/osrm-route-example.tsxnew file mode 100644index 0000000..33326a5--- /dev/null+++ b/src/app/docs/_components/examples/osrm-route-example.tsx@@ -0,0 +1,75 @@+"use client";++import { useEffect, useState } from "react";+import {+ Map,+ MapMarker,+ MarkerContent,+ MapRoute,+ MarkerLabel,+} from "@/registry/map";+import { Loader2 } from "lucide-react";++const start = { name: "Times Square", lng: -73.9855, lat: 40.758 };+const end = { name: "Central Park", lng: -73.9654, lat: 40.7829 };++export function OsrmRouteExample() {+ const [route, setRoute] = useState<[number, number][] | null>(null);+ const [isLoading, setIsLoading] = useState(true);++ useEffect(() => {+ async function fetchRoute() {+ try {+ const response = await fetch(+ `https://router.project-osrm.org/route/v1/driving/${start.lng},${start.lat};${end.lng},${end.lat}?overview=full&geometries=geojson`+ );+ const data = await response.json();++ if (data.routes?.[0]?.geometry?.coordinates) {+ setRoute(data.routes[0].geometry.coordinates);+ }+ } catch (error) {+ console.error("Failed to fetch route:", error);+ } finally {+ setIsLoading(false);+ }+ }++ fetchRoute();+ }, []);++ return (+ <div className="h-[400px] w-full overflow-hidden relative">+ <Map center={[-73.975, 40.77]} zoom={12.5}>+ {route && (+ <MapRoute+ coordinates={route}+ color="#6366f1"+ width={5}+ opacity={0.85}+ />+ )}++ <MapMarker longitude={start.lng} latitude={start.lat}>+ <MarkerContent>+ <div className="size-5 rounded-full bg-green-500 border-2 border-white shadow-lg" />+ <MarkerLabel position="bottom">Start: {start.name}</MarkerLabel>+ </MarkerContent>+ </MapMarker>++ <MapMarker longitude={end.lng} latitude={end.lat}>+ <MarkerContent>+ <div className="size-5 rounded-full bg-red-500 border-2 border-white shadow-lg" />+ <MarkerLabel position="bottom">End: {end.name}</MarkerLabel>+ </MarkerContent>+ </MapMarker>+ </Map>++ {isLoading && (+ <div className="absolute inset-0 flex items-center justify-center bg-background/50">+ <Loader2 className="size-6 animate-spin text-muted-foreground" />+ </div>+ )}+ </div>+ );+}diff --git a/src/app/docs/_components/examples/popup-example.tsx b/src/app/docs/_components/examples/popup-example.tsxnew file mode 100644index 0000000..496f761--- /dev/null+++ b/src/app/docs/_components/examples/popup-example.tsx@@ -0,0 +1,110 @@+"use client";++import {+ Map,+ MapMarker,+ MarkerContent,+ MarkerLabel,+ MarkerPopup,+} from "@/registry/map";+import { Button } from "@/components/ui/button";+import { Star, Navigation, Clock, ExternalLink } from "lucide-react";+import Image from "next/image";++const places = [+ {+ id: 1,+ name: "The Metropolitan Museum of Art",+ category: "Museum",+ rating: 4.8,+ reviews: 12453,+ hours: "10:00 AM - 5:00 PM",+ image:+ "https://images.unsplash.com/photo-1575223970966-76ae61ee7838?w=300&h=200&fit=crop",+ lng: -73.9632,+ lat: 40.7794,+ },+ {+ id: 2,+ name: "Brooklyn Bridge",+ category: "Landmark",+ rating: 4.9,+ reviews: 8234,+ hours: "Open 24 hours",+ image:+ "https://images.unsplash.com/photo-1496588152823-86ff7695e68f?w=300&h=200&fit=crop",+ lng: -73.9969,+ lat: 40.7061,+ },+ {+ id: 3,+ name: "Grand Central Terminal",+ category: "Transit",+ rating: 4.7,+ reviews: 5621,+ hours: "5:15 AM - 2:00 AM",+ image:+ "https://images.unsplash.com/photo-1534430480872-3498386e7856?w=300&h=200&fit=crop",+ lng: -73.9772,+ lat: 40.7527,+ },+];++export function PopupExample() {+ return (+ <div className="h-[500px] w-full overflow-hidden">+ <Map center={[-73.98, 40.74]} zoom={11}>+ {places.map((place) => (+ <MapMarker key={place.id} longitude={place.lng} latitude={place.lat}>+ <MarkerContent>+ <div className="size-5 rounded-full bg-rose-500 border-2 border-white shadow-lg cursor-pointer hover:scale-110 transition-transform" />+ <MarkerLabel>{place.name}</MarkerLabel>+ </MarkerContent>+ <MarkerPopup className="p-0 w-62">+ <div className="relative h-32 overflow-hidden rounded-t-md">+ <Image+ fill+ src={place.image}+ alt={place.name}+ className="object-cover"+ />+ </div>+ <div className="space-y-2 p-3">+ <div>+ <span className="text-xs font-medium text-muted-foreground uppercase tracking-wide">+ {place.category}+ </span>+ <h3 className="font-semibold text-foreground leading-tight">+ {place.name}+ </h3>+ </div>+ <div className="flex items-center gap-3 text-sm">+ <div className="flex items-center gap-1">+ <Star className="size-3.5 fill-amber-400 text-amber-400" />+ <span className="font-medium">{place.rating}</span>+ <span className="text-muted-foreground">+ ({place.reviews.toLocaleString()})+ </span>+ </div>+ </div>+ <div className="flex items-center gap-1.5 text-sm text-muted-foreground">+ <Clock className="size-3.5" />+ <span>{place.hours}</span>+ </div>+ <div className="flex gap-2 pt-1">+ <Button size="sm" className="flex-1 h-8">+ <Navigation className="size-3.5 mr-1.5" />+ Directions+ </Button>+ <Button size="sm" variant="outline" className="h-8">+ <ExternalLink className="size-3.5" />+ </Button>+ </div>+ </div>+ </MarkerPopup>+ </MapMarker>+ ))}+ </Map>+ </div>+ );+}diff --git a/src/app/docs/_components/examples/route-example.tsx b/src/app/docs/_components/examples/route-example.tsxnew file mode 100644index 0000000..9cbc33f--- /dev/null+++ b/src/app/docs/_components/examples/route-example.tsx@@ -0,0 +1,44 @@+"use client";++import {+ Map,+ MapMarker,+ MarkerContent,+ MarkerTooltip,+ MapRoute,+} from "@/registry/map";++const route = [+ [-74.006, 40.7128], // NYC City Hall+ [-73.9857, 40.7484], // Empire State Building+ [-73.9772, 40.7527], // Grand Central+ [-73.9654, 40.7829], // Central Park+] as [number, number][];++const stops = [+ { name: "City Hall", lng: -74.006, lat: 40.7128 },+ { name: "Empire State Building", lng: -73.9857, lat: 40.7484 },+ { name: "Grand Central Terminal", lng: -73.9772, lat: 40.7527 },+ { name: "Central Park", lng: -73.9654, lat: 40.7829 },+];++export function RouteExample() {+ return (+ <div className="h-[400px] w-full overflow-hidden">+ <Map center={[-73.98, 40.76]} zoom={11}>+ <MapRoute coordinates={route} color="#3b82f6" width={4} opacity={0.8} />++ {stops.map((stop, index) => (+ <MapMarker key={stop.name} longitude={stop.lng} latitude={stop.lat}>+ <MarkerContent>+ <div className="size-6 rounded-full bg-blue-500 border-2 border-white shadow-lg flex items-center justify-center text-white text-xs font-bold">+ {index + 1}+ </div>+ </MarkerContent>+ <MarkerTooltip>{stop.name}</MarkerTooltip>+ </MapMarker>+ ))}+ </Map>+ </div>+ );+}diff --git a/src/app/docs/_components/examples/standalone-popup-example.tsx b/src/app/docs/_components/examples/standalone-popup-example.tsxnew file mode 100644index 0000000..8e1c4a7--- /dev/null+++ b/src/app/docs/_components/examples/standalone-popup-example.tsx@@ -0,0 +1,50 @@+"use client";++import { useState } from "react";+import { Map, MapPopup } from "@/registry/map";+import { Button } from "@/components/ui/button";++export function StandalonePopupExample() {+ const [showPopup, setShowPopup] = useState(true);++ return (+ <div className="h-[400px] w-full overflow-hidden relative">+ <Map center={[-74.006, 40.7128]} zoom={13}>+ <MapPopup+ longitude={-74.006}+ latitude={40.7128}+ open={showPopup}+ onClose={() => setShowPopup(false)}+ closeButton+ focusAfterOpen={false}+ closeOnClick={false}+ >+ <div className="space-y-2 pr-4">+ <h3 className="font-semibold text-foreground">New York City</h3>+ <p className="text-sm text-muted-foreground">+ The city that never sleeps. Population: 8.3 million+ </p>+ <Button+ size="sm"+ variant="outline"+ className="w-full"+ onClick={() => setShowPopup(false)}+ >+ Close+ </Button>+ </div>+ </MapPopup>+ </Map>++ {!showPopup && (+ <Button+ size="sm"+ className="absolute bottom-4 left-4 z-10"+ onClick={() => setShowPopup(true)}+ >+ Show Popup+ </Button>+ )}+ </div>+ );+}diff --git a/src/app/docs/advanced-usage/page.tsx b/src/app/docs/advanced-usage/page.tsxnew file mode 100644index 0000000..e09ea69--- /dev/null+++ b/src/app/docs/advanced-usage/page.tsx@@ -0,0 +1,133 @@+import {+ DocsLayout,+ DocsSection,+ DocsCode,+ DocsLink,+ DocsNote,+} from "../_components/docs";+import { ComponentPreview } from "../_components/component-preview";+import { AdvancedUsageExample } from "../_components/examples/advanced-usage-example";+import { CustomLayerExample } from "../_components/examples/custom-layer-example";+import { CodeBlock } from "../_components/code-block";+import { getExampleSource } from "@/lib/get-example-source";++const useMapCode = `import { Map, useMap } from "@/components/ui/map";++function MyComponent() {+ const { map, isLoaded } = useMap();++ useEffect(() => {+ if (!map || !isLoaded) return;++ // Access the underlying MapLibre GL map instance+ map.on("click", (e) => {+ console.log("Clicked at:", e.lngLat);+ });++ // Use any MapLibre GL method+ map.flyTo({ center: [-74, 40.7], zoom: 12 });+ }, [map, isLoaded]);++ return null;+}`;++export default function AdvancedPage() {+ const advancedSource = getExampleSource("advanced-usage-example.tsx");+ const customLayerSource = getExampleSource("custom-layer-example.tsx");++ return (+ <DocsLayout+ title="Advanced Usage"+ description="Access the underlying MapLibre GL instance for advanced customization."+ prev={{ title: "Routes", href: "/docs/routes" }}+ >+ <DocsSection>+ <p>+ The <DocsCode>useMap</DocsCode> hook provides direct access to the+ MapLibre GL map instance, allowing you to use any feature from the+ MapLibre GL JS API.+ </p>+ </DocsSection>++ <DocsNote>+ <strong>Tip:</strong> Check the{" "}+ <DocsLink+ href="https://maplibre.org/maplibre-gl-js/docs/API/classes/Map/"+ external+ >+ MapLibre GL JS documentation+ </DocsLink>{" "}+ for the full list of available methods and events.+ </DocsNote>++ <DocsSection title="Using the Hook">+ <p>+ Create a child component inside <DocsCode>Map</DocsCode> and use the{" "}+ <DocsCode>useMap</DocsCode> hook to access the map instance.+ </p>+ <CodeBlock code={useMapCode} />+ </DocsSection>++ <DocsSection title="Example: Custom Controls">+ <p>+ This example shows how to create custom controls that manipulate the+ map's pitch and bearing, and listen to map events to display+ real-time values.+ </p>+ </DocsSection>++ <ComponentPreview code={advancedSource}>+ <AdvancedUsageExample />+ </ComponentPreview>++ <DocsSection title="Example: Custom GeoJSON Layer">+ <p>+ Add custom GeoJSON data as layers with fill and outline styles. This+ example shows NYC parks with hover interactions.+ </p>+ </DocsSection>++ <ComponentPreview code={customLayerSource}>+ <CustomLayerExample />+ </ComponentPreview>++ <DocsSection title="Extend to Build">+ <p>You can extend this to build custom features like:</p>+ <ul>+ <li>+ <strong>Real-time tracking</strong> - Live location updates for+ delivery, rides, or fleet management+ </li>+ <li>+ <strong>Geofencing</strong> - Trigger actions when users enter or+ leave specific areas+ </li>+ <li>+ <strong>Heatmaps</strong> - Visualize density data like population,+ crime, or activity hotspots+ </li>+ <li>+ <strong>Drawing tools</strong> - Let users draw polygons, lines, or+ place markers for custom areas+ </li>+ <li>+ <strong>3D buildings</strong> - Extrude building footprints for+ urban visualization+ </li>+ <li>+ <strong>Animations</strong> - Animate markers along routes or create+ fly-through experiences+ </li>+ <li>+ <strong>Custom data layers</strong> - Overlay weather, traffic, or+ satellite imagery+ </li>+ <li>+ <strong>Clustering</strong> - Group thousands of markers into+ clusters for performance+ </li>+ </ul>+ </DocsSection>+ </DocsLayout>+ );+}diff --git a/src/app/docs/controls/page.tsx b/src/app/docs/controls/page.tsxindex 47dc2ee..baa65b5 100644--- a/src/app/docs/controls/page.tsx+++ b/src/app/docs/controls/page.tsx@@ -1,21 +1,8 @@import { DocsLayout, DocsSection, DocsCode } from "../_components/docs";import { ComponentPreview } from "../_components/component-preview";-import { CodeBlock } from "../_components/code-block";import { MapControlsExample } from "../_components/examples/map-controls-example";import { getExampleSource } from "@/lib/get-example-source";-const controlsPropsCode = `<MapControls- position="bottom-right" // "top-left" | "top-right" | "bottom-left" | "bottom-right"- showZoom={true} // Zoom in/out buttons- showCompass={true} // Reset bearing to north- showLocate={true} // Find user's location- showFullscreen={true} // Toggle fullscreen mode- className="custom-class" // Additional CSS classes- onLocate={(coords) => { // Callback when location found- console.log(coords.longitude, coords.latitude);- }}-/>`;-export default function ControlsPage() {const controlsSource = getExampleSource("map-controls-example.tsx");@@ -24,6 +11,7 @@ export default function ControlsPage() {title="Map Controls"description="Add interactive controls to your map for zoom, compass, location, and fullscreen."prev={{ title: "Basic Map", href: "/docs/basic-map" }}+ next={{ title: "Markers", href: "/docs/markers" }}><DocsSection><p>@@ -35,35 +23,6 @@ export default function ControlsPage() {<ComponentPreview code={controlsSource}><MapControlsExample /></ComponentPreview>-- <DocsSection title="Props">- <CodeBlock code={controlsPropsCode} />- <ul className="mt-4 space-y-2">- <li>- <strong>position</strong> - Where to place the controls on the map- </li>- <li>- <strong>showZoom</strong> - Display zoom in/out buttons- </li>- <li>- <strong>showCompass</strong> - Display compass to reset bearing- </li>- <li>- <strong>showLocate</strong> - Display button to find user location- </li>- <li>- <strong>showFullscreen</strong> - Display fullscreen toggle button- </li>- <li>- <strong>onLocate</strong> - Callback with coordinates when location- is found- </li>- <li>- <strong>className</strong> - Additional tailwind classes to- customize the controls- </li>- </ul>- </DocsSection></DocsLayout>);}diff --git a/src/app/docs/layout.tsx b/src/app/docs/layout.tsxindex 4de61ff..25985db 100644--- a/src/app/docs/layout.tsx+++ b/src/app/docs/layout.tsx@@ -2,7 +2,17 @@import Link from "next/link";import { usePathname } from "next/navigation";-import { Map, BookOpen, Code, Settings, Braces } from "lucide-react";+import {+ Map,+ BookOpen,+ Code,+ Settings,+ Braces,+ MapPin,+ MessageSquare,+ Route,+ Wrench,+} from "lucide-react";import {Sidebar,@@ -36,6 +46,10 @@ const navigation = [items: [{ title: "Basic Map", href: "/docs/basic-map", icon: Map },{ title: "Map Controls", href: "/docs/controls", icon: Settings },+ { title: "Markers", href: "/docs/markers", icon: MapPin },+ { title: "Popups", href: "/docs/popups", icon: MessageSquare },+ { title: "Routes", href: "/docs/routes", icon: Route },+ { title: "Advanced Usage", href: "/docs/advanced-usage", icon: Wrench },],},];diff --git a/src/app/docs/markers/page.tsx b/src/app/docs/markers/page.tsxnew file mode 100644index 0000000..764ef03--- /dev/null+++ b/src/app/docs/markers/page.tsx@@ -0,0 +1,48 @@+import { DocsLayout, DocsSection, DocsCode } from "../_components/docs";+import { ComponentPreview } from "../_components/component-preview";+import { MarkersExample } from "../_components/examples/markers-example";+import { PopupExample } from "../_components/examples/popup-example";+import { getExampleSource } from "@/lib/get-example-source";++export default function MarkersPage() {+ const markersSource = getExampleSource("markers-example.tsx");+ const popupSource = getExampleSource("popup-example.tsx");++ return (+ <DocsLayout+ title="Markers"+ description="Add interactive markers to your map with popups and tooltips."+ prev={{ title: "Map Controls", href: "/docs/controls" }}+ next={{ title: "Popups", href: "/docs/popups" }}+ >+ <DocsSection>+ <p>+ Use <DocsCode>MapMarker</DocsCode> to place markers on the map. Each+ marker can have custom content, popups that open on click, and+ tooltips that appear on hover.+ </p>+ </DocsSection>++ <DocsSection title="Basic Example">+ <p>+ Simple markers with tooltips and popups showing location information.+ </p>+ </DocsSection>++ <ComponentPreview code={markersSource}>+ <MarkersExample />+ </ComponentPreview>++ <DocsSection title="Rich Popups">+ <p>+ Build complex popups with images, ratings, and action buttons using+ shadcn/ui components.+ </p>+ </DocsSection>++ <ComponentPreview code={popupSource}>+ <PopupExample />+ </ComponentPreview>+ </DocsLayout>+ );+}diff --git a/src/app/docs/popups/page.tsx b/src/app/docs/popups/page.tsxnew file mode 100644index 0000000..b5eda4b--- /dev/null+++ b/src/app/docs/popups/page.tsx@@ -0,0 +1,29 @@+import { DocsLayout, DocsSection, DocsCode } from "../_components/docs";+import { ComponentPreview } from "../_components/component-preview";+import { StandalonePopupExample } from "../_components/examples/standalone-popup-example";+import { getExampleSource } from "@/lib/get-example-source";++export default function PopupsPage() {+ const popupSource = getExampleSource("standalone-popup-example.tsx");++ return (+ <DocsLayout+ title="Standalone Popups"+ description="Display popups anywhere on the map without markers."+ prev={{ title: "Markers", href: "/docs/markers" }}+ next={{ title: "Routes", href: "/docs/routes" }}+ >+ <DocsSection>+ <p>+ Use <DocsCode>MapPopup</DocsCode> to display a popup at any location+ on the map. Unlike <DocsCode>MarkerPopup</DocsCode>, standalone popups+ are not attached to markers and can be controlled programmatically.+ </p>+ </DocsSection>++ <ComponentPreview code={popupSource}>+ <StandalonePopupExample />+ </ComponentPreview>+ </DocsLayout>+ );+}diff --git a/src/app/docs/routes/page.tsx b/src/app/docs/routes/page.tsxnew file mode 100644index 0000000..860aef1--- /dev/null+++ b/src/app/docs/routes/page.tsx@@ -0,0 +1,46 @@+import { DocsLayout, DocsSection, DocsCode } from "../_components/docs";+import { ComponentPreview } from "../_components/component-preview";+import { RouteExample } from "../_components/examples/route-example";+import { OsrmRouteExample } from "../_components/examples/osrm-route-example";+import { getExampleSource } from "@/lib/get-example-source";++export default function RoutesPage() {+ const routeSource = getExampleSource("route-example.tsx");+ const osrmRouteSource = getExampleSource("osrm-route-example.tsx");++ return (+ <DocsLayout+ title="Routes"+ description="Draw lines and paths connecting coordinates on the map."+ prev={{ title: "Popups", href: "/docs/popups" }}+ next={{ title: "Advanced Usage", href: "/docs/advanced-usage" }}+ >+ <DocsSection>+ <p>+ Use <DocsCode>MapRoute</DocsCode> to draw lines connecting a series of+ coordinates. Perfect for showing directions, trails, or any path+ between points.+ </p>+ </DocsSection>++ <DocsSection title="Basic Route">+ <p>Draw a route with numbered stop markers along the path.</p>+ </DocsSection>++ <ComponentPreview code={routeSource}>+ <RouteExample />+ </ComponentPreview>++ <DocsSection title="Dynamic Route from OSRM">+ <p>+ Fetch real driving directions from the OSRM API and display them on+ the map.+ </p>+ </DocsSection>++ <ComponentPreview code={osrmRouteSource}>+ <OsrmRouteExample />+ </ComponentPreview>+ </DocsLayout>+ );+}