Public
Edited
Feb 6, 2023
2 stars
Insert cell
Insert cell
Insert cell
Insert cell
viewof map = {
const container = html`<div style="height:400px;">`;
yield container; // Give the container dimensions.
const mapRef = container.value = new mapboxgl.Map({
container,
center: [0,0],
zoom: 1,
style: "mapbox://styles/mapbox/light-v10",
scrollZoom: false
});
invalidation.then(() => mapRef.remove());
yield container;
}
Insert cell
map
Insert cell
marker = {
const markerRef = new mapboxgl.Marker()
.setLngLat([0, 0])
.addTo(map);

// make sure we clean up the marker if we re-run this cell too!
invalidation.then(() => markerRef.remove());
return markerRef;
}
Insert cell
{
// make only this cell depend on changes to `longitude` cell
marker.setLngLat([longitude, latitude]);
}
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more