map3 = {
let map = this
const data = JSON.parse(JSON.stringify(crashes))
if (!map) {
map = new mapboxgl.Map({
container: container3,
center: [-74.0059, 40.7127],
zoom: 10,
style: 'mapbox://styles/mapbox/dark-v9',
scrollZoom: false
});
map.addControl(new mapboxgl.NavigationControl());
}
map.on("load", function () {
map.addSource('crashes', {
type: 'geojson',
'data': data,
});
map.addLayer({
id: 'crashes',
type: 'circle',
source: 'crashes',
'layout': {},
'paint': {
'circle-color': {
property: 'crash_type',
type: 'categorical',
stops: [
['no_injury_fatality', '#FECC5C'],
['injury', '#FD8D3C'],
['fatality', '#F03B20'],
['injury_and_fatality', '#BD0026']
]
},
'circle-opacity': 0.8,
'circle-radius': {
'base': 1.75,
'stops': [[12, 2], [22, 180]]
},
}
});
})
try {
yield map;
yield invalidation;
} finally {
map.remove();
}
}