{
if (mgOverview) {
if (map.getLayer(`statistics-reached`)) {
map.removeLayer(`statistics-reached`);
}
if (map.getSource(`statistics-reached`)) {
map.removeSource(`statistics-reached`);
}
if (map.getLayer(`statistics-unreached`)) {
map.removeLayer(`statistics-unreached`);
}
if (map.getSource(`statistics-unreached`)) {
map.removeSource(`statistics-unreached`);
}
map.addLayer(
{
id: `statistics-reached`,
type: "fill",
source: {
type: "vector",
tiles: [`${mvtUrl}?apiKey=${targomoKey()}&serviceUrl=${serviceUrl}`],
attribution:
'<a href="https://www.targomo.com/developers/resources/attribution/" target="_blank">© Targomo</a>'
},
"source-layer": "aggregation",
layout: {},
filter: ["to-boolean", ["get", "reachability"]],
paint: {
"fill-opacity": 0.6,
"fill-color": colorDef(
mgOverview,
displayStat.key,
d3.interpolateYlOrRd
),
"fill-outline-color": "rgba(0,0,0,0)"
}
},
"place_other"
);
if (show_unreachable) {
map.addLayer(
{
id: `statistics-unreached`,
type: "fill",
source: {
type: "vector",
tiles: [`${mvtUrl}?key=${targomoKey()}&serviceUrl=${serviceUrl}`],
attribution:
'<a href="https://www.targomo.com/developers/resources/attribution/" target="_blank">© Targomo</a>'
},
"source-layer": "aggregation",
layout: {},
filter: ["!", ["to-boolean", ["get", "reachability"]]],
paint: {
"fill-opacity": 0.4,
"fill-color": colorDef(
mgOverview,
displayStat.key,
d3.interpolateGreys
),
"fill-outline-color": "rgba(0,0,0,0)"
}
},
"place_other"
);
}
}
return md`_adding MVT layers to the map_`;
}