Notebooks 2.0 is here.

Public
Edited
Mar 3, 2023
1 fork
3 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
location = {
if (prompt) {
try {
return await getLocation();
} catch (error) {
console.error(error);
return null;
}
} else {
return null;
}
}
Insert cell
function getLocation() {
return new Promise((resolve, reject) => {
navigator.geolocation.getCurrentPosition(
({ coords: { longitude, latitude } }) => resolve([longitude, latitude]),
reject
);
});
}
Insert cell
async function findPolygon(rect) {
const source = geojson.deserialize(url, rect);

// intentionally not caring about multiple matches
// makes sense for this dataset, but may not always!
for await (const feature of source) {
if (d3.geoContains(feature, [rect.minX, rect.minY])) {
return feature;
}
}

return null;
}
Insert cell
geojson = import("https://esm.sh/flatgeobuf@3.24.1/lib/mjs/geojson.js?bundle")
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