made line drawing less of a mess
This commit is contained in:
parent
9d28eec424
commit
92c28fbc54
1 changed files with 19 additions and 15 deletions
|
@ -96,26 +96,29 @@ async function submit(clickEvent){
|
|||
let from_lon = document.getElementById("from_longitude_input").value;
|
||||
let to_lat = document.getElementById("to_lattitude_input").value;
|
||||
let to_lon = document.getElementById("to_longitude_input").value;
|
||||
|
||||
let path = await fetch(`http://localhost:8080/path?time=e&from_lat=${from_lat}&from_lon=${from_lon}&to_lat=${to_lat}&to_lon=${to_lon}`).then(r=>r.json());
|
||||
|
||||
let secs = [];
|
||||
for(let route of path.path){
|
||||
console.log(route.route_name);
|
||||
secs.push(fetch(`http://localhost:8080/time_to_arrive?service=${route.service}&from=${route.enter_stop_id}&to=${route.exit_stop_id}&route=${route.route_id}`).then(r=>r.json()));
|
||||
fetch(`http://localhost:8080/route_draw?service=${route.service}&id=${route.route_id}`).then(r=>r.json()).then(v=>{
|
||||
return {path:google.maps.geometry.encoding.decodePath(v.poly_line), color:v.color}
|
||||
})
|
||||
.then(o=>{
|
||||
//console.log(`"${o.path}"`);
|
||||
|
||||
let route_draw = await fetch(`http://localhost:8080/route_draw?service=${route.service}&id=${route.route_id}`)
|
||||
.then(r=>r.json());
|
||||
|
||||
let path=google.maps.geometry.encoding.decodePath(route_draw.poly_line);
|
||||
|
||||
let line = new google.maps.Polyline({
|
||||
path:o.path,
|
||||
strokeColor: o.color,
|
||||
path,
|
||||
strokeColor: route_draw.color,
|
||||
strokeOpacity: 1.0,
|
||||
strokeWeight: 3,
|
||||
});
|
||||
|
||||
line.setMap(map);
|
||||
window.paths.push(line);
|
||||
//setTimeout(()=>line.setVisible(false), 5000);
|
||||
})
|
||||
>>>>>>> Stashed changes
|
||||
}
|
||||
Promise.all(secs).then(l=>l.reduce((a,b)=>a+b)).then(v=>alert(`bus ride will take ${display_time(v)}`));
|
||||
}
|
||||
|
@ -131,6 +134,7 @@ function display_time(secs){
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
async function clear_lines(){
|
||||
for (let path of window.paths) path.setMap(null);
|
||||
window.paths = [];
|
||||
|
|
Loading…
Reference in a new issue