Published
Edited
Aug 20, 2020
6 stars
Also listed in…
maps and geo
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
scrollZoomEnabled = {
if (!map.map) return false;

if (map.map.scrollZoom.isEnabled() && scrollZoom !== "enabled") {
map.map.scrollZoom.disable();
} else {
map.map.scrollZoom.enable();
}

return map.map.scrollZoom.isEnabled();
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
getPopupHtml = (name, value) => `
<div class="map-popup-container">
<p><strong>${name}</strong></p>
<p>Percentage of households without internet access:</p>
<p class="big">${value}%</p>
</div>`
Insert cell
html`<style>
.map-popup-container {
width: 150px;
display: flex;
flex-direction: column;
}
.map-popup-container p {
margin: 0.2rem;
line-height: 0.9rem;
}
.map-popup-container p.big {
margin-top: 0.5rem;
font-weight: bold;
font-size: 2rem;
}
</style>`
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
carto = {
const c = await require("@carto/carto-vl@1.4.6/dist/carto-vl.min.js");
c.setDefaultAuth({
username: cartoUser,
apiKey: cartoApiKey
});
return c;
}
Insert cell
mapboxgl = {
const gl = await require("mapbox-gl@1.12.0");
if (!gl.accessToken) {
gl.accessToken =
'pk.eyJ1IjoiY2hlbnJpY2siLCJhIjoiLVhZMUZZZyJ9.HcNi26J3P-MiOmBKYHIbxw';
}
return gl;
}
Insert cell
mapboxglCSS = html`<link href='${await require.resolve(
"mapbox-gl@1.12.0/dist/mapbox-gl.css"
)}' rel='stylesheet' />`
Insert cell
import { checkbox } from "@jashkenas/inputs"
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