Skip to content

Commit

Permalink
Add example
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Kuethe committed May 1, 2024
1 parent aebf065 commit 10bf762
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .examples/testapp.py
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)

0 comments on commit 10bf762

Please sign in to comment.