TypeScript Examples¶
anymap-ts is built with TypeScript, providing type-safe interactive maps through the anywidget framework. This section demonstrates how to use the TypeScript renderers directly.
Architecture Overview¶
anymap-ts uses the anywidget pattern for Python-JavaScript communication:
1 | |
Each map type has a corresponding TypeScript renderer that:
- Receives a
modelobject for state synchronization with Python - Receives an
elDOM element for rendering - Handles method calls from Python via
_js_calls - Sends events back to Python via
_js_events
Available Renderers¶
| Renderer | Library | Source File |
|---|---|---|
MapLibreRenderer |
MapLibre GL JS | src/maplibre/MapLibreRenderer.ts |
LeafletRenderer |
Leaflet | src/leaflet/LeafletRenderer.ts |
MapboxRenderer |
Mapbox GL JS | src/mapbox/MapboxRenderer.ts |
CesiumWidget |
Cesium | src/cesium/index.ts |
DeckGLRenderer |
DeckGL + MapLibre | src/deckgl/DeckGLRenderer.ts |
OpenLayersRenderer |
OpenLayers | src/openlayers/OpenLayersRenderer.ts |
PotreeWidget |
Potree | src/potree/index.ts |
KeplerGLWidget |
KeplerGL | src/keplergl/index.ts |
Examples by Category¶
Basic Mapping¶
- MapLibre GL JS - Vector maps with drawing and layer control
- Leaflet - Lightweight, mobile-friendly maps
- Mapbox GL JS - Commercial vector maps (requires token)
- OpenLayers - Feature-rich with WMS/WMTS support
3D Visualization¶
- Cesium - 3D globe with terrain and 3D Tiles
GPU-Accelerated Layers¶
- DeckGL - ScatterplotLayer, HexagonLayer, HeatmapLayer, ArcLayer
Scientific Data¶
- COG Layer - Cloud Optimized GeoTIFF visualization
- Zarr Layer - Multi-dimensional dataset visualization
Specialized Viewers¶
Core Types¶
The anywidget communication types are defined in src/types/anywidget.ts:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | |
TypeScript Source Files¶
Standalone TypeScript example files are available in src/examples/:
| File | Description |
|---|---|
maplibre.ts |
MapLibre with draw and layer control |
leaflet.ts |
Leaflet with markers and GeoJSON |
mapbox.ts |
Mapbox GL JS example |
cesium.ts |
Cesium 3D globe |
deckgl.ts |
DeckGL visualization layers |
openlayers.ts |
OpenLayers mapping |
potree.ts |
Potree point cloud viewer |
keplergl.ts |
KeplerGL data exploration |
cog_layer.ts |
COG layer visualization |
zarr_layer.ts |
Zarr layer visualization |