Published
Edited
Mar 25, 2021
Insert cell
Insert cell
container = html`<div style='height:500px;' />`
Insert cell
map = {
let map = this;

const mapboxStyle = FileAttachment("os_night.json").url();
if (!map) {
map = new mapboxgl.Map({
container,
center: [0.05, 51.459],
zoom: 12,
pitch: 45,
style:
'https://s3.us-east-2.amazonaws.com/eviction-lab-prototypes/bubble-colors/assets/style.json'
});
}

// Wait until the map loads, then yield the container again.
yield new Promise(resolve => {
if (map.loaded()) resolve(map);
else map.on('load', () => resolve(map));
});

let bgLayer = map.setPaintProperty('background', 'background-color', bgColor);

if (!map.getSource('lsom')) {
map.addSource('lsom', {
type: 'vector',
tiles: [
'https://maps.london.gov.uk/lsom/geoserver/gwc/service/wmts?REQUEST=GetTile&SERVICE=WMTS&VERSION=1.0.0&LAYER=lsom:solar_buildings_fid&STYLE=&TILEMATRIX=MyEPSG:900913:16&TILEMATRIXSET=MyEPSG:900913&FORMAT=application/x-protobuf;type=mapbox-vector&TILECOL={x}&TILEROW={y}'
],
tileSize: 512
});
}

let buildingsLayer = {
id: "solar_buildings_fid",
type: "fill",
source: "lsom",
'source-layer': 'lsom:solar_buildings_fid',
layout: {
visibility: "visible"
},
paint: {
'fill-color': 'Red'
}
};

if (map.getLayer(buildingsLayer.id)) {
map.removeLayer(buildingsLayer.id);
}
map.addLayer(buildingsLayer);
}
Insert cell
viewof circleColor = html`<input type="color" value="#ff0400">`
Insert cell
viewof circleStrokeColor = html`<input type="color" value="#ffffff">`
Insert cell
viewof bgColor = html`<input type="color" value="#46464D">`
Insert cell
viewof circleOpacity = html`<input type="number" min="0", max="1" step="0.01" value="0.65">`
Insert cell
FileAttachment("os_night.json").url()
Insert cell
import { soFetch } from '@alecglassford/so-fetch'
Insert cell
d3 = require('d3')
Insert cell
mapboxgl = {
let mapboxgl = await require('mapbox-gl@0.43.0');
return mapboxgl;
}
Insert cell
Insert cell
md`# Bibliography`
Insert cell
md`@pjsier/mapbox-gl-bubble-map#counties`
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