map = {
let map = this;
if (!map) {
map = new mapboxgl.Map({
container: mapContainer,
center: [
-122.4,
37.7923539,
],
zoom: 12,
style: 'mapbox://styles/mapbox/light-v9'
});
}
yield new Promise(resolve => {
if (map.loaded()) resolve(map);
else map.on('load', () => resolve(map));
});
const rand = gen('count');
setMapSource(
map,
'h3-hexes',
geojson2h3.h3SetToFeatureCollection(hexes, hex => ({count: rand.random()}))
);
setMapLayer(
map,
'h3-hexes',
{
id: 'h3-hexes-fill-layer',
type: 'fill',
interactive: false,
paint: {
'fill-color': 'red',
'fill-outline-color': 'rgba(0,0,0,0)',
'fill-opacity': {
property: 'count',
stops: [
[0, 0.0],
[1, 0.5]
]
}
}
});
}