Public
Edited
Nov 15, 2023
Insert cell
Insert cell
viewof map = {
const container = html`<div style="height:600px;">`;
yield container; // Give the container dimensions.
const map = container.value = new mapboxgl.Map({
container,
center: [-73.9944789, 40.7353297],
zoom: 15,
style: "mapbox://styles/mapbox/streets-v11",
scrollZoom: false
});

// const data = [{address: "63 Fifth Ave", lat: 40.7354741, long: -73.993774}, {address: "16 E 16th St", lat: 40.7368412, long: -73.9917407}, {address: "2 W 13th St", lat: 40.7353701, long: -73.9945167}]

for (const element of data) {
const thisMarker = new mapboxgl.Marker()
.setLngLat([element.long, element.lat])
.addTo(map);
}
invalidation.then(() => map.remove());
}
Insert cell
data = [{address: "63 Fifth Ave", lat: 40.7354741, long: -73.993774}, {address: "16 E 16th St", lat: 40.7368412, long: -73.9917407}, {address: "2 W 13th St", lat: 40.7353701, long: -73.9945167}]
Insert cell
// You’ll need to replace this with your own MapBox token.
// See https://www.mapbox.com/help/how-access-tokens-work/
accessToken = "pk.eyJ1IjoibW9sbGllbWFyaWUiLCJhIjoiY2txNXF0Mmw5MTVvdDJ3b2N3bHhobXN6aCJ9.ztC4Av-WFMynvpwyFgUiGw"
Insert cell
mapboxgl = {
const gl = await require("mapbox-gl@1");
if (!gl.accessToken) {
gl.accessToken = accessToken;
const href = await require.resolve("mapbox-gl@1/dist/mapbox-gl.css");
document.head.appendChild(html`<link href=${href} rel=stylesheet>`);
}
return gl;
}
Insert cell
viewof d = Inputs.select(days, {label: "Days"})
Insert cell
days = ["Sundays", "Mondays", "Tuesdays", "Wednesdays", "Thursdays", "Fridays", "Saturdays"]
Insert cell
d
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