labels above data
This commit is contained in:
parent
b1ad04f45f
commit
3b552bd890
1 changed files with 15 additions and 3 deletions
|
@ -55,6 +55,18 @@
|
||||||
load_image('radar-rect-green');
|
load_image('radar-rect-green');
|
||||||
load_image('radar-rect-red');
|
load_image('radar-rect-red');
|
||||||
|
|
||||||
|
// should this be here? am unfamiliar with the structure
|
||||||
|
|
||||||
|
const layers = map.getStyle().layers;
|
||||||
|
let sym_layer;
|
||||||
|
for (let i = 0; i < layers.length; i++) {
|
||||||
|
if (layers[i].type === 'symbol') {
|
||||||
|
sym_layer = layers[i].id;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
map.addSource('alerts', {
|
map.addSource('alerts', {
|
||||||
type: 'geojson',
|
type: 'geojson',
|
||||||
data: 'https://api.weather.gov/alerts/active?status=actual'
|
data: 'https://api.weather.gov/alerts/active?status=actual'
|
||||||
|
@ -67,7 +79,7 @@
|
||||||
// @ts-expect-error this type is too complicated
|
// @ts-expect-error this type is too complicated
|
||||||
'fill-color': fillLUT,
|
'fill-color': fillLUT,
|
||||||
}
|
}
|
||||||
});
|
}, sym_layer);
|
||||||
map.addLayer({
|
map.addLayer({
|
||||||
id: 'alerts-outline',
|
id: 'alerts-outline',
|
||||||
type: 'line',
|
type: 'line',
|
||||||
|
@ -80,7 +92,7 @@
|
||||||
'line-color': borderLUT,
|
'line-color': borderLUT,
|
||||||
'line-width': 3
|
'line-width': 3
|
||||||
}
|
}
|
||||||
});
|
}, sym_layer);
|
||||||
let createPopup = (e, full: boolean) => {
|
let createPopup = (e, full: boolean) => {
|
||||||
const randLetter = String.fromCharCode(65 + Math.floor(Math.random() * 26));
|
const randLetter = String.fromCharCode(65 + Math.floor(Math.random() * 26));
|
||||||
const uniqid = randLetter + Date.now();
|
const uniqid = randLetter + Date.now();
|
||||||
|
@ -98,7 +110,7 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
map.on('click', 'alerts', (e) => {createPopup(e,true)});
|
map.on('click', 'alerts', (e) => { createPopup(e, true) });
|
||||||
let currentFeatureCoordinates = undefined;
|
let currentFeatureCoordinates = undefined;
|
||||||
const popup = new maplibregl.Popup({
|
const popup = new maplibregl.Popup({
|
||||||
closeButton: false,
|
closeButton: false,
|
||||||
|
|
Loading…
Add table
Reference in a new issue