Move export dialog check outside onUpdate (#729)
to only check once on init, not on every update. Waypoints available at time of callback. Add check for lonlats param as event isn't called without and error check.
This commit is contained in:
parent
3b3357c473
commit
b772924106
1 changed files with 14 additions and 11 deletions
25
js/index.js
25
js/index.js
|
|
@ -313,6 +313,20 @@
|
||||||
onUpdate(evt && evt.err);
|
onUpdate(evt && evt.err);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Open export dialog immediately when the `export` query parameter is set;
|
||||||
|
// this is used for the QR code export:
|
||||||
|
var searchParams = new URLSearchParams(window.location.search);
|
||||||
|
if (searchParams.has('export') && searchParams.get('export') === 'dialog') {
|
||||||
|
// event won't get called without lonlats
|
||||||
|
if (new URLSearchParams(window.location.hash).has('lonlats')) {
|
||||||
|
routing.once('routing:setWaypointsEnd', (evt) => {
|
||||||
|
if (!evt.err && routing.getWaypoints().length > 1) {
|
||||||
|
$('#exportButton').trigger('click');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
map.on('routing:draw-start', function () {
|
map.on('routing:draw-start', function () {
|
||||||
drawButton.state('deactivate-draw');
|
drawButton.state('deactivate-draw');
|
||||||
beelineButton.enable();
|
beelineButton.enable();
|
||||||
|
|
@ -348,17 +362,6 @@
|
||||||
trackAnalysis.update(track, segments);
|
trackAnalysis.update(track, segments);
|
||||||
|
|
||||||
exportRoute.update(latLngs, segments);
|
exportRoute.update(latLngs, segments);
|
||||||
|
|
||||||
// Open export dialog immediately when the `export` query parameter is set;
|
|
||||||
// this is used for the QR code export:
|
|
||||||
var searchParams = new URLSearchParams(window.location.search);
|
|
||||||
if (searchParams.has('export') && searchParams.get('export') === 'dialog') {
|
|
||||||
routing.once('routing:setWaypointsEnd', () => {
|
|
||||||
if (latLngs.length > 1) {
|
|
||||||
$('#exportButton').trigger('click');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
routing.addTo(map);
|
routing.addTo(map);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue