gmaprium 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- gmaprium-0.1.0/.gitignore +18 -0
- gmaprium-0.1.0/LICENSE +21 -0
- gmaprium-0.1.0/MANIFEST.in +14 -0
- gmaprium-0.1.0/PKG-INFO +183 -0
- gmaprium-0.1.0/README.md +149 -0
- gmaprium-0.1.0/examples/example.ipynb +131 -0
- gmaprium-0.1.0/examples/example.py +101 -0
- gmaprium-0.1.0/examples/folium_extension.py +102 -0
- gmaprium-0.1.0/examples/streamlit_app.py +47 -0
- gmaprium-0.1.0/pyproject.toml +83 -0
- gmaprium-0.1.0/src/gmaprium/__init__.py +21 -0
- gmaprium-0.1.0/src/gmaprium/elements.py +692 -0
- gmaprium-0.1.0/src/gmaprium/streamlit.py +40 -0
- gmaprium-0.1.0/src/gmaprium/tiles.py +58 -0
- gmaprium-0.1.0/tests/test_elements.py +198 -0
- gmaprium-0.1.0/tests/test_streamlit.py +50 -0
- gmaprium-0.1.0/tests/test_tiles.py +31 -0
gmaprium-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Kentaro Aoki
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
include LICENSE
|
|
2
|
+
include README.md
|
|
3
|
+
include pyproject.toml
|
|
4
|
+
recursive-include src *.py
|
|
5
|
+
recursive-include tests *.py
|
|
6
|
+
recursive-include examples *.py
|
|
7
|
+
recursive-include examples *.ipynb
|
|
8
|
+
global-exclude __pycache__/*
|
|
9
|
+
global-exclude *.py[cod]
|
|
10
|
+
global-exclude .pytest_cache/*
|
|
11
|
+
exclude examples/*.html
|
|
12
|
+
exclude apm.yml
|
|
13
|
+
exclude apm.lock.yaml
|
|
14
|
+
recursive-exclude apm_modules *
|
gmaprium-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: gmaprium
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Folium-style Python helpers for rendering Google Maps.
|
|
5
|
+
Project-URL: Homepage, https://github.com/KentaroAOKI/gmaprium
|
|
6
|
+
Project-URL: Repository, https://github.com/KentaroAOKI/gmaprium
|
|
7
|
+
Project-URL: Issues, https://github.com/KentaroAOKI/gmaprium/issues
|
|
8
|
+
Author: Kentaro
|
|
9
|
+
License: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: folium,geojson,google-maps,heatmap,maps,streamlit
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Topic :: Scientific/Engineering :: GIS
|
|
24
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
25
|
+
Requires-Python: >=3.9
|
|
26
|
+
Requires-Dist: jinja2>=3.1
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: build>=1.2; extra == 'dev'
|
|
29
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
30
|
+
Requires-Dist: twine>=5; extra == 'dev'
|
|
31
|
+
Provides-Extra: streamlit
|
|
32
|
+
Requires-Dist: streamlit>=1.30; extra == 'streamlit'
|
|
33
|
+
Description-Content-Type: text/markdown
|
|
34
|
+
|
|
35
|
+
# gmaprium
|
|
36
|
+
|
|
37
|
+
Folium-style Python helpers for rendering Google Maps HTML.
|
|
38
|
+
|
|
39
|
+
gmaprium can be used to create standalone HTML maps, display maps in Jupyter Notebook, add Google tile layers to existing Folium maps, and embed maps in Streamlit apps.
|
|
40
|
+
|
|
41
|
+
## Installation
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
pip install gmaprium
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Usage
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
from gmaprium import GeoJson, HeatMap, LayerControl, Map, Marker, Polygon
|
|
51
|
+
|
|
52
|
+
m = Map(
|
|
53
|
+
location=[35.6812, 139.7671],
|
|
54
|
+
zoom_start=12,
|
|
55
|
+
api_key="YOUR_GOOGLE_MAPS_API_KEY",
|
|
56
|
+
map_type="roadmap",
|
|
57
|
+
height="500px",
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
Marker([35.6812, 139.7671], popup="Tokyo Station", tooltip="Tokyo", name="Stations").add_to(m)
|
|
61
|
+
Polygon(
|
|
62
|
+
[[35.70, 139.70], [35.70, 139.82], [35.62, 139.82], [35.62, 139.70]],
|
|
63
|
+
name="Area",
|
|
64
|
+
).add_to(m)
|
|
65
|
+
HeatMap([[35.6812, 139.7671, 2], [35.6895, 139.6917, 1]], name="Heat").add_to(m)
|
|
66
|
+
LayerControl().add_to(m)
|
|
67
|
+
|
|
68
|
+
# Full HTML document.
|
|
69
|
+
m.save("map.html")
|
|
70
|
+
|
|
71
|
+
# Embeddable HTML fragment for web apps.
|
|
72
|
+
html = m.render_fragment()
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
You can also pass the API key with the `GOOGLE_MAPS_API_KEY` environment variable.
|
|
76
|
+
|
|
77
|
+
Markers use Google's `AdvancedMarkerElement`. If you add markers without passing `map_id=...`, the renderer uses Google's `DEMO_MAP_ID` for local testing.
|
|
78
|
+
|
|
79
|
+
## Supported Elements
|
|
80
|
+
|
|
81
|
+
- `Map`
|
|
82
|
+
- `Marker`
|
|
83
|
+
- `Polyline`
|
|
84
|
+
- `Polygon`
|
|
85
|
+
- `Circle`
|
|
86
|
+
- `GeoJson`
|
|
87
|
+
- `HeatMap`
|
|
88
|
+
- `LayerControl`
|
|
89
|
+
|
|
90
|
+
`GeoJson` accepts GeoJSON dictionaries, JSON file paths, objects with `__geo_interface__`, and GeoPandas-like objects with `to_json()`.
|
|
91
|
+
|
|
92
|
+
`HeatMap` uses a canvas overlay instead of Google's deprecated JavaScript `HeatmapLayer`.
|
|
93
|
+
It ports the Leaflet.heat/simpleheat rendering model, including `radius`, `blur`, `min_opacity`, `max_zoom`, `max_value`, and `gradient`.
|
|
94
|
+
The defaults match Leaflet.heat/simpleheat on a typical OSM map: `radius=25`, `blur=15`, `min_opacity=0.05`, `max_zoom=18`, `max_value=1.0`, and the blue-cyan-lime-yellow-red gradient.
|
|
95
|
+
Lower zoom levels are intentionally faded by Leaflet.heat's `max_zoom - zoom` intensity scale. Set `max_zoom` closer to your initial zoom if the heat fades too quickly.
|
|
96
|
+
|
|
97
|
+
The legacy `google_tiles_url()` and `add_google_tiles()` helpers are still available for projects that want to add Google tile URLs to an existing Folium map.
|
|
98
|
+
|
|
99
|
+
## Notebook
|
|
100
|
+
|
|
101
|
+
In Jupyter Notebook, display the map by returning the `Map` object as the last expression in a cell.
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
import os
|
|
105
|
+
|
|
106
|
+
from gmaprium import HeatMap, LayerControl, Map, Marker
|
|
107
|
+
|
|
108
|
+
os.environ["GOOGLE_MAPS_API_KEY"] = "your-api-key"
|
|
109
|
+
|
|
110
|
+
m = Map(location=[35.6812, 139.7671], zoom_start=12, height="500px")
|
|
111
|
+
Marker([35.6812, 139.7671], popup="Tokyo Station", name="Markers").add_to(m)
|
|
112
|
+
HeatMap([[35.6812, 139.7671, 1.0]], name="Heat", max_zoom=14).add_to(m)
|
|
113
|
+
LayerControl().add_to(m)
|
|
114
|
+
|
|
115
|
+
m
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
You can also display explicitly:
|
|
119
|
+
|
|
120
|
+
```python
|
|
121
|
+
from IPython.display import HTML, display
|
|
122
|
+
|
|
123
|
+
display(HTML(m.render_fragment()))
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
The notebook example is available at `examples/example.ipynb`.
|
|
127
|
+
|
|
128
|
+
## Folium Extension
|
|
129
|
+
|
|
130
|
+
If you already use Folium, add Google tile layers to a `folium.Map` with `add_google_tiles()`.
|
|
131
|
+
|
|
132
|
+
```python
|
|
133
|
+
import folium
|
|
134
|
+
|
|
135
|
+
from gmaprium import add_google_tiles
|
|
136
|
+
|
|
137
|
+
m = folium.Map(location=[35.6812, 139.7671], zoom_start=12, tiles=None)
|
|
138
|
+
add_google_tiles(m, api_key="your-api-key", map_type="roadmap", name="Google Roadmap")
|
|
139
|
+
add_google_tiles(m, api_key="your-api-key", map_type="satellite", name="Google Satellite", show=False)
|
|
140
|
+
|
|
141
|
+
folium.LayerControl().add_to(m)
|
|
142
|
+
m.save("folium_google_tiles.html")
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
This Folium extension only adds Google tile layers. It does not enable the Google Maps JavaScript API renderer or gmaprium's `HeatMap`.
|
|
146
|
+
|
|
147
|
+
The Folium example is available at `examples/folium_extension.py`.
|
|
148
|
+
|
|
149
|
+
## Streamlit
|
|
150
|
+
|
|
151
|
+
Use `st_google_map()` to render a `gmaprium.Map` inside a Streamlit app.
|
|
152
|
+
|
|
153
|
+
```python
|
|
154
|
+
import os
|
|
155
|
+
|
|
156
|
+
import streamlit as st
|
|
157
|
+
|
|
158
|
+
from gmaprium import Map, Marker, st_google_map
|
|
159
|
+
|
|
160
|
+
api_key = os.environ["GOOGLE_MAPS_API_KEY"]
|
|
161
|
+
|
|
162
|
+
m = Map(location=[35.6812, 139.7671], zoom_start=12, api_key=api_key, height="600px")
|
|
163
|
+
Marker([35.6812, 139.7671], popup="Tokyo Station").add_to(m)
|
|
164
|
+
|
|
165
|
+
st_google_map(m)
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Install the optional dependency and run the example app:
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
python -m pip install -e ".[dev,streamlit]"
|
|
172
|
+
export GOOGLE_MAPS_API_KEY="your-api-key"
|
|
173
|
+
streamlit run examples/streamlit_app.py
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
The Streamlit example is available at `examples/streamlit_app.py`.
|
|
177
|
+
|
|
178
|
+
## Development
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
python -m pip install -e ".[dev]"
|
|
182
|
+
pytest
|
|
183
|
+
```
|
gmaprium-0.1.0/README.md
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# gmaprium
|
|
2
|
+
|
|
3
|
+
Folium-style Python helpers for rendering Google Maps HTML.
|
|
4
|
+
|
|
5
|
+
gmaprium can be used to create standalone HTML maps, display maps in Jupyter Notebook, add Google tile layers to existing Folium maps, and embed maps in Streamlit apps.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install gmaprium
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
from gmaprium import GeoJson, HeatMap, LayerControl, Map, Marker, Polygon
|
|
17
|
+
|
|
18
|
+
m = Map(
|
|
19
|
+
location=[35.6812, 139.7671],
|
|
20
|
+
zoom_start=12,
|
|
21
|
+
api_key="YOUR_GOOGLE_MAPS_API_KEY",
|
|
22
|
+
map_type="roadmap",
|
|
23
|
+
height="500px",
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
Marker([35.6812, 139.7671], popup="Tokyo Station", tooltip="Tokyo", name="Stations").add_to(m)
|
|
27
|
+
Polygon(
|
|
28
|
+
[[35.70, 139.70], [35.70, 139.82], [35.62, 139.82], [35.62, 139.70]],
|
|
29
|
+
name="Area",
|
|
30
|
+
).add_to(m)
|
|
31
|
+
HeatMap([[35.6812, 139.7671, 2], [35.6895, 139.6917, 1]], name="Heat").add_to(m)
|
|
32
|
+
LayerControl().add_to(m)
|
|
33
|
+
|
|
34
|
+
# Full HTML document.
|
|
35
|
+
m.save("map.html")
|
|
36
|
+
|
|
37
|
+
# Embeddable HTML fragment for web apps.
|
|
38
|
+
html = m.render_fragment()
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
You can also pass the API key with the `GOOGLE_MAPS_API_KEY` environment variable.
|
|
42
|
+
|
|
43
|
+
Markers use Google's `AdvancedMarkerElement`. If you add markers without passing `map_id=...`, the renderer uses Google's `DEMO_MAP_ID` for local testing.
|
|
44
|
+
|
|
45
|
+
## Supported Elements
|
|
46
|
+
|
|
47
|
+
- `Map`
|
|
48
|
+
- `Marker`
|
|
49
|
+
- `Polyline`
|
|
50
|
+
- `Polygon`
|
|
51
|
+
- `Circle`
|
|
52
|
+
- `GeoJson`
|
|
53
|
+
- `HeatMap`
|
|
54
|
+
- `LayerControl`
|
|
55
|
+
|
|
56
|
+
`GeoJson` accepts GeoJSON dictionaries, JSON file paths, objects with `__geo_interface__`, and GeoPandas-like objects with `to_json()`.
|
|
57
|
+
|
|
58
|
+
`HeatMap` uses a canvas overlay instead of Google's deprecated JavaScript `HeatmapLayer`.
|
|
59
|
+
It ports the Leaflet.heat/simpleheat rendering model, including `radius`, `blur`, `min_opacity`, `max_zoom`, `max_value`, and `gradient`.
|
|
60
|
+
The defaults match Leaflet.heat/simpleheat on a typical OSM map: `radius=25`, `blur=15`, `min_opacity=0.05`, `max_zoom=18`, `max_value=1.0`, and the blue-cyan-lime-yellow-red gradient.
|
|
61
|
+
Lower zoom levels are intentionally faded by Leaflet.heat's `max_zoom - zoom` intensity scale. Set `max_zoom` closer to your initial zoom if the heat fades too quickly.
|
|
62
|
+
|
|
63
|
+
The legacy `google_tiles_url()` and `add_google_tiles()` helpers are still available for projects that want to add Google tile URLs to an existing Folium map.
|
|
64
|
+
|
|
65
|
+
## Notebook
|
|
66
|
+
|
|
67
|
+
In Jupyter Notebook, display the map by returning the `Map` object as the last expression in a cell.
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
import os
|
|
71
|
+
|
|
72
|
+
from gmaprium import HeatMap, LayerControl, Map, Marker
|
|
73
|
+
|
|
74
|
+
os.environ["GOOGLE_MAPS_API_KEY"] = "your-api-key"
|
|
75
|
+
|
|
76
|
+
m = Map(location=[35.6812, 139.7671], zoom_start=12, height="500px")
|
|
77
|
+
Marker([35.6812, 139.7671], popup="Tokyo Station", name="Markers").add_to(m)
|
|
78
|
+
HeatMap([[35.6812, 139.7671, 1.0]], name="Heat", max_zoom=14).add_to(m)
|
|
79
|
+
LayerControl().add_to(m)
|
|
80
|
+
|
|
81
|
+
m
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
You can also display explicitly:
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
from IPython.display import HTML, display
|
|
88
|
+
|
|
89
|
+
display(HTML(m.render_fragment()))
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
The notebook example is available at `examples/example.ipynb`.
|
|
93
|
+
|
|
94
|
+
## Folium Extension
|
|
95
|
+
|
|
96
|
+
If you already use Folium, add Google tile layers to a `folium.Map` with `add_google_tiles()`.
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
import folium
|
|
100
|
+
|
|
101
|
+
from gmaprium import add_google_tiles
|
|
102
|
+
|
|
103
|
+
m = folium.Map(location=[35.6812, 139.7671], zoom_start=12, tiles=None)
|
|
104
|
+
add_google_tiles(m, api_key="your-api-key", map_type="roadmap", name="Google Roadmap")
|
|
105
|
+
add_google_tiles(m, api_key="your-api-key", map_type="satellite", name="Google Satellite", show=False)
|
|
106
|
+
|
|
107
|
+
folium.LayerControl().add_to(m)
|
|
108
|
+
m.save("folium_google_tiles.html")
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
This Folium extension only adds Google tile layers. It does not enable the Google Maps JavaScript API renderer or gmaprium's `HeatMap`.
|
|
112
|
+
|
|
113
|
+
The Folium example is available at `examples/folium_extension.py`.
|
|
114
|
+
|
|
115
|
+
## Streamlit
|
|
116
|
+
|
|
117
|
+
Use `st_google_map()` to render a `gmaprium.Map` inside a Streamlit app.
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
import os
|
|
121
|
+
|
|
122
|
+
import streamlit as st
|
|
123
|
+
|
|
124
|
+
from gmaprium import Map, Marker, st_google_map
|
|
125
|
+
|
|
126
|
+
api_key = os.environ["GOOGLE_MAPS_API_KEY"]
|
|
127
|
+
|
|
128
|
+
m = Map(location=[35.6812, 139.7671], zoom_start=12, api_key=api_key, height="600px")
|
|
129
|
+
Marker([35.6812, 139.7671], popup="Tokyo Station").add_to(m)
|
|
130
|
+
|
|
131
|
+
st_google_map(m)
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Install the optional dependency and run the example app:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
python -m pip install -e ".[dev,streamlit]"
|
|
138
|
+
export GOOGLE_MAPS_API_KEY="your-api-key"
|
|
139
|
+
streamlit run examples/streamlit_app.py
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
The Streamlit example is available at `examples/streamlit_app.py`.
|
|
143
|
+
|
|
144
|
+
## Development
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
python -m pip install -e ".[dev]"
|
|
148
|
+
pytest
|
|
149
|
+
```
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cells": [
|
|
3
|
+
{
|
|
4
|
+
"cell_type": "code",
|
|
5
|
+
"execution_count": null,
|
|
6
|
+
"id": "example-map",
|
|
7
|
+
"metadata": {},
|
|
8
|
+
"outputs": [],
|
|
9
|
+
"source": [
|
|
10
|
+
"import os\n",
|
|
11
|
+
"\n",
|
|
12
|
+
"from gmaprium import Circle, GeoJson, HeatMap, LayerControl, Map, Marker, Polygon, Polyline\n",
|
|
13
|
+
"\n",
|
|
14
|
+
"api_key = os.environ.get(\"GOOGLE_MAPS_API_KEY\")\n",
|
|
15
|
+
"if not api_key:\n",
|
|
16
|
+
" raise RuntimeError(\"Set GOOGLE_MAPS_API_KEY before running this notebook.\")\n",
|
|
17
|
+
"\n",
|
|
18
|
+
"m = Map(\n",
|
|
19
|
+
" location=[35.6812, 139.7671],\n",
|
|
20
|
+
" zoom_start=12,\n",
|
|
21
|
+
" api_key=api_key,\n",
|
|
22
|
+
" map_type=\"roadmap\",\n",
|
|
23
|
+
" height=\"600px\",\n",
|
|
24
|
+
")\n",
|
|
25
|
+
"\n",
|
|
26
|
+
"Marker(\n",
|
|
27
|
+
" [35.6812, 139.7671],\n",
|
|
28
|
+
" popup=\"Tokyo Station\",\n",
|
|
29
|
+
" tooltip=\"Tokyo Station\",\n",
|
|
30
|
+
" name=\"Markers\",\n",
|
|
31
|
+
").add_to(m)\n",
|
|
32
|
+
"\n",
|
|
33
|
+
"Polyline(\n",
|
|
34
|
+
" [[35.6812, 139.7671], [35.6895, 139.6917]],\n",
|
|
35
|
+
" color=\"#0b57d0\",\n",
|
|
36
|
+
" weight=4,\n",
|
|
37
|
+
" name=\"Route\",\n",
|
|
38
|
+
").add_to(m)\n",
|
|
39
|
+
"\n",
|
|
40
|
+
"Polygon(\n",
|
|
41
|
+
" [[35.7000, 139.7000], [35.7000, 139.8200], [35.6200, 139.8200], [35.6200, 139.7000]],\n",
|
|
42
|
+
" color=\"#188038\",\n",
|
|
43
|
+
" fill_color=\"#34a853\",\n",
|
|
44
|
+
" fill_opacity=0.18,\n",
|
|
45
|
+
" name=\"Area\",\n",
|
|
46
|
+
").add_to(m)\n",
|
|
47
|
+
"\n",
|
|
48
|
+
"Circle(\n",
|
|
49
|
+
" [35.6895, 139.6917],\n",
|
|
50
|
+
" radius=700,\n",
|
|
51
|
+
" color=\"#d93025\",\n",
|
|
52
|
+
" fill_color=\"#f28b82\",\n",
|
|
53
|
+
" fill_opacity=0.25,\n",
|
|
54
|
+
" name=\"Circle\",\n",
|
|
55
|
+
").add_to(m)\n",
|
|
56
|
+
"\n",
|
|
57
|
+
"GeoJson(\n",
|
|
58
|
+
" {\n",
|
|
59
|
+
" \"type\": \"FeatureCollection\",\n",
|
|
60
|
+
" \"features\": [\n",
|
|
61
|
+
" {\n",
|
|
62
|
+
" \"type\": \"Feature\",\n",
|
|
63
|
+
" \"properties\": {\"name\": \"Sample GeoJSON\"},\n",
|
|
64
|
+
" \"geometry\": {\n",
|
|
65
|
+
" \"type\": \"Polygon\",\n",
|
|
66
|
+
" \"coordinates\": [\n",
|
|
67
|
+
" [\n",
|
|
68
|
+
" [139.735, 35.675],\n",
|
|
69
|
+
" [139.755, 35.675],\n",
|
|
70
|
+
" [139.755, 35.690],\n",
|
|
71
|
+
" [139.735, 35.690],\n",
|
|
72
|
+
" [139.735, 35.675],\n",
|
|
73
|
+
" ]\n",
|
|
74
|
+
" ],\n",
|
|
75
|
+
" },\n",
|
|
76
|
+
" }\n",
|
|
77
|
+
" ],\n",
|
|
78
|
+
" },\n",
|
|
79
|
+
" name=\"GeoJSON\",\n",
|
|
80
|
+
" style_function=lambda feature: {\n",
|
|
81
|
+
" \"fillColor\": \"#fbbc04\",\n",
|
|
82
|
+
" \"fillOpacity\": 0.3,\n",
|
|
83
|
+
" \"strokeColor\": \"#f9ab00\",\n",
|
|
84
|
+
" \"strokeWeight\": 2,\n",
|
|
85
|
+
" },\n",
|
|
86
|
+
").add_to(m)\n",
|
|
87
|
+
"\n",
|
|
88
|
+
"HeatMap(\n",
|
|
89
|
+
" [\n",
|
|
90
|
+
" [35.6812, 139.7671, 1.0],\n",
|
|
91
|
+
" [35.6825, 139.7685, 0.95],\n",
|
|
92
|
+
" [35.6840, 139.7700, 0.9],\n",
|
|
93
|
+
" [35.6895, 139.6917, 0.85],\n",
|
|
94
|
+
" [35.6920, 139.6940, 0.8],\n",
|
|
95
|
+
" [35.6586, 139.7454, 0.8],\n",
|
|
96
|
+
" [35.6600, 139.7480, 0.75],\n",
|
|
97
|
+
" [35.7101, 139.8107, 0.85],\n",
|
|
98
|
+
" [35.7085, 139.8088, 0.8],\n",
|
|
99
|
+
" ],\n",
|
|
100
|
+
" name=\"Heat\",\n",
|
|
101
|
+
" max_zoom=14,\n",
|
|
102
|
+
").add_to(m)\n",
|
|
103
|
+
"\n",
|
|
104
|
+
"LayerControl().add_to(m)\n",
|
|
105
|
+
"\n",
|
|
106
|
+
"m\n"
|
|
107
|
+
]
|
|
108
|
+
}
|
|
109
|
+
],
|
|
110
|
+
"metadata": {
|
|
111
|
+
"kernelspec": {
|
|
112
|
+
"display_name": "py313",
|
|
113
|
+
"language": "python",
|
|
114
|
+
"name": "python3"
|
|
115
|
+
},
|
|
116
|
+
"language_info": {
|
|
117
|
+
"codemirror_mode": {
|
|
118
|
+
"name": "ipython",
|
|
119
|
+
"version": 3
|
|
120
|
+
},
|
|
121
|
+
"file_extension": ".py",
|
|
122
|
+
"mimetype": "text/x-python",
|
|
123
|
+
"name": "python",
|
|
124
|
+
"nbconvert_exporter": "python",
|
|
125
|
+
"pygments_lexer": "ipython3",
|
|
126
|
+
"version": "3.13.12"
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
"nbformat": 4,
|
|
130
|
+
"nbformat_minor": 5
|
|
131
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
from gmaprium import Circle, GeoJson, HeatMap, LayerControl, Map, Marker, Polygon, Polyline
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
api_key = os.environ.get("GOOGLE_MAPS_API_KEY", "YOUR_GOOGLE_MAPS_API_KEY")
|
|
10
|
+
output_path = Path(__file__).with_name("example.html")
|
|
11
|
+
|
|
12
|
+
m = Map(
|
|
13
|
+
location=[35.6812, 139.7671],
|
|
14
|
+
zoom_start=12,
|
|
15
|
+
api_key=api_key,
|
|
16
|
+
map_type="roadmap",
|
|
17
|
+
height="600px",
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
Marker(
|
|
21
|
+
[35.6812, 139.7671],
|
|
22
|
+
popup="Tokyo Station",
|
|
23
|
+
tooltip="Tokyo Station",
|
|
24
|
+
name="Markers",
|
|
25
|
+
).add_to(m)
|
|
26
|
+
|
|
27
|
+
Polyline(
|
|
28
|
+
[[35.6812, 139.7671], [35.6895, 139.6917]],
|
|
29
|
+
color="#0b57d0",
|
|
30
|
+
weight=4,
|
|
31
|
+
name="Route",
|
|
32
|
+
).add_to(m)
|
|
33
|
+
|
|
34
|
+
Polygon(
|
|
35
|
+
[[35.7000, 139.7000], [35.7000, 139.8200], [35.6200, 139.8200], [35.6200, 139.7000]],
|
|
36
|
+
color="#188038",
|
|
37
|
+
fill_color="#34a853",
|
|
38
|
+
fill_opacity=0.18,
|
|
39
|
+
name="Area",
|
|
40
|
+
).add_to(m)
|
|
41
|
+
|
|
42
|
+
Circle(
|
|
43
|
+
[35.6895, 139.6917],
|
|
44
|
+
radius=700,
|
|
45
|
+
color="#d93025",
|
|
46
|
+
fill_color="#f28b82",
|
|
47
|
+
fill_opacity=0.25,
|
|
48
|
+
name="Circle",
|
|
49
|
+
).add_to(m)
|
|
50
|
+
|
|
51
|
+
GeoJson(
|
|
52
|
+
{
|
|
53
|
+
"type": "FeatureCollection",
|
|
54
|
+
"features": [
|
|
55
|
+
{
|
|
56
|
+
"type": "Feature",
|
|
57
|
+
"properties": {"name": "Sample GeoJSON"},
|
|
58
|
+
"geometry": {
|
|
59
|
+
"type": "Polygon",
|
|
60
|
+
"coordinates": [
|
|
61
|
+
[
|
|
62
|
+
[139.735, 35.675],
|
|
63
|
+
[139.755, 35.675],
|
|
64
|
+
[139.755, 35.690],
|
|
65
|
+
[139.735, 35.690],
|
|
66
|
+
[139.735, 35.675],
|
|
67
|
+
]
|
|
68
|
+
],
|
|
69
|
+
},
|
|
70
|
+
}
|
|
71
|
+
],
|
|
72
|
+
},
|
|
73
|
+
name="GeoJSON",
|
|
74
|
+
style_function=lambda feature: {
|
|
75
|
+
"fillColor": "#fbbc04",
|
|
76
|
+
"fillOpacity": 0.3,
|
|
77
|
+
"strokeColor": "#f9ab00",
|
|
78
|
+
"strokeWeight": 2,
|
|
79
|
+
},
|
|
80
|
+
).add_to(m)
|
|
81
|
+
|
|
82
|
+
HeatMap(
|
|
83
|
+
[
|
|
84
|
+
[35.6812, 139.7671, 1.0],
|
|
85
|
+
[35.6825, 139.7685, 0.95],
|
|
86
|
+
[35.6840, 139.7700, 0.9],
|
|
87
|
+
[35.6895, 139.6917, 0.85],
|
|
88
|
+
[35.6920, 139.6940, 0.8],
|
|
89
|
+
[35.6586, 139.7454, 0.8],
|
|
90
|
+
[35.6600, 139.7480, 0.75],
|
|
91
|
+
{"location": [35.7101, 139.8107], "weight": 0.85},
|
|
92
|
+
{"location": [35.7085, 139.8088], "weight": 0.8},
|
|
93
|
+
],
|
|
94
|
+
name="Heat",
|
|
95
|
+
max_zoom=14,
|
|
96
|
+
).add_to(m)
|
|
97
|
+
|
|
98
|
+
LayerControl().add_to(m)
|
|
99
|
+
|
|
100
|
+
m.save(output_path)
|
|
101
|
+
print(f"Wrote {output_path}")
|