Published
Edited
Nov 17, 2020
Insert cell
Insert cell
selection.map(f => f.getId())
Insert cell
viewof selection = {
const target = html`<div style="height:660px;">`;
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({
format: new ol.format.GeoJSON()
})
})
],
target,
view: new ol.View({
center: ol.proj.fromLonLat([-77.29, 18.2]),
zoom: 7,
maxZoom: 8
})
});
target.value = []; // Initial empty selection.
const select = new ol.interaction.Select();
select.on("select", event => {
target.value = select.getFeatures().getArray();
target.dispatchEvent(new CustomEvent("input"));
})
map.addInteraction(select);
invalidation.then(() => map.dispose());
return target;
}
Insert cell
ol = {
// OpenLayers doesn’t publish a build to npm, so we can’t use unpkg. :(
const ol = await require("https://openlayers.org/en/v5.2.0/build/ol.js").catch(() => window.ol);
if (!ol.css) ol.css = document.head.appendChild(html`<link rel=stylesheet href="https://openlayers.org/en/v5.2.0/css/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