choropleth = {
let container = DOM.element('div', { style: `width:${width}px;` });
const legendSvg = d3.select(container).append("svg")
.attr("width", width)
.attr("height", 70)
.append("g")
.attr("transform", "translate(365,20)")
.append(() =>
legend({
color: color,
title: data.title,
width: 260,
tickFormat: ".1f"
})
);
let mapContainer = DOM.element('div', { style: `width:${width}px;height:${width/1.6}px` });
container.appendChild(mapContainer);
let map = L.map(mapContainer).setView([41.81, -93.46], 7);
esriLeaflet.basemapLayer('Gray').addTo(map);
L.svg().addTo(map);
yield container;
const overlay = d3.select(map.getPanes().overlayPane);
const svg = overlay.select('svg');
const g = svg.append('g').attr('class', 'leaflet-zoom-hide');
function update() {
const projectPoint = function(x, y) {
const point = map.latLngToLayerPoint(new L.LatLng(y, x));
this.stream.point(point.x, point.y);
};
const projection = d3.geoTransform({ point: projectPoint });
const pathCreator = d3.geoPath().projection(projection);
const areaPaths = g.selectAll("path")
.data(counties.features)
.join("path")
.attr("stroke", "white")
.attr("stroke-linejoin", "round")
.attr("stroke-width", 1)
.attr("fill", d => color(data.get(+d.properties.FIPS)))
.attr("d", pathCreator)
.append("title")
.text(d => "Median Age: " + data.get(+d.properties.FIPS));
}
map.on("zoom", update);
map.on("move", update);
update();
}