AnyMap
A Python package for creating interactive maps with anywidget and JavaScript mapping libraries
- GitHub repo: https://github.com/opengeos/anymap
- Documentation: https://anymap.dev
- PyPI: https://pypi.org/project/anymap
- Conda-forge: https://anaconda.org/conda-forge/anymap
- Free software: MIT License
Features
- 🗺️ Interactive Maps: Create beautiful, interactive maps in Jupyter notebooks
- 🔄 Bidirectional Communication: Full Python ↔ JavaScript communication
- 📱 Multi-cell Support: Render maps in multiple notebook cells without conflicts
- 🎯 MapLibre Integration: Built-in support for MapLibre GL JS
- 🛠️ Extensible: Easy to add support for other mapping libraries
- 🚀 Familiar API: Similar to ipyleaflet for easy migration
Installation
pip install anymap
conda install -c conda-forge anymap
Quick Start
from anymap import MapLibreMap
# Create a basic map
m = MapLibreMap(
center=[-122.4194, 37.7749], # San Francisco
zoom=12,
height="600px"
)
m
Basic Usage
Creating Maps
from anymap import MapLibreMap
# Create a map with custom settings
m = MapLibreMap(
center=[-74.0060, 40.7128], # New York City
zoom=13,
height="500px",
bearing=45, # Map rotation
pitch=60 # 3D tilt
)
Adding Markers
# Add a marker with popup and custom styling
m.add_marker(
lat=40.7128,
lng=-74.0060,
popup="<h3>New York City</h3><p>The Big Apple</p>",
options={
"color": "#ff5722",
"draggable": True,
}
)
Working with GeoJSON
# Add GeoJSON data
geojson_data = {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [-74.0060, 40.7128]
},
"properties": {"name": "NYC"}
}
]
}
m.add_geojson_layer(
layer_id="cities",
geojson_data=geojson_data,
layer_type="circle",
paint={
"circle-radius": 8,
"circle-color": "#ff0000"
}
)
Event Handling
def handle_click(event):
lat, lng = event['lngLat']
print(f"Clicked at: {lat:.4f}, {lng:.4f}")
m.on_map_event('click', handle_click)
Dynamic Updates
# Change map properties
m.set_center(-0.1278, 51.5074) # London
m.set_zoom(14)
# Animate to a location
m.fly_to(2.3522, 48.8566, zoom=15) # Paris
Multi-Cell Rendering
AnyMap is designed to work seamlessly across multiple notebook cells:
# Cell 1
m = MapLibreMap(center=[0, 0], zoom=2)
m
# Cell 2 - Same map instance
m.add_marker(0, 0, popup="Origin")
# Cell 3 - Display again
m
Advanced Features
Layer Management
# Add and remove layers
m.add_source("my-source", {
"type": "geojson",
"data": geojson_data
})
m.add_layer("my-layer", {
"id": "my-layer",
"type": "circle",
"source": "my-source",
"paint": {"circle-radius": 5}
})
# Remove layers
m.remove_layer("my-layer")
m.remove_source("my-source")
Custom JavaScript Methods
# Call any MapLibre GL JS method
m.call_js_method('easeTo', {
'center': [lng, lat],
'zoom': 14,
'duration': 2000
})
Examples
Check out the example notebooks in the examples/ directory:
basic_usage.ipynb- Basic map creation and interactionadvanced_features.ipynb- Advanced layer management and stylingmulti_cell_test.ipynb- Multi-cell rendering tests
Development
To set up for development:
git clone https://github.com/opengeos/anymap.git
cd anymap
pip install -e .
Run tests:
python -m unittest tests.test_anymap -v
Roadmap
- ✅ MapLibre GL JS backend
- ✅ Mapbox GL JS backend
- ✅ Leaflet backend
- ✅ OpenLayers backend
- ✅ DeckGL backend
- ✅ KeplerGL backend
- 🔲 Cesium backend
- 🔲 Potree backend
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Metadata
Release files for anymap 0.12.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| anymap-0.12.0.tar.gz | 251.3 kB | Without provenance | Details for anymap-0.12.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| anymap-0.12.0-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for anymap-0.12.0-py2.py3-none-any.whl |
Total release size: 525.0 kB
Release files / anymap-0.12.0.tar.gz
| Download URL | anymap-0.12.0.tar.gz |
|---|---|
| Size | 251.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b7faeb40827921a18581aeff820328ea5c34e2e09d581ff3765e3babb06036c3
|
|
BLAKE2b-256 checksum How to use checksums |
0224936f467727fead2c132a1ad40b0026e7801adda0a8c2d668e8f93f1ceb07
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Release files / anymap-0.12.0-py2.py3-none-any.whl
| Download URL | anymap-0.12.0-py2.py3-none-any.whl |
|---|---|
| Size | 273.8 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
dc2015a0a2f5ec28dbce33b9fce27fc97b1f4da8130a516a71a5ad3309697a1f
|
|
BLAKE2b-256 checksum How to use checksums |
e718f899fd1930808751e0072fea7e0f7660b673338d2aed44ede76af0199d55
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Security for anymap 0.12.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.