From 572a8c6d3c7510e8e4414fa4200dcde396f85543 Mon Sep 17 00:00:00 2001 From: Chandler Swift Date: Fri, 2 Feb 2024 03:33:09 -0600 Subject: [PATCH] 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;