A Python library for creating interactive web maps, optimized for LLM-assisted development.
Encapsulates best practices for interactive web map development behind a predictable, composable API — so both you and your LLM produce correct code on the first try. Outputs a single HTML file powered by MapLibre GL JS.
Table of Contents
- Declarative API — composable
Map+ layers + sources + components. Describe what the map should show; the library handles how. - Single HTML output — standalone file with MapLibre GL JS; works via
file://when data is embedded. - Embedded mode — inline GeoJSON (optionally Geobuf + Gzip) so you can share one file.
- Comparison mode — before/after slider using the MapLibre compare plugin.
- Feature-state expressions — GPU-efficient dynamic styling (
fill_color,opacity) viasetFeatureState. - Extensible — custom JS/CSS/HTML injection,
embed_data()for arbitrary JSON. - Built-in attribution — automatic LLMaps branding with GitHub link (customizable or removable).
- LLM-friendly — predictable names, stable contracts; use
get_llm_context()for a compact reference in chat.
Available building blocks:
| Category | Classes |
|---|---|
| Layers | CircleLayer, FillLayer, H3Layer, VectorTileLayer, SymbolLayer |
| Sources | FileSource, ApiSource, VectorTileSource |
| Components | Legend, Popup, Sidebar, Search, FeatureSearch, Controls, BasemapSwitcher, Storytelling |
pip install llmapsCursor / Claude Code — both support the Agent Skills standard. Copy the repo's cursor-skill folder so the AI has full context when generating map code:
| Tool | Skills path |
|---|---|
| Cursor | ~/.cursor/skills/llmaps/SKILL.md |
| Claude Code | ~/.claude/skills/llmaps/SKILL.md |
On Windows use %USERPROFILE%\ instead of ~/. Create the folders if needed. The skill is picked up automatically on next launch. If you use either tool with this skill, you can skip the step below.
Context for other LLM chats: Run once in your project directory, then attach llmaps_context.md to the chat (e.g. @llmaps_context.md in Cursor):
python -c "import llmaps; open('llmaps_context.md','w').write(llmaps.get_llm_context())"from llmaps import Map
from llmaps.layers import CircleLayer
from llmaps.sources import FileSource
from llmaps.components import Legend, Popup, Controls
source = FileSource(id="points", path="data/points.geojson")
layer = CircleLayer(
id="points-layer",
source=source,
radius=6,
color="#3182bd",
opacity=0.8,
)
m = Map(center=[10.0, 50.0], zoom=4, title="My Map", tiles="osm")
m.add_layer(layer)
m.add_component(Legend(layer_labels={"points-layer": "Points"}))
m.add_component(Popup(fields=["name", "value"], field_labels={"name": "Name", "value": "Value"}))
m.add_component(Controls(zoom=True, scale=True))
m.auto_extent()
m.save("my_map.html")Compass is an AI-first workflow that helps you go from raw data to a working build_map.py with minimal prompting.
It is documentation-only and uses existing LLMaps APIs.
- Surveys your dataset (geometry, fields, stats, bbox).
- Asks a few focused questions about intent and style.
- Chooses a recipe and generates runnable map code.
- Refines colors, components, and interactions on request.
compass/README.md— overview and workflowcompass/decision-tree.md— recipe selection logiccompass/question-bank.md— adaptive interview promptscompass/recipes/—build_map.pytemplates with placeholders
- Implicit: ask naturally, for example
Create an interactive map from examples/real-world/cafes/data/paris_cafes.geojson. - Explicit: use
/llmaps.compass,/llmaps.compass-survey, or/llmaps.compass-refinein Cursor.
Explore interactive maps showcasing key features and capabilities: LLMaps Examples Gallery
| Example | Features | Data |
|---|---|---|
| Paris Cafes & Restaurants | CircleLayer, Search, FeatureSearch, BasemapSwitcher, Popup, Sidebar | OpenStreetMap Overpass |
| World Population | FillLayer, feature-state styling, Jenks classification, color ramps | Natural Earth |
| Earthquakes | CircleLayer, interpolate expressions, Jenks classification, temporal filtering | USGS Earthquake API |
| Pennsylvania Gerrymandering Story | FillLayer, Storytelling, comparison mode, custom overlays | PA election and district data |
| Example | Features | Data |
|---|---|---|
| Dashboard Primitives | Dashboard component, filter bridge events, lightweight integration pattern | Small embedded GeoJSON |
- MapLibre GL JS — frontend map rendering
- Jinja2 — HTML template engine
- Optional: H3, GeoPandas, Geobuf
| Criterion | Kepler.gl | Folium / ipyleaflet | Custom MapLibre/Leaflet | LLMaps |
|---|---|---|---|---|
| Ready-made components | ❌ | ✅ Full set: layers, legend, popup, sidebar, search, controls | ||
| LLM-friendly | ❌ | ✅ Clear API, stable contracts | ||
| H3 / aggregation | ✅ | ❌ | ✅ H3Layer | |
| Embedded (file://) | ❌ | ✅ embedded=True |
||
| Comparison (before/after) | ❌ | ❌ | ✅ enable_comparison |
|
| Single HTML output | ❌ | ✅ Possible | ✅ save / to_html |
|
| Customization | ✅ Good | ✅ Full | ✅ Full (config + templates + custom JS/CSS) | |
| Extensibility | ✅ Good (plugins, custom HTML/JS) | ✅ Full | ✅ Full (custom JS/CSS/HTML, embed_data(), templates) |
|
| No backend | ❌ | ✅ Often | ✅ Embedded mode |
When to use LLMaps: You want a single Python API to produce a standalone interactive map (especially with embedded data), with minimal boilerplate and good support for LLM-generated code.
When to choose something else: You need a full GIS UI (Kepler.gl), tight Jupyter-only integration (Folium/ipyleaflet), or a fully custom frontend stack (raw MapLibre/Leaflet with your own backend).
Python API → Config (to_dict()) → HTML (Jinja2) → Frontend (MapLibre GL JS + plugins)
Everything reduces to a serializable dict — no framework magic. The generator turns that config into one HTML file with inline or linked JS/CSS. See PHILOSOPHY.md for design principles and rationale.
- LLM context — run
python -c "import llmaps; open('llmaps_context.md','w').write(llmaps.get_llm_context())"and use @llmaps_context.md in chat for a compact API reference. - PHILOSOPHY.md — Concept, design principles, comparison with alternatives.
- CONSTITUTION.md — Development principles for meaningful public API changes.
- specs/README.md — Lightweight spec-driven workflow and templates for planning public features.
- docs/api/ — Map, layers, sources, components (parameters and examples).
- docs/recipes/ — Heatmap, comparison, embedded map, feature-state highlighting.
Use the tiles argument when creating the map:
| Key | Provider | Attribution |
|---|---|---|
"osm" |
OpenStreetMap (default) | © OpenStreetMap contributors |
"carto-light" |
Carto Light | © OpenStreetMap contributors, © CARTO |
"carto-dark" |
Carto Dark | © OpenStreetMap contributors, © CARTO |
"yandex" |
Yandex Maps | © Yandex Maps |
"2gis" |
2GIS | © 2GIS |
MIT. See LICENSE.
Sergey Abramov
See CONTRIBUTING.md.
For meaningful public API changes, use the lightweight spec workflow in specs/README.md before implementation starts.