centerpoint = {
let map = new mapboxgl.Map({
container: mapContainer,
center: [
-121,
38
],
zoom: 6,
style: 'mapbox://styles/mapbox/light-v9'
});
map.on('click', 'fire', function (e) {
console.log(e.features[0].properties);
new mapboxgl.Popup()
.setLngLat(e.lngLat)
.setHTML(e.features[0].properties.name)
.addTo(map);
});
map.addControl(new mapboxgl.NavigationControl());
map.addControl(new mapboxgl.FullscreenControl());
map.on('load', function () {
console.log(kml)
map.addLayer({
'id': 'fire',
'type': 'fill',
'source': {
'type': 'geojson',
'data': geojson
},
'layout': {},
'paint': {
'fill-color': '#f00',
'fill-opacity': 0.5
}
});
map.addLayer( {
"id": "label",
"type": "symbol",
"source": {
'type': 'geojson',
'data': geojson
},
"minzoom": 5,
"maxzoom": 24,
"layout": {
"text-optional": false,
"text-size": {
"base": 1.4,
"stops": [
[
7,
14
],
[
15,
18
]
]
},
"symbol-spacing": 500,
"text-field": "{name}"
},
"paint": {
"text-color": "#000",
"text-halo-color": "hsl(0, 0%, 100%)",
"text-halo-width": 2
}
});
});
return Generators.observe(change => {
map.on('mousemove', e => {
change(e.lngLat);
});
});
}