File tree Expand file tree Collapse file tree 4 files changed +36
-15
lines changed Expand file tree Collapse file tree 4 files changed +36
-15
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,10 @@ Visit the examples in [hpneo.github.com/gmaps](http://hpneo.github.com/gmaps/)
8
8
Changelog
9
9
---------
10
10
11
+ 0.1.8.10
12
+ -----------------------
13
+ * Better GMaps.Route methods
14
+
11
15
0.1.8.9
12
16
-----------------------
13
17
* Fix typo in Polyline events
Original file line number Diff line number Diff line change 11
11
-webkit-box-shadow : 0px 5px 20px # ccc ;
12
12
box-shadow : 0px 5px 20px # ccc ;
13
13
}
14
+ # map .large {
15
+ height : 500px ;
16
+ }
14
17
15
18
.overlay {
16
19
display : block;
Original file line number Diff line number Diff line change 33
33
$ ( '#forward' ) . click ( function ( e ) {
34
34
e . preventDefault ( ) ;
35
35
route . forward ( ) ;
36
+
37
+ if ( route . step_count < route . steps_length )
38
+ $ ( '#steps' ) . append ( '<li>' + route . steps [ route . step_count ] . instructions + '</li>' ) ;
36
39
} ) ;
37
40
$ ( '#back' ) . click ( function ( e ) {
38
41
e . preventDefault ( ) ;
39
42
route . back ( ) ;
43
+
44
+ if ( route . step_count >= 0 )
45
+ $ ( '#steps' ) . find ( 'li' ) . last ( ) . remove ( ) ;
40
46
} ) ;
41
47
} ) ;
42
48
map = new GMaps ( {
58
64
< h1 > GMaps.js — Travel route</ h1 >
59
65
< div class ="row ">
60
66
< div class ="span16 ">
61
- < div id ="map "> </ div >
67
+ < div id ="map " class =" large " > </ div >
62
68
</ div >
63
69
< div class ="span5 ">
64
- < a href ="# " class ="btn " id ="get_route "> Get route</ a >
65
- < a href ="# " class ="btn " id ="back "> « Back</ a >
66
- < a href ="# " class ="btn " id ="forward "> Forward »</ a >
70
+ < div class ="row ">
71
+ < a href ="# " class ="btn " id ="get_route "> Get route</ a >
72
+ < a href ="# " class ="btn " id ="back "> « Back</ a >
73
+ < a href ="# " class ="btn " id ="forward "> Forward »</ a >
74
+ </ div >
75
+ < div class ="row ">
76
+ < ul id ="steps ">
77
+ </ ul >
78
+ </ div >
67
79
</ div >
68
80
</ div >
69
81
</ body >
Original file line number Diff line number Diff line change @@ -806,8 +806,9 @@ GMaps = function(options){
806
806
GMaps . Route = function ( options ) {
807
807
this . map = options . map ;
808
808
this . route = options . route ;
809
- this . path = this . route . overview_path ;
810
- this . steps = this . path . length ;
809
+ this . step_count = 0 ;
810
+ this . steps = this . route . legs [ 0 ] . steps ;
811
+ this . steps_length = this . steps . length ;
811
812
812
813
this . polyline = this . map . drawPolyline ( {
813
814
path : new google . maps . MVCArray ( ) ,
@@ -816,19 +817,20 @@ GMaps.Route = function(options){
816
817
strokeWeight : options . strokeWeight
817
818
} ) . getPath ( ) ;
818
819
819
- this . polyline . push ( this . route . overview_path [ 0 ] ) ;
820
- this . path_length = this . polyline . getLength ( ) ;
821
-
822
820
this . back = function ( ) {
823
- if ( this . path_length > 0 ) {
824
- this . polyline . pop ( ) ;
825
- this . path_length -- ;
821
+ if ( this . step_count > 0 ) {
822
+ this . step_count -- ;
823
+ for ( p in this . route . legs [ 0 ] . steps [ this . step_count ] . path )
824
+ this . polyline . pop ( ) ;
826
825
}
827
826
} ;
827
+
828
828
this . forward = function ( ) {
829
- if ( this . path_length < this . steps ) {
830
- this . polyline . push ( this . path [ this . path_length ] ) ;
831
- this . path_length ++ ;
829
+ if ( this . step_count < this . steps_length ) {
830
+ for ( p in this . route . legs [ 0 ] . steps [ this . step_count ] . path )
831
+ this . polyline . push ( this . route . legs [ 0 ] . steps [ this . step_count ] . path [ p ] )
832
+
833
+ this . step_count ++ ;
832
834
}
833
835
} ;
834
836
} ;
You can’t perform that action at this time.
0 commit comments