From d96415b1c52e1c94b1b82cc310465290210c4afe Mon Sep 17 00:00:00 2001 From: Chandler Swift Date: Fri, 2 Feb 2024 03:25:22 -0600 Subject: [PATCH 1/4] Use getProperties instead of undocumented var --- layers/dot-cams/index.js | 8 ++++---- main.js | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/layers/dot-cams/index.js b/layers/dot-cams/index.js index b047a88..8f38101 100644 --- a/layers/dot-cams/index.js +++ b/layers/dot-cams/index.js @@ -38,23 +38,23 @@ for (let [state, url] of Object.entries(allStates)) { return new Style({ image: new Icon({ anchor: [0.5, 1], - src: feature.values_.views[0].hasVideo ? pinVideo : pin, + src: feature.getProperties().views[0].hasVideo ? pinVideo : pin, }), }); }, }); vectorLayer.customPopup = function(feature) { - const view = feature.values_.views[0]; + const view = feature.getProperties().views[0]; if (view.hasVideo) { - return `

${feature.values_.name}

`; + return `

${feature.getProperties().name}

`; } else { return ``; } }; vectorLayer.customPopupCallback = function(feature) { - const view = feature.values_.views[0]; + const view = feature.getProperties().views[0]; if (view.hasVideo) { const video = document.getElementById('popupVideo'); diff --git a/main.js b/main.js index cba5c02..51f17e4 100644 --- a/main.js +++ b/main.js @@ -141,7 +141,7 @@ map.on('click', function (evt) { } } else { // exclude geometry -- https://stackoverflow.com/a/208106 - const {geometry: _, ...featureData} = feature.values_; + const {geometry: _, ...featureData} = feature.getProperties(); content.innerHTML = objectToTable(featureData); } From b86fadf4260da398e8c87c7e71091a81fc507267 Mon Sep 17 00:00:00 2001 From: Chandler Swift Date: Fri, 2 Feb 2024 03:25:36 -0600 Subject: [PATCH 2/4] Expose map to the window object for debugging --- main.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/main.js b/main.js index 51f17e4..24f87ab 100644 --- a/main.js +++ b/main.js @@ -150,3 +150,5 @@ map.on('click', function (evt) { }); new ResizeObserver(() => map.updateSize()).observe(document.getElementById("map")); + +window.map = map; From 0c6f0565431505f5bb31df9a40d51b3258d1267f Mon Sep 17 00:00:00 2001 From: Chandler Swift Date: Fri, 2 Feb 2024 03:26:19 -0600 Subject: [PATCH 3/4] Remove erronenously included console.log --- layers/dot-cams/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/layers/dot-cams/index.js b/layers/dot-cams/index.js index 8f38101..166d5b5 100644 --- a/layers/dot-cams/index.js +++ b/layers/dot-cams/index.js @@ -20,8 +20,8 @@ const allStates = { ...castleRockStates, ...travelIqStates, 'Alabama': al, -} -console.log(allStates, castleRockStates, travelIqStates); +}; + let dot_cams = { name: "State DOT Cameras", details: `Enable All`, From 572a8c6d3c7510e8e4414fa4200dcde396f85543 Mon Sep 17 00:00:00 2001 From: Chandler Swift Date: Fri, 2 Feb 2024 03:33:09 -0600 Subject: [PATCH 4/4] Add properties to Chandler's location --- layers/chandler/layer.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/layers/chandler/layer.js b/layers/chandler/layer.js index 28a1600..85ac3f1 100644 --- a/layers/chandler/layer.js +++ b/layers/chandler/layer.js @@ -13,14 +13,15 @@ const res = await fetch("https://whereis.chandlerswift.com/api/0/last"); const locs = await res.json(); const loc = locs[0]; -let geometry = new Point(fromLonLat([loc.lon, loc.lat])); +let feature = new Feature({ + geometry: new Point(fromLonLat([loc.lon, loc.lat])), + ...loc +}); const vectorLayer = new VectorLayer({ source: new VectorSource({ features: [ - new Feature({ - geometry: geometry, - }) + feature, ] }), style: new Style({ @@ -35,7 +36,8 @@ setInterval(async function(){ const res = await fetch("https://whereis.chandlerswift.com/api/0/last"); const locs = await res.json(); const loc = locs[0]; - geometry.setCoordinates(fromLonLat([loc.lon, loc.lat])); + 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])); }, 10 * 1000); export default vectorLayer;