About mapcn
mapcn is a skill for adding MapLibre GL map components and full-page map blocks to React projects using shadcn CLI. It helps developers select suitable map patterns and install only the components or blocks needed.
Key features
- 01React map components
- 02Full-page map blocks
- 03shadcn CLI installation
- 04Markers, routes, arcs, and clusters
- 05GeoJSON layers and custom styles
Use cases
- 01Add a store locator to an app
- 02Display shipment routes and progress
- 03Visualize regional statistics on a map
- 04Show links between locations
Install
Copy the command and run it in a terminal.
npx skills add https:/ / github.com/ anmolsaini16/ mapcn --skill mapcnAfter installing, type/mapcnin Claude Code to confirm it loaded.
Bundled files
References and scripts installed along with SKILL.md.
references/blocks.mdcomponents.mdpatterns.mdDetails
From the project READMEmapcn
Map components for React that you install with the shadcn CLI. Everything lives in one file, components/ui/map.tsx, built on MapLibre GL and styled with the project's shadcn theme. Blocks are full pages (dashboards, trackers, locators) built from those components.
When the user hasn't named a map
If they ask what mapcn could do for their app, or where a map would fit:
- Read the stack (
package.json,components.json) and skim the pages and data models. - Suggest 2–4 places a map fits, most noticeable first. Tie each one to something real in their code and name what you'd use, for example:
- addresses or locations, leading to a Store Locator or markers with popups
- orders or shipments, leading to Delivery Tracker (
MapRoute+RouteProgress) - per-country or per-region stats, leading to Choropleth or Analytics Map
- links between places (flights, traffic, supply chains), leading to
MapArcor Logistics Network
- Install and build only what the user picks.
Before you start
- shadcn/ui and Tailwind CSS. Look for
components.json. If there isn't one, tell the user mapcn needs shadcn/ui and offer to runnpx shadcn@latest initfirst. - Already installed? Check
aliases.uiincomponents.json(usually@/components/ui) formap.tsx. If it's there, don't reinstall. Read it instead.
Install
npx shadcn@latest add @mapcn/map
That adds components/ui/map.tsx, installs maplibre-gl and adds a few popup and attribution styles to the global CSS. Blocks install the same way, npx shadcn@latest add @mapcn/<block>, and pull in the map component themselves. Block files install to Next.js App Router paths (app/<route>/page.tsx). In any other setup, move them and register the route: see references/blocks.md.
Never write or paste map.tsx by hand. If the CLI fails, read https://mapcn.dev/r/map.json, install the dependencies it lists, and report what went wrong.
Rules
- Give the map a height.
<Map>fills its parent, and a parent without a height shows nothing. Wrap it:<div className="h-[400px]">or<Card className="h-[320px] overflow-hidden p-0">. - Coordinates are
[longitude, latitude].center={[-74.006, 40.7128]}is New York. Markers takelongitudeandlatitudeprops. Swapping them is the most common bug. - Client components only.
map.tsxis already"use client". Any component that usesuseMap, refs or map event handlers needs it too. In Next.js, keep data fetching in a server component and pass the data down. - Props are documented in the installed
map.tsx. Every prop has a JSDoc comment. Read the types there and don't guess. Don't edit the file unless the user asks. - Routes don't fetch.
MapRouteonly draws the coordinates it's given;RouteProgressandRouteMarkergo inside it and work from that same line. Fetch directions (OSRM, Mapbox, Google) in the parent and pass[lng, lat][]down. See the OSRM example linked under Routes inreferences/components.md.MapGeoJSONandMapClusterLayertake a GeoJSON object or a URL. - Use theme colors in your own UI. Marker content, popups and overlays are plain React, so use
bg-background,text-muted-foreground,borderand so on. Data colors on lines and fills (MapRoute color, paint props) can be real colors. - Theme follows the app. The basemap switches light/dark from a
darkorlightclass or adata-themeattribute on<html>(next-themes works out of the box), falling back to the system preference. Passthemeonly to force one. - Raw MapLibre when you need it:
useMap()inside<Map>returns{ map, isLoaded }, or pass aref(MapRef) to<Map>. Wait forisLoadedbefore adding sources or layers, and remove them on cleanup.
Basemap Selection
- Use
<Map>withoutblankfor the default free CARTO basemap tiles. This is best for store locators, delivery tracking, logistics maps, address maps, and any UI where users need streets, place labels, or geographic context. - Use
<Map blank>for a transparent, tile-less canvas. Used alone it renders nothing; add your own layers such asMapGeoJSON,MapArc, markers, clusters, or custom MapLibre layers. This is best for choropleths, arc maps, dot maps, dashboards, and data visualizations where the data should define the geography. - If the user wants a blank map with only countries or country borders, use
<Map blank>with<MapGeoJSON data={WORLD_GEOJSON} />. For world countries, a Natural Earth GeoJSON source works well:https://cdn.jsdelivr.net/gh/nvkelso/[email protected]/geojson/ne_110m_admin_0_countries.geojson. Users can also provide their own GeoJSON URL or GeoJSON object toMapGeoJSON. - Use the
stylesprop for custom MapLibre-compatible style URLs or style objects, for example MapTiler, OpenFreeMap, CARTO, or a self-hosted style. Explicitstylesoverrideblank.
Components
Everything is imported from @/components/ui/map:
- Map:
Map,useMap - Controls:
MapControls - Markers:
MapMarker,MarkerContent,MarkerPopup,MarkerTooltip,MarkerLabel - Popups:
MapPopup - Routes:
MapRoute,RouteProgress,RouteMarker - Arcs:
MapArc - GeoJSON:
MapGeoJSON - Clusters:
MapClusterLayer
References
Read only what the task needs. Reading this from a URL instead of an installed skill? The same files are at https://raw.githubusercontent.com/AnmolSaini16/mapcn/main/skills/mapcn/references/.
references/components.md: every export with what it's for, its docs page and links to example sourcereferences/blocks.md: each block, what it shows, the files it adds and its install commandreferences/patterns.md: controlled viewport, fly-to, route fetching, custom layers, large datasets, Web Worker and CSP