leaflet
Build interactive maps with Leaflet.js. Use when a user asks to create map-based applications, add markers and popups, draw shapes, handle geolocation, or integrate tile layers in web applications.
What this skill does
# Leaflet โ Lightweight Open-Source Maps
## Overview
You are an expert in Leaflet, the lightweight open-source JavaScript library for interactive maps. You help developers build map-based applications using OpenStreetMap tiles (free, no API key), custom markers, GeoJSON layers, clustering, and React integration via react-leaflet.
## Instructions
### React Integration
```tsx
import { MapContainer, TileLayer, Marker, Popup, GeoJSON, useMap } from "react-leaflet";
import MarkerClusterGroup from "react-leaflet-cluster";
import "leaflet/dist/leaflet.css";
function StoreMap({ stores }) {
return (
<MapContainer center={[40.75, -73.98]} zoom={12}
style={{ height: "100vh", width: "100%" }}>
<TileLayer
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
attribution='© OpenStreetMap contributors'
/>
{/* Cluster markers when zoomed out */}
<MarkerClusterGroup>
{stores.map((store) => (
<Marker key={store.id} position={[store.lat, store.lng]}>
<Popup>
<h3>{store.name}</h3>
<p>{store.address}</p>
<p>Hours: {store.hours}</p>
</Popup>
</Marker>
))}
</MarkerClusterGroup>
</MapContainer>
);
}
// GeoJSON boundaries (neighborhoods, delivery zones)
function DeliveryZones({ zones }) {
return (
<MapContainer center={[40.75, -73.98]} zoom={11}>
<TileLayer url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" />
<GeoJSON
data={zones}
style={(feature) => ({
fillColor: feature.properties.active ? "#22c55e" : "#ef4444",
weight: 2,
opacity: 0.8,
fillOpacity: 0.3,
})}
onEachFeature={(feature, layer) => {
layer.bindPopup(`
<b>${feature.properties.name}</b><br/>
Orders: ${feature.properties.orderCount}<br/>
Avg delivery: ${feature.properties.avgDeliveryMin} min
`);
}}
/>
</MapContainer>
);
}
```
### Custom Icons and Controls
```tsx
import L from "leaflet";
// Custom marker icon
const storeIcon = new L.Icon({
iconUrl: "/icons/store-pin.png",
iconSize: [32, 32],
iconAnchor: [16, 32],
popupAnchor: [0, -32],
});
// Custom map control (e.g., "Locate Me" button)
function LocateControl() {
const map = useMap();
return (
<button
className="leaflet-control"
onClick={() => map.locate({ setView: true, maxZoom: 16 })}
>
๐ My Location
</button>
);
}
```
## Installation
```bash
npm install leaflet react-leaflet
npm install react-leaflet-cluster # Marker clustering
npm install @types/leaflet # TypeScript types
```
## Examples
**Example 1: User asks to set up leaflet**
User: "Help me set up leaflet for my project"
The agent should:
1. Check system requirements and prerequisites
2. Install or configure leaflet
3. Set up initial project structure
4. Verify the setup works correctly
**Example 2: User asks to build a feature with leaflet**
User: "Create a dashboard using leaflet"
The agent should:
1. Scaffold the component or configuration
2. Connect to the appropriate data source
3. Implement the requested feature
4. Test and validate the output
## Guidelines
1. **Free tiles** โ Use OpenStreetMap tiles (no API key, no cost); switch to Mapbox/Stadia for custom styling
2. **Marker clustering** โ Use `react-leaflet-cluster` for 100+ markers; prevents visual clutter and improves performance
3. **GeoJSON for regions** โ Use GeoJSON layers for boundaries, zones, and polygons; style dynamically based on data
4. **Lazy load** โ Leaflet CSS and JS are ~40KB; lazy load the map component for better initial page load
5. **SSR compatibility** โ Leaflet requires `window`; use `dynamic(() => import("./Map"), { ssr: false })` in Next.js
6. **Tile caching** โ Use service workers to cache map tiles for offline support in PWAs
7. **Event handling** โ Use `useMapEvents` hook for click, zoom, move events; build interactive experiences
8. **Lightweight alternative** โ At 42KB (gzipped), Leaflet is 5x smaller than Mapbox GL JS; choose Leaflet when you don't need 3D or custom styles
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.