map = {
let h = (width<600) ? width + 200: width * 0.75,
z = (width<600) ? 6.5 : 7,
container = DOM.element('div', { style: `width:${width}px;height:${h}px` });
yield container;
let map = L.map(container).setView([42.1, -71.8], 9);
let osmLayer = L.tileLayer('https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}@2x.png', {
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
let tractsOverlay = L.geoJson(tracts, {
style: function(feature) {
let blackPop = feature.properties.B02001003, totPop = feature.properties.B02001001,
blackPct = (blackPop/totPop).toFixed(2),
c = (blackPct>0.1) ? colorRamp(blackPct) : '#fff',
o = (blackPct>0.1) ? 0.8 : 0;
return {
color : c,
stroke: '#999',
opacity: 1,
weight: 0.5,
fillOpacity: o
}
},
onEachFeature: function(feature, layer) {
let blackPop = feature.properties.B02001003, totPop = feature.properties.B02001001,
blackPct = (blackPop/totPop * 100).toFixed(2);
layer.bindPopup('<h4>'+feature.properties.name+'</h4><p>Black population: '+blackPop+'<br/>Total population: ' + totPop + '</p>')
}
}).addTo(map);
var geojsonMarkerOptions = {
radius: 5,
fillColor: "#ff7800",
color: "#000",
weight: 1,
opacity: 1,
fillOpacity: 0.25
};
let crashOverlay = L.geoJson(crashGeo, {
pointToLayer: function (feature, latlng) {
return L.circleMarker(latlng, geojsonMarkerOptions);
}
}).addTo(map);
let legend = L.control({position: 'bottomleft'})
legend.onAdd = function (map) {var div = L.DomUtil.create('div', 'legend'); return l};
legend.addTo(map);
}