use iframe instead of linking stops

This commit is contained in:
steven 2025-04-17 16:11:49 -04:00
parent 6718a5a665
commit 2ae572c2be

View file

@ -9,7 +9,7 @@
<script src="https://static.stevenalexander.org/leaflet/leaflet.js" integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo=" crossorigin=""></script>
<link rel="stylesheet" href="https://static.stevenalexander.org/leaflet/leaflet.css" integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY=" crossorigin="" />
<base target="_blank">
<style>html,body{height:100%;margin:0;}#map{height:100vh;}</style>
<style>html,body{height:100%;margin:0;}#map{height:100vh;}iframe{border:none;}</style>
</head>
<body>
<div id="map"></div>
@ -17,14 +17,13 @@
let map=L.map("map",{center:[38.2,-85.75],zoom:13,layers:[L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png")]});
let stops={{stops}};
for (stop in stops){
L.circle(stops[stop]).bindPopup(`<a href="https://tarc.rideralerts.com/InfoPoint/Minimal/Departures/ForStop?stopId=${stop}">Stop #${stop}</a>`).addTo(map)
L.circle(stops[stop]).bindPopup(`<iframe src="https://tarc.rideralerts.com/InfoPoint/Minimal/Departures/ForStop?stopId=${stop}">Stop #${stop}</iframe>`).addTo(map)
}
let layerControl=L.control.layers().addTo(map);
let busLayers={},busMarkers={};
function updateMap(){
let routes={};
fetch("tarc.csv").then(response=>response.text()).then(csv=>{
if(csv=="")return;
csv.split("\n").forEach(line=>{
let [lat,lng,r,id,p,d,s,t]=line.split(",");
p=parseInt(p);
@ -42,6 +41,7 @@ function updateMap(){
}
layerControl.remove();
layerControl=L.control.layers(null,overlayLayers,{collapsed:window.innerWidth<window.innerHeight}).addTo(map);
let iframe=document.querySelector("iframe");if(iframe)iframe.src=iframe.src;
setTimeout(updateMap,5000)
})
}