-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Stefan Kuethe
committed
May 1, 2024
1 parent
aebf065
commit 10bf762
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import webbrowser | ||
|
||
from maplibre import Layer, LayerType, MapOptions | ||
from maplibre.controls import FullscreenControl | ||
from maplibre.ipywidget import MapWidget as Map | ||
from maplibre.sources import GeoJSONSource | ||
|
||
vancouver_blocks = GeoJSONSource( | ||
data="https://raw.githubusercontent.com/visgl/deck.gl-data/master/examples/geojson/vancouver-blocks.json", | ||
) | ||
|
||
map_options = MapOptions( | ||
center=(-123.1256, 49.24658), | ||
zoom=12, | ||
hash=True, | ||
pitch=35, | ||
) | ||
|
||
m = Map(map_options) | ||
m.use_message_queue() | ||
m.add_control(FullscreenControl()) | ||
m.add_layer( | ||
Layer( | ||
type=LayerType.LINE, | ||
source=vancouver_blocks, | ||
paint={"line-color": "white"}, | ||
) | ||
) | ||
|
||
temp_file = "/tmp/pymaplibregl.html" | ||
|
||
with open(temp_file, "w") as f: | ||
f.write(m.to_html(style="height: 800px;")) | ||
|
||
webbrowser.open(temp_file) |