From c307dd0a22041edc40a7e59fd3dde79711508775 Mon Sep 17 00:00:00 2001 From: sora-ext Date: Tue, 25 Feb 2025 18:02:19 +0100 Subject: [PATCH] Update src/client/old.js --- src/client/old.js | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/src/client/old.js b/src/client/old.js index 9843eeb..ae82cc2 100644 --- a/src/client/old.js +++ b/src/client/old.js @@ -1,3 +1,4 @@ + import * as api from "./api"; import journey_wrapper from "./types/wrapper"; import { migrator } from "./types/migration"; @@ -31,21 +32,21 @@ const app = new Vue({ monthBeforeYear: true, }, polyline: { - latlngs: [[47.334852, -1.509485], [47.342596, -1.328731], [47.241487, -1.190568], [47.234787, -1.358337]], + latlngs: [], color: 'green' } }, methods: { - start_journey: function(){ window.location.href = "/" + this.journey.id}, + start_journey: function () { window.location.href = "/" + this.journey.id }, - compute_bb: function(){ - const map = this.$refs.map[0].mapObject; - var bounds = map.getBounds(); - var minLng = bounds.getSouthWest().lng; - var minLat = bounds.getSouthWest().lat; - var maxLng = bounds.getNorthEast().lng; - var maxLat = bounds.getNorthEast().lat; - return [[minLng,minLat],[maxLng,maxLat]] + compute_bb: function () { + const map = this.$refs.map[0].mapObject; + var bounds = map.getBounds(); + var minLng = bounds.getSouthWest().lng; + var minLat = bounds.getSouthWest().lat; + var maxLng = bounds.getNorthEast().lng; + var maxLat = bounds.getNorthEast().lat; + return [[minLng, minLat], [maxLng, maxLat]] }, search_nominatim: function (txt, f) { @@ -54,7 +55,7 @@ const app = new Vue({ return Promise.resolve([]); } let bb = this.journey.leg_get(); - return api.query_nominatim(txt,this.compute_bb(), f).catch((err) => []).then((results) => { + return api.query_nominatim(txt, this.compute_bb(), f).catch((err) => []).then((results) => { results.forEach((r) => { r.latlon = [parseFloat(r.lat), parseFloat(r.lon)]; r.sname = r.display_name.split(",")[0]; @@ -65,7 +66,7 @@ const app = new Vue({ search_flight: function (txt) { if (txt == "") return; this.querying.flight = true; - api.query_flight(txt.replace(" ", "")).then((results) => { + api.query_flight(txt).then((results) => { if (results.results == "") { this.query.flight = []; this.querying.flight = false; @@ -139,6 +140,14 @@ const app = new Vue({ api.load(this.journey.id).then((r) => (app.journey.data = migrator(r))); + + api.query_flight("qf1").then(r => { + console.log(r) + this.polyline.latlngs = L.geodesic([ + new L.LatLng(r[0].from_geo.lat, r[0].from_geo.lon), + new L.LatLng(r[0].to_geo.lat, r[0].to_geo.lon)], {})._latlngs + }) + this.debounceSave = api.throttle(this.save_data, 500); this.debounceSearch = { hotel: api.throttle((q) => {