improve map
All checks were successful
Create and publish a Docker image / build-and-push-image (push) Successful in 5m38s
All checks were successful
Create and publish a Docker image / build-and-push-image (push) Successful in 5m38s
This commit is contained in:
parent
bb1ac27ea6
commit
5f12042f2f
3 changed files with 18 additions and 6 deletions
|
|
@ -36,7 +36,12 @@ async fn get_map_element_html(state: Data<Arc<AppState>>, resp: SessionResponse)
|
||||||
for other in trips {
|
for other in trips {
|
||||||
if let libseptastic::stop_schedule::TripTracking::Tracked(td) = other.tracking_data {
|
if let libseptastic::stop_schedule::TripTracking::Tracked(td) = other.tracking_data {
|
||||||
if let Some(lat) = td.latitude && let Some(lng) = td.longitude {
|
if let Some(lat) = td.latitude && let Some(lng) = td.longitude {
|
||||||
locations.push((lat, lng, td.route_id));
|
locations.push(crate::templates::MapItem {
|
||||||
|
lat,
|
||||||
|
lng,
|
||||||
|
route_id: td.route_id,
|
||||||
|
headsign: other.direction.direction_destination
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -99,10 +99,17 @@ pub struct StopSearchResults {
|
||||||
pub results: Vec<Stop>
|
pub results: Vec<Stop>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct MapItem {
|
||||||
|
pub lat: f64,
|
||||||
|
pub lng: f64,
|
||||||
|
pub route_id: String,
|
||||||
|
pub headsign: String,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(askama::Template)]
|
#[derive(askama::Template)]
|
||||||
#[template(path = "map.html")]
|
#[template(path = "map.html")]
|
||||||
pub struct MapTemplate {
|
pub struct MapTemplate {
|
||||||
pub locations: Vec<(f64,f64, String)>
|
pub locations: Vec<MapItem>
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn build_timetables(directions: Vec<Direction>, trips: Vec<Trip>) -> Vec<TimetableDirection> {
|
pub fn build_timetables(directions: Vec<Direction>, trips: Vec<Trip>) -> Vec<TimetableDirection> {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
crossorigin="">
|
crossorigin="">
|
||||||
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"
|
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"
|
||||||
integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo="
|
integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo="
|
||||||
crossorigin="">
|
crossorigin=""></script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
#map { height: 750px; width: 100%; }
|
#map { height: 750px; width: 100%; }
|
||||||
|
|
@ -26,13 +26,13 @@
|
||||||
html: `
|
html: `
|
||||||
<div>
|
<div>
|
||||||
<span style="background-color: #eee; padding: 2px;">
|
<span style="background-color: #eee; padding: 2px;">
|
||||||
{{ loc.2 }}
|
{{ loc.route_id }} to {{ loc.headsign }}
|
||||||
</span>
|
</span>
|
||||||
</div>`,
|
</div>`,
|
||||||
className: 'text-label'
|
className: 'text-label'
|
||||||
});
|
});
|
||||||
var marker = L.marker([{{loc.0}}, {{loc.1}}], {icon: icon}).addTo(map);
|
var marker = L.marker([{{loc.lat}}, {{loc.lng}}], {icon: icon}).addTo(map);
|
||||||
marker.bindPopup("{{ loc.2 }}")
|
marker.bindPopup("{{ loc.route_id }}")
|
||||||
}
|
}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue