add bus stops to the map
This commit is contained in:
parent
f1e1947b51
commit
47d21fd1a9
2 changed files with 11 additions and 4 deletions
10
app.py
10
app.py
|
@ -6,17 +6,19 @@ app=Flask(__name__)
|
||||||
app.config['CACHE_TYPE']='SimpleCache'
|
app.config['CACHE_TYPE']='SimpleCache'
|
||||||
cache=Cache(app)
|
cache=Cache(app)
|
||||||
|
|
||||||
|
data=requests.get("https://tarc.rideralerts.com/InfoPoint/rest/Routes/GetVisibleRoutes").json()
|
||||||
|
routes=",".join(str(r.get("RouteId")) for r in data)
|
||||||
|
data=requests.get("https://tarc.rideralerts.com/InfoPoint/rest/Stops/GetAllStops").json()
|
||||||
|
stops={s.get("StopId"):[s.get("Latitude"),s.get("Longitude")] for s in data}
|
||||||
|
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
def index():
|
def index():
|
||||||
return render_template("map.html")
|
return render_template("map.html",stops=stops)
|
||||||
|
|
||||||
@app.route("/bus.svg")
|
@app.route("/bus.svg")
|
||||||
def favicon():
|
def favicon():
|
||||||
return send_from_directory(app.static_folder,"bus.svg")
|
return send_from_directory(app.static_folder,"bus.svg")
|
||||||
|
|
||||||
data=requests.get("https://tarc.rideralerts.com/InfoPoint/rest/Routes/GetVisibleRoutes").json()
|
|
||||||
routes=",".join(str(r.get("RouteId")) for r in data)
|
|
||||||
|
|
||||||
@app.route("/tarc.csv")
|
@app.route("/tarc.csv")
|
||||||
@cache.cached(timeout=5)
|
@cache.cached(timeout=5)
|
||||||
def tarc():
|
def tarc():
|
||||||
|
|
|
@ -8,12 +8,17 @@
|
||||||
<link rel="icon" href="bus.svg" type="image/svg+xml">
|
<link rel="icon" href="bus.svg" type="image/svg+xml">
|
||||||
<script src="https://static.stevenalexander.org/leaflet/leaflet.js" integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo=" crossorigin=""></script>
|
<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="" />
|
<link rel="stylesheet" href="https://static.stevenalexander.org/leaflet/leaflet.css" integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY=" crossorigin="" />
|
||||||
|
<base href="https://tarc.rideralerts.com/InfoPoint/Minimal/Departures/ForStop" target="_blank">
|
||||||
<style>html,body{height:100%;margin:0;}#map{height:100vh;}</style>
|
<style>html,body{height:100%;margin:0;}#map{height:100vh;}</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="map"></div>
|
<div id="map"></div>
|
||||||
<script>
|
<script>
|
||||||
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 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="?stopId=${stop}">Stop #${stop}</a>`).addTo(map)
|
||||||
|
}
|
||||||
let layerControl=L.control.layers().addTo(map);
|
let layerControl=L.control.layers().addTo(map);
|
||||||
let busLayers={},busMarkers={};
|
let busLayers={},busMarkers={};
|
||||||
function updateMap(){
|
function updateMap(){
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue