@@ -351,6 +351,13 @@ function createCallback(errorFallback) {
351
351
} ;
352
352
}
353
353
354
+ function focus ( coord ) {
355
+ if ( coord . lat && coord . lng ) {
356
+ routingLayer . clearLayers ( ) ;
357
+ map . setView ( new L . LatLng ( coord . lat , coord . lng ) , 11 ) ;
358
+ setFlag ( coord , true ) ;
359
+ }
360
+ }
354
361
function routeLatLng ( request ) {
355
362
clickToRoute = true ;
356
363
$ ( "#info" ) . empty ( ) ;
@@ -560,23 +567,28 @@ function initForm() {
560
567
} ) ;
561
568
562
569
// if FROM will be submitted
563
- $ ( '#fromInput' ) . keyup ( function ( e ) {
564
- if ( e . which == 10 || e . which == 13 ) {
570
+ $ ( '#fromInput' ) . keypress ( function ( e ) {
571
+ if ( e . which == 13 ) {
572
+ var from = $ ( "#fromInput" ) . val ( )
565
573
var to = $ ( "#toInput" ) . val ( ) ;
566
574
// do not resolve 'to'
567
575
if ( to == "To" ) {
568
- resolveTo ( ) ;
576
+ if ( from != ghRequest . from . input )
577
+ ghRequest . from = new GHInput ( from ) ;
578
+ $ . when ( resolveFrom ( ) ) . done ( function ( ) {
579
+ focus ( ghRequest . from ) ;
580
+ } ) ;
569
581
} else
570
- resolveCoords ( $ ( "#fromInput" ) . val ( ) , to ) ;
582
+ resolveCoords ( from , to ) ;
571
583
}
572
584
} ) ;
573
585
574
586
// if TO will be submitted
575
- $ ( '#toInput' ) . keyup ( function ( e ) {
576
- if ( e . which == 10 || e . which == 13 ) {
587
+ $ ( '#toInput' ) . keypress ( function ( e ) {
588
+ if ( e . which == 13 ) {
577
589
var from = $ ( "#fromInput" ) . val ( ) ;
578
590
if ( from == "From" ) {
579
- resolveFrom ( ) ;
591
+ // resolveFrom();
580
592
} else
581
593
resolveCoords ( from , $ ( "#toInput" ) . val ( ) ) ;
582
594
}
0 commit comments