Compare commits

..

No commits in common. "572a8c6d3c7510e8e4414fa4200dcde396f85543" and "2242863fddbaaa40040b7cfc48d76ba1d19da885" have entirely different histories.

3 changed files with 12 additions and 16 deletions

View file

@ -13,15 +13,14 @@ const res = await fetch("https://whereis.chandlerswift.com/api/0/last");
const locs = await res.json();
const loc = locs[0];
let feature = new Feature({
geometry: new Point(fromLonLat([loc.lon, loc.lat])),
...loc
});
let geometry = new Point(fromLonLat([loc.lon, loc.lat]));
const vectorLayer = new VectorLayer({
source: new VectorSource({
features: [
feature,
new Feature({
geometry: geometry,
})
]
}),
style: new Style({
@ -36,8 +35,7 @@ setInterval(async function(){
const res = await fetch("https://whereis.chandlerswift.com/api/0/last");
const locs = await res.json();
const loc = locs[0];
feature.setProperties(loc); // TODO: this won't remove a property if it was in a previous response but not this one
feature.getGeometry().setCoordinates(fromLonLat([loc.lon, loc.lat]));
geometry.setCoordinates(fromLonLat([loc.lon, loc.lat]));
}, 10 * 1000);
export default vectorLayer;

View file

@ -20,8 +20,8 @@ const allStates = {
...castleRockStates,
...travelIqStates,
'Alabama': al,
};
}
console.log(allStates, castleRockStates, travelIqStates);
let dot_cams = {
name: "State DOT Cameras",
details: `<a href="#" onclick="this.closest('details').querySelectorAll('ul li input').forEach(e => e.checked || e.click()); return false;">Enable All</a>`,
@ -38,23 +38,23 @@ for (let [state, url] of Object.entries(allStates)) {
return new Style({
image: new Icon({
anchor: [0.5, 1],
src: feature.getProperties().views[0].hasVideo ? pinVideo : pin,
src: feature.values_.views[0].hasVideo ? pinVideo : pin,
}),
});
},
});
vectorLayer.customPopup = function(feature) {
const view = feature.getProperties().views[0];
const view = feature.values_.views[0];
if (view.hasVideo) {
return `<p>${feature.getProperties().name}</p><video style="max-width: 80vw; max-height: 80vh;" id="popupVideo" autoplay controls></video>`;
return `<p>${feature.values_.name}</p><video style="max-width: 80vw; max-height: 80vh;" id="popupVideo" autoplay controls></video>`;
} else {
return `<img style="max-width: 80vw; max-height: 80vh;" src="${view.src}">`;
}
};
vectorLayer.customPopupCallback = function(feature) {
const view = feature.getProperties().views[0];
const view = feature.values_.views[0];
if (view.hasVideo) {
const video = document.getElementById('popupVideo');

View file

@ -141,7 +141,7 @@ map.on('click', function (evt) {
}
} else {
// exclude geometry -- https://stackoverflow.com/a/208106
const {geometry: _, ...featureData} = feature.getProperties();
const {geometry: _, ...featureData} = feature.values_;
content.innerHTML = objectToTable(featureData);
}
@ -150,5 +150,3 @@ map.on('click', function (evt) {
});
new ResizeObserver(() => map.updateSize()).observe(document.getElementById("map"));
window.map = map;