Public
Edited
Apr 4, 2024
1 fork
1 star
Insert cell
Insert cell
Insert cell
container = html`<div style="height:600px;">`
Insert cell
map = {
const map = L.map(container).setView([0, -0], 2);
L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", {
attribution: "&copy; <a href=https://www.openstreetmap.org/copyright>OpenStreetMap</a> contributors"
}).addTo(map);

invalidation.then(() => map.remove());
return map;
}
Insert cell
Insert cell
quakesLayer = {
const quakes = await d3.json('https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/1.0_week.geojson');
// See: https://leafletjs.com/examples/geojson/
var geojsonMarkerOptions = {
radius: 3,
fillColor: "crimson",
color: "#000",
weight: 1,
opacity: 1,
fillOpacity: 0.8
};
// See: https://leafletjs.com/reference-1.4.0.html#geojson-pointtolayer
var pointToLayer = function (feature, latlng) {
return L.circleMarker(latlng, geojsonMarkerOptions);
}
let quakesLayer = L.geoJson(quakes.features, { pointToLayer: pointToLayer }).addTo(map);

return quakesLayer;
}
Insert cell
Insert cell
quakesLayer.eachLayer(function(quakeLayer) { // Each earthquake has its own "layer"
let mag = quakeLayer.feature.properties.mag;
let opacity = (mag > max_mag) ? 1 : 0;
quakeLayer.setStyle({opacity: opacity, fillOpacity: opacity});
});
Insert cell
Insert cell
L = {
const L = await require("leaflet@1/dist/leaflet.js");
if (!L._style) {
const href = await require.resolve("leaflet@1/dist/leaflet.css");
document.head.appendChild(L._style = html`<link href=${href} rel=stylesheet>`);
}
return L;
}
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