Published
Edited
Jan 6, 2021
1 star
Insert cell
Insert cell
{
let container = html`<div style='height:400px;' />`;

// Give the container dimensions.
yield container;

// Create the \`map\` object with the mapboxgl.Map constructor, referencing
// the container div
let map = new mapboxgl.Map({
container,
center: [-73.61457, 45.524149],
zoom: 10,
style: "mapbox://styles/mapbox/streets-v9",
scrollZoom: false
});

if (showNavigationControl) {
map.addControl(new mapboxgl.NavigationControl(), "top-right");
}

// Be careful to clean up the map's resources using \`map.remove()\` whenever
// this cell is re-evaluated.
invalidation.then(() => map.remove());
}
Insert cell
Insert cell
Insert cell
Insert cell
viewof map = {
let container = html`<div style='height:400px;' />`;

// Give the container dimensions.
yield container;

// Create the \`map\` object with the mapboxgl.Map constructor, referencing
// the container div
let map = new mapboxgl.Map({
container,
center: [4.352731704711914, 50.846272321172954],
zoom: 4,
style: "mapbox://styles/mapbox/light-v9"
});

// Wait until the map loads.
map.on("load", () => {
container.value = map;
container.dispatchEvent(new CustomEvent("input"));
});
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
viewof centerpoint = {
let container = html`<div style='height:400px;' />`;

// Give the container dimensions.
yield container;

// Create the \`map\` object with the mapboxgl.Map constructor, referencing
// the container div
let map = new mapboxgl.Map({
container,
center: [4.352731704711914, 50.846272321172954],
zoom: 4,
style: "mapbox://styles/mapbox/light-v9"
});

map.on("mousemove", e => {
container.value = e.lngLat;
container.dispatchEvent(new CustomEvent("input"));
});
}
Insert cell
Insert cell
Insert cell
loadStyleSheet = () =>
html`<link href='https://unpkg.com/mapbox-gl@1.5.0/dist/mapbox-gl.css' rel='stylesheet' />`
Insert cell
mapboxgl = {
let mapboxgl = await require('mapbox-gl@1.5.0');
mapboxgl.accessToken =
'pk.eyJ1IjoibGlmZXdpbm5pbmciLCJhIjoiYWZyWnFjMCJ9.ksAPTz72HyEjF2AOMbRNvg';
return mapboxgl;
}
Insert cell
Insert cell
html`<style>
.labeled::after {
margin-left: 2em;
white-space: nowrap;
content: attr(aria-label);
}
</style>`
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more