Create beautiful JavaScript maps with one line of Python
Project description
Mapkick.py
Create beautiful JavaScript maps with one line of Python. No more fighting with mapping libraries!
Installation
Run:
pip install mapkick
Mapkick uses Mapbox GL JS v1. To use tiles from Mapbox, create a Mapbox account to get an access token and set MAPBOX_ACCESS_TOKEN
in your environment.
Django
Add to INSTALLED_APPS
in settings.py
INSTALLED_APPS = [
"mapkick.django",
# ...
]
Load the JavaScript
{% load static %}
<script src="{% static 'mapkick.bundle.js' %}"></script>
Create a map in a view
from mapkick.django import Map
def index(request):
map = Map([{'latitude': 37.7829, 'longitude': -122.4190}])
return render(request, 'home/index.html', {'map': map})
And add it to the template
{{ map }}
Maps
Point map
Map([{'latitude': 37.7829, 'longitude': -122.4190}])
Area map (experimental)
AreaMap([{'geometry': {'type': 'Polygon', 'coordinates': ...}}])
Data
Data can be an array
Map([{'latitude': 37.7829, 'longitude': -122.4190}])
Or a URL that returns JSON (same format as above)
Map('/restaurants')
Point Map
Use latitude
or lat
for latitude and longitude
, lon
, or lng
for longitude
You can specify a label and tooltip for each data point
{
'latitude': ...,
'longitude': ...,
'label': 'Hot Chicken Takeover',
'tooltip': '5 stars'
}
Area Map
Use geometry
with a GeoJSON Polygon
or MultiPolygon
You can specify a label and tooltip for each data point
{
'geometry': {'type': 'Polygon', 'coordinates': ...},
'label': 'Hot Chicken Takeover',
'tooltip': '5 stars'
}
Options
Width and height
Map(data, width='800px', height='500px')
Marker color
Map(data, markers={'color': '#f84d4d'})
Show tooltips on click instead of hover
Map(data, tooltips={'hover': False})
Allow HTML in tooltips (must sanitize manually)
Map(data, tooltips={'html': True})
Map style
Map(data, style='mapbox://styles/mapbox/outdoors-v12')
Zoom and controls
Map(data, zoom=15, controls=True)
Refresh data from a remote source every n
seconds
Map(url, refresh=60)
History
View the changelog
Contributing
Everyone is encouraged to help improve this project. Here are a few ways you can help:
- Report bugs
- Fix bugs and submit pull requests
- Write, clarify, or fix documentation
- Suggest or add new features
To get started with development:
git clone https://github.com/ankane/mapkick.py.git
cd mapkick.py
pip install -r requirements.txt
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for mapkick-0.1.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6596bb7f6b2869910389cf8a99b9cfca43160f5ae54b0f74ee202d9adddeb33e |
|
MD5 | d74d86f001d74c661ed21022a5c14fb1 |
|
BLAKE2b-256 | 68810957e97839dfb74cc2e14e5dab21acfed50b5117ca55be82c0ea5ff49d13 |