Published
Edited
Sep 3, 2022
4 forks
7 stars
Insert cell
Insert cell
selection.map(f => f.getId())
Insert cell
viewof selection = {
const target = html`<div style="height: 600px;">`;
yield target; // Give the container dimensions.
const map = new ol.Map({
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
}),
new ol.layer.Vector({
source: new ol.source.Vector({
url: "https://openlayers.org/data/vector/us-states.json",
format: new ol.format.GeoJSON()
})
})
],
target,
view: new ol.View({
center: [0, 0],
zoom: 2
})
});
target.value = []; // Initial empty selection.
const select = new ol.interaction.Select();
select.on("select", event => {
target.value = select.getFeatures().getArray();
target.dispatchEvent(new Event("input", {bubbles: true}));
})
map.addInteraction(select);
invalidation.then(() => map.dispose());
return target;
}
Insert cell
ol = {
const ol = await require("ol@7.1.0/dist/ol.js").catch(() => window.ol);
if (!ol._style) ol._style = document.head.appendChild(html`<link rel=stylesheet href="${await require.resolve("ol@7.1.0/ol.css")}">`);
return ol;
}
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