Beautiful map components. 100% Free, Zero config, one command setup.
TypeScript
add copyable install command and refine homepage examples
anmol124a34dabdc7
diff --git a/src/app/(main)/(home)/_components/examples/analytics-example.tsx b/src/app/(main)/(home)/_components/examples/analytics-example.tsxindex e965b8a..1d4fc5a 100644--- a/src/app/(main)/(home)/_components/examples/analytics-example.tsx+++ b/src/app/(main)/(home)/_components/examples/analytics-example.tsx@@ -31,30 +31,30 @@ export function AnalyticsExample() {</div><div className="text-2xl leading-tight font-semibold">3,544</div><div className="mt-1 flex items-center gap-1">- <TrendingUp className="size-3 text-emerald-500" />- <span className="text-xs text-emerald-500">+12.5%</span>+ <TrendingUp className="size-3" />+ <span className="text-foreground text-xs">+12.5%</span><span className="text-muted-foreground text-xs">vs last hour</span></div></div>- <Map center={[0, 30]}>+ <Map+ center={[0, 30]}+ scrollZoom={false}+ dragRotate={false}+ pitchWithRotate={false}+ >{analyticsData.map((loc) => (<MapMarker key={loc.city} longitude={loc.lng} latitude={loc.lat}><MarkerContent><div- className="rounded-full bg-emerald-500/80 shadow-sm"+ className="rounded-full bg-blue-500/80 shadow-sm"style={{ width: loc.size * 1.8, height: loc.size * 1.8 }}/></MarkerContent><MarkerTooltip><div className="text-center"><div className="font-medium">{loc.city}</div>- <div className="font-semibold text-emerald-400">- {loc.users}- </div>- <div className="text-background/70 text-[10px]">- active users- </div>+ <div className="text-background/80">{loc.users} users</div></div></MarkerTooltip></MapMarker>diff --git a/src/app/(main)/(home)/_components/examples/arc-example.tsx b/src/app/(main)/(home)/_components/examples/arc-example.tsxindex 3d118b3..1764994 100644--- a/src/app/(main)/(home)/_components/examples/arc-example.tsx+++ b/src/app/(main)/(home)/_components/examples/arc-example.tsx@@ -28,7 +28,12 @@ const arcs = destinations.map((dest) => ({export function ArcExample() {return (<ExampleCard className="aspect-square" stagger={8}>- <Map center={[-0.1276, 41.5074]} zoom={1} projection={{ type: "globe" }}>+ <Map+ center={[-0.1276, 41.5074]}+ zoom={1}+ projection={{ type: "globe" }}+ scrollZoom={false}+ ><MapArcdata={arcs}paint={{diff --git a/src/app/(main)/(home)/_components/examples/delivery-example.tsx b/src/app/(main)/(home)/_components/examples/delivery-example.tsxindex d6f0453..b5e7a12 100644--- a/src/app/(main)/(home)/_components/examples/delivery-example.tsx+++ b/src/app/(main)/(home)/_components/examples/delivery-example.tsx@@ -90,7 +90,13 @@ export function DeliveryExample() {className="aspect-square sm:col-span-2 sm:aspect-video lg:aspect-auto"stagger={9}>- <Map center={[-0.105, 51.511]} zoom={12.4}>+ <Map+ center={[-0.105, 51.511]}+ zoom={12.6}+ scrollZoom={false}+ dragRotate={false}+ pitchWithRotate={false}+ ><MapRoute coordinates={route} width={4} color="#3b82f6" /><MapMarker longitude={store.lng} latitude={store.lat}><MarkerContent>@@ -108,7 +114,7 @@ export function DeliveryExample() {</MapMarker><MapMarker longitude={home.lng} latitude={home.lat}><MarkerContent>- <div className="size-3.5 rounded-full border-2 border-white bg-blue-500 shadow-lg" />+ <div className="size-3.5 rounded-full border-2 border-white bg-red-500 shadow-lg" /><MarkerLabel>Home</MarkerLabel></MarkerContent></MapMarker>diff --git a/src/app/(main)/(home)/_components/examples/ev-charging-example.tsx b/src/app/(main)/(home)/_components/examples/ev-charging-example.tsxindex 3dc4623..fe8e07d 100644--- a/src/app/(main)/(home)/_components/examples/ev-charging-example.tsx+++ b/src/app/(main)/(home)/_components/examples/ev-charging-example.tsx@@ -118,7 +118,13 @@ const statusConfig: Record<export function EVChargingExample() {return (<ExampleCard className="aspect-square" stagger={7}>- <Map center={[-122.434, 37.776]} zoom={11}>+ <Map+ center={[-122.434, 37.776]}+ zoom={11}+ scrollZoom={false}+ dragRotate={false}+ pitchWithRotate={false}+ >{stations.map((station) => {const config = statusConfig[station.status];return (@@ -132,15 +138,15 @@ export function EVChargingExample() {<Zap className="size-3 fill-white text-white" /></div></MarkerContent>- <MarkerTooltip>- <div className="space-y-0.5 text-xs">+ <MarkerTooltip className="bg-popover text-popover-foreground border px-2.5 py-1.5">+ <div className="space-y-1 text-xs"><div className="font-medium">{station.name}</div><div className="flex items-center gap-1"><span className={`size-1.5 rounded-full ${config.bg}`} /><span className={config.textClass}>{config.label}</span></div>{station.detail && (- <div className="text-background/60 text-[11px]">+ <div className="text-muted-foreground text-[11px]">{station.detail}</div>)}diff --git a/src/app/(main)/(home)/_components/examples/flyto-example.tsx b/src/app/(main)/(home)/_components/examples/flyto-example.tsxindex f0193b1..775d987 100644--- a/src/app/(main)/(home)/_components/examples/flyto-example.tsx+++ b/src/app/(main)/(home)/_components/examples/flyto-example.tsx@@ -21,7 +21,7 @@ export function FlyToExample() {setActiveIndex(index);mapRef.current?.flyTo({center: destinations[index].center,- zoom: 4.5,+ zoom: 6,duration: 2000,essential: true,});@@ -31,12 +31,18 @@ export function FlyToExample() {return (<ExampleCard className="aspect-square" stagger={6}>- <Map ref={mapRef} center={active.center} zoom={4.5}>+ <Map+ ref={mapRef}+ center={active.center}+ zoom={5.5}+ scrollZoom={false}+ dragRotate={false}+ pitchWithRotate={false}+ ><MapMarker longitude={active.center[0]} latitude={active.center[1]}><MarkerContent>- <div className="relative flex items-center justify-center">- <div className="absolute size-6 animate-ping rounded-full bg-blue-500/30" />- <div className="size-3 rounded-full border-2 border-white bg-blue-500 shadow-lg" />+ <div className="flex items-center justify-center">+ <div className="size-3.5 rounded-full border-2 border-white bg-blue-500 shadow-lg" /></div></MarkerContent></MapMarker>diff --git a/src/app/(main)/(home)/_components/examples/trail-example.tsx b/src/app/(main)/(home)/_components/examples/trail-example.tsxindex 7daaa3b..d1fd377 100644--- a/src/app/(main)/(home)/_components/examples/trail-example.tsx+++ b/src/app/(main)/(home)/_components/examples/trail-example.tsx@@ -1,7 +1,7 @@"use client";import { Map, MapRoute, MapMarker, MarkerContent } from "@/registry/map";-import { Bike, Flame, Clock, Route } from "lucide-react";+import { Bike } from "lucide-react";import { ExampleCard } from "./example-card";// Central Park cycling route@@ -28,32 +28,23 @@ export function TrailExample() {<ExampleCard className="aspect-square" stagger={5}><div className="bg-background/95 border-border/50 absolute top-3 left-3 z-10 rounded-lg border p-3 shadow-lg backdrop-blur-md"><div className="mb-2 flex items-center gap-1.5">- <Bike className="size-3.5 text-emerald-500" />+ <Bike className="text-foreground size-3.5" /><span className="text-xs font-medium">Central Park Loop</span></div><div className="grid grid-cols-3 gap-3 text-center"><div>- <div className="text-muted-foreground mb-0.5 flex items-center justify-center gap-1">- <Route className="size-3" />- </div><div className="text-sm font-semibold">6.2</div><div className="text-muted-foreground text-[9px] uppercase">Miles</div></div><div>- <div className="text-muted-foreground mb-0.5 flex items-center justify-center gap-1">- <Clock className="size-3" />- </div><div className="text-sm font-semibold">32</div><div className="text-muted-foreground text-[9px] uppercase">Mins</div></div><div>- <div className="text-muted-foreground mb-0.5 flex items-center justify-center gap-1">- <Flame className="size-3" />- </div><div className="text-sm font-semibold">285</div><div className="text-muted-foreground text-[9px] uppercase">Cal@@ -62,10 +53,16 @@ export function TrailExample() {</div></div>- <Map center={[-73.97, 40.782]} zoom={11.8}>+ <Map+ center={[-73.97, 40.782]}+ zoom={11.8}+ scrollZoom={false}+ dragRotate={false}+ pitchWithRotate={false}+ ><MapRoutecoordinates={trailCoordinates}- color="#10b981"+ color="#3b82f6"width={3}opacity={0.9}/>diff --git a/src/app/(main)/docs/_components/install-command.tsx b/src/app/(main)/docs/_components/install-command.tsxnew file mode 100644index 0000000..ad68d47--- /dev/null+++ b/src/app/(main)/docs/_components/install-command.tsx@@ -0,0 +1,74 @@+"use client";++import { useState } from "react";+import { Check, Copy } from "lucide-react";+import { Button } from "@/components/ui/button";+import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";++interface InstallCommandProps {+ /** The shadcn registry item to add, e.g. "@mapcn/map" */+ name: string;+}++const PACKAGE_MANAGERS = [+ { manager: "pnpm", exec: "pnpm dlx" },+ { manager: "npm", exec: "npx" },+ { manager: "yarn", exec: "yarn dlx" },+ { manager: "bun", exec: "bunx --bun" },+] as const;++export function InstallCommand({ name }: InstallCommandProps) {+ const tabs = PACKAGE_MANAGERS.map(({ manager, exec }) => ({+ manager,+ command: `${exec} shadcn@latest add ${name}`,+ }));++ const [active, setActive] = useState<string>(tabs[0].manager);+ const [copied, setCopied] = useState(false);++ const copy = async () => {+ const current = tabs.find((tab) => tab.manager === active);+ if (!current) return;+ await navigator.clipboard.writeText(current.command);+ setCopied(true);+ setTimeout(() => setCopied(false), 2000);+ };++ return (+ <div className="relative w-full overflow-hidden rounded-lg border">+ <Tabs value={active} onValueChange={setActive} className="gap-0">+ <div className="bg-muted/40 flex items-center justify-between border-b pr-2 pl-2">+ <TabsList variant="line" className="h-9 bg-transparent">+ {tabs.map((tab) => (+ <TabsTrigger+ key={tab.manager}+ value={tab.manager}+ className="font-mono text-xs"+ >+ {tab.manager}+ </TabsTrigger>+ ))}+ </TabsList>+ <Button+ variant="ghost"+ size="icon-sm"+ onClick={copy}+ aria-label={copied ? "Copied" : "Copy command"}+ className="text-muted-foreground"+ >+ {copied ? <Check /> : <Copy />}+ </Button>+ </div>+ {tabs.map((tab) => (+ <TabsContent key={tab.manager} value={tab.manager}>+ <pre className="bg-muted/40 overflow-x-auto p-4 text-sm">+ <code className="font-mono" data-language="bash">+ {tab.command}+ </code>+ </pre>+ </TabsContent>+ ))}+ </Tabs>+ </div>+ );+}diff --git a/src/app/(main)/docs/installation/page.tsx b/src/app/(main)/docs/installation/page.tsxindex f86d142..e435770 100644--- a/src/app/(main)/docs/installation/page.tsx+++ b/src/app/(main)/docs/installation/page.tsx@@ -6,12 +6,11 @@ import {DocsSection,} from "../_components/docs";import { CodeBlock } from "../_components/code-block";+import { InstallCommand } from "../_components/install-command";import { Metadata } from "next";import { Card } from "@/components/ui/card";import { Map, MapControls } from "@/registry/map";-const installCommand = "npx shadcn@latest add @mapcn/map";-const usageCode = `import { Map, MapControls } from "@/components/ui/map";import { Card } from "@/components/ui/card";@@ -58,7 +57,7 @@ export default function InstallationPage() {<DocsSection title="Installation"><p>Run the following command to add the map component:</p>- <CodeBlock code={installCommand} language="bash" />+ <InstallCommand name="@mapcn/map" /><p>This will install <DocsCode>maplibre-gl</DocsCode> and add the mapcomponent to your project.diff --git a/src/registry/blocks/analytics-map/page.tsx b/src/registry/blocks/analytics-map/page.tsxindex 7796374..820488c 100644--- a/src/registry/blocks/analytics-map/page.tsx+++ b/src/registry/blocks/analytics-map/page.tsx@@ -59,10 +59,12 @@ export default function Page() {</MarkerContent><MarkerTooltipoffset={20}- className="bg-popover text-muted-foreground border"+ className="bg-popover text-popover-foreground border">- <p className="text-foreground font-medium">{location.city}</p>- <p className="mt-0.5">{location.size} active users</p>+ <p className="font-medium">{location.city}</p>+ <p className="text-muted-foreground mt-0.5">+ {location.size} active users+ </p></MarkerTooltip></MapMarker>))}diff --git a/src/registry/blocks/choropleth/data.ts b/src/registry/blocks/choropleth/data.tsindex df583a5..b2ff06c 100644--- a/src/registry/blocks/choropleth/data.ts+++ b/src/registry/blocks/choropleth/data.ts@@ -44,7 +44,7 @@ interface ChoroplethColors {/*** Central map config — colors, the value→color scale, and the initial view.* WebGL paint can't read CSS variables, so colors are concrete values per- * theme. The ramp is a single-hue blue scale tuned for contrast on each+ * theme. The ramp is a single-hue grayscale scale tuned for contrast on each* theme's basemap.*/export const mapConfig = {diff --git a/src/registry/blocks/choropleth/page.tsx b/src/registry/blocks/choropleth/page.tsxindex 5c5ee71..0cc8359 100644--- a/src/registry/blocks/choropleth/page.tsx+++ b/src/registry/blocks/choropleth/page.tsx@@ -114,7 +114,6 @@ export default function Page() {maxZoom={mapConfig.view.maxZoom}dragRotate={false}pitchWithRotate={false}- attributionControl={false}loading={!countries}>{countries && (diff --git a/src/registry/blocks/delivery-tracker/page.tsx b/src/registry/blocks/delivery-tracker/page.tsxindex a85b503..635060c 100644--- a/src/registry/blocks/delivery-tracker/page.tsx+++ b/src/registry/blocks/delivery-tracker/page.tsx@@ -1,6 +1,7 @@"use client";import { useEffect, useMemo, useState } from "react";+import { useTheme } from "next-themes";import { Clock3, Utensils, Truck, UserRound } from "lucide-react";import {@@ -44,8 +45,8 @@ const deliveryMeals: DeliveryMeal[] = [},];-const pickup = { lng: -122.466, lat: 37.716 };-const dropoff = { lng: -122.399, lat: 37.683 };+const pickup = { lng: -122.4185, lat: 37.7645 };+const dropoff = { lng: -122.434, lat: 37.7475 };function formatDistance(meters?: number) {if (!meters) return "--";@@ -65,6 +66,8 @@ function formatDuration(seconds?: number) {export default function Page() {const [routeData, setRouteData] = useState<OsrmRouteData | null>(null);const [loading, setLoading] = useState(true);+ const { resolvedTheme } = useTheme();+ const remainingRouteColor = resolvedTheme === "dark" ? "#9ca3af" : "#6b7280";useEffect(() => {async function fetchRoute() {@@ -186,17 +189,17 @@ export default function Page() {<div className="relative h-[400px] overflow-hidden rounded-xl shadow-sm md:h-full"><Maploading={loading}- center={[-122.435, 37.696]}- zoom={12}+ center={[-122.4263, 37.756]}+ zoom={13.6}minZoom={10}maxZoom={16}><MapRouteid="delivery-full-route"coordinates={routeData?.coordinates ?? []}- color="#5b6572"+ color={remainingRouteColor}width={5.2}- opacity={0.3}+ opacity={0.5}interactive={false}/><MapRoute@@ -215,7 +218,7 @@ export default function Page() {offset={[0, 10]}><MarkerContent>- <div className="relative grid size-9 place-items-center rounded-full bg-emerald-500 dark:bg-emerald-600">+ <div className="relative grid size-9 place-items-center rounded-full border-2 border-white bg-blue-500 shadow-md dark:bg-blue-600"><Truck className="size-4 text-white" /></div></MarkerContent>diff --git a/src/registry/blocks/uptime-monitor/components/edge-node-marker.tsx b/src/registry/blocks/uptime-monitor/components/edge-node-marker.tsxindex 0a341a5..d0fc99e 100644--- a/src/registry/blocks/uptime-monitor/components/edge-node-marker.tsx+++ b/src/registry/blocks/uptime-monitor/components/edge-node-marker.tsx@@ -23,13 +23,14 @@ export function EdgeNodeMarker({ node }: EdgeNodeMarkerProps) {/></div></MarkerContent>- <MarkerTooltip offset={10} className="bg-popover min-w-28 border p-2">+ <MarkerTooltip+ offset={10}+ className="bg-popover text-popover-foreground min-w-28 border p-2"+ ><div className="flex items-center gap-1.5"><span className={cn("size-1.5 rounded-full", meta.dot)} />- <span className="text-foreground text-[11px] font-medium">- {node.city}- </span>- <span className="text-muted-foreground ml-auto font-mono text-[10px] uppercase">+ <span className="text-[11px] font-medium">{node.city}</span>+ <span className="text-muted-foreground ml-auto font-mono text-[11px] uppercase">{node.id}</span></div>diff --git a/src/registry/blocks/uptime-monitor/page.tsx b/src/registry/blocks/uptime-monitor/page.tsxindex 1a3e009..a1e9726 100644--- a/src/registry/blocks/uptime-monitor/page.tsx+++ b/src/registry/blocks/uptime-monitor/page.tsx@@ -21,7 +21,6 @@ export default function Page() {scrollZoom={false}dragRotate={false}pitchWithRotate={false}- attributionControl={false}><MapGeoJSON data={WORLD_GEOJSON} linePaint={false} />