Compare commits
No commits in common. "572a8c6d3c7510e8e4414fa4200dcde396f85543" and "2242863fddbaaa40040b7cfc48d76ba1d19da885" have entirely different histories.
572a8c6d3c
...
2242863fdd
|
@ -13,15 +13,14 @@ const res = await fetch("https://whereis.chandlerswift.com/api/0/last");
|
||||||
const locs = await res.json();
|
const locs = await res.json();
|
||||||
const loc = locs[0];
|
const loc = locs[0];
|
||||||
|
|
||||||
let feature = new Feature({
|
let geometry = new Point(fromLonLat([loc.lon, loc.lat]));
|
||||||
geometry: new Point(fromLonLat([loc.lon, loc.lat])),
|
|
||||||
...loc
|
|
||||||
});
|
|
||||||
|
|
||||||
const vectorLayer = new VectorLayer({
|
const vectorLayer = new VectorLayer({
|
||||||
source: new VectorSource({
|
source: new VectorSource({
|
||||||
features: [
|
features: [
|
||||||
feature,
|
new Feature({
|
||||||
|
geometry: geometry,
|
||||||
|
})
|
||||||
]
|
]
|
||||||
}),
|
}),
|
||||||
style: new Style({
|
style: new Style({
|
||||||
|
@ -36,8 +35,7 @@ setInterval(async function(){
|
||||||
const res = await fetch("https://whereis.chandlerswift.com/api/0/last");
|
const res = await fetch("https://whereis.chandlerswift.com/api/0/last");
|
||||||
const locs = await res.json();
|
const locs = await res.json();
|
||||||
const loc = locs[0];
|
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
|
geometry.setCoordinates(fromLonLat([loc.lon, loc.lat]));
|
||||||
feature.getGeometry().setCoordinates(fromLonLat([loc.lon, loc.lat]));
|
|
||||||
}, 10 * 1000);
|
}, 10 * 1000);
|
||||||
|
|
||||||
export default vectorLayer;
|
export default vectorLayer;
|
||||||
|
|
|
@ -20,8 +20,8 @@ const allStates = {
|
||||||
...castleRockStates,
|
...castleRockStates,
|
||||||
...travelIqStates,
|
...travelIqStates,
|
||||||
'Alabama': al,
|
'Alabama': al,
|
||||||
};
|
}
|
||||||
|
console.log(allStates, castleRockStates, travelIqStates);
|
||||||
let dot_cams = {
|
let dot_cams = {
|
||||||
name: "State DOT Cameras",
|
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>`,
|
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({
|
return new Style({
|
||||||
image: new Icon({
|
image: new Icon({
|
||||||
anchor: [0.5, 1],
|
anchor: [0.5, 1],
|
||||||
src: feature.getProperties().views[0].hasVideo ? pinVideo : pin,
|
src: feature.values_.views[0].hasVideo ? pinVideo : pin,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
vectorLayer.customPopup = function(feature) {
|
vectorLayer.customPopup = function(feature) {
|
||||||
const view = feature.getProperties().views[0];
|
const view = feature.values_.views[0];
|
||||||
if (view.hasVideo) {
|
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 {
|
} else {
|
||||||
return `<img style="max-width: 80vw; max-height: 80vh;" src="${view.src}">`;
|
return `<img style="max-width: 80vw; max-height: 80vh;" src="${view.src}">`;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
vectorLayer.customPopupCallback = function(feature) {
|
vectorLayer.customPopupCallback = function(feature) {
|
||||||
const view = feature.getProperties().views[0];
|
const view = feature.values_.views[0];
|
||||||
if (view.hasVideo) {
|
if (view.hasVideo) {
|
||||||
const video = document.getElementById('popupVideo');
|
const video = document.getElementById('popupVideo');
|
||||||
|
|
||||||
|
|
4
main.js
4
main.js
|
@ -141,7 +141,7 @@ map.on('click', function (evt) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// exclude geometry -- https://stackoverflow.com/a/208106
|
// exclude geometry -- https://stackoverflow.com/a/208106
|
||||||
const {geometry: _, ...featureData} = feature.getProperties();
|
const {geometry: _, ...featureData} = feature.values_;
|
||||||
|
|
||||||
content.innerHTML = objectToTable(featureData);
|
content.innerHTML = objectToTable(featureData);
|
||||||
}
|
}
|
||||||
|
@ -150,5 +150,3 @@ map.on('click', function (evt) {
|
||||||
});
|
});
|
||||||
|
|
||||||
new ResizeObserver(() => map.updateSize()).observe(document.getElementById("map"));
|
new ResizeObserver(() => map.updateSize()).observe(document.getElementById("map"));
|
||||||
|
|
||||||
window.map = map;
|
|
||||||
|
|
Loading…
Reference in a new issue