1515 this . options . formatBase = [
1616 / [ \s A - Z ] / g, function ( match ) {
1717 if ( match . match ( / \s / ) ) {
18- return "_ " ;
18+ return "_" ;
19+ } else if ( match . match ( / \: / ) ) {
20+ return "" ;
1921 }
2022 if ( match . match ( / [ A - Z ] / ) ) {
2123 return match . toLowerCase ( ) ;
2224 }
2325 }
2426 ] ;
2527 }
26- if ( this . map . _loaded ) {
28+ if ( this . map . _loaded || location . hash ) {
2729 return this . startListning ( ) ;
2830 } else {
29- return this . map . on ( "load" , this . startListning ) ;
31+ return this . map . on ( "load" , this . startListning , this ) ;
3032 }
3133 } ,
3234 startListning : function ( ) {
33- var onHashChange ,
34- _this = this ;
35+ var onHashChange , phash ;
3536 if ( location . hash ) {
36- this . updateFromState ( this . parseHash ( location . hash ) ) ;
37+ phash = this . parseHash ( location . hash ) ;
38+ if ( phash ) {
39+ this . updateFromState ( phash ) ;
40+ }
3741 }
3842 if ( history . pushState ) {
3943 if ( ! location . hash ) {
4044 history . replaceState . apply ( history , this . formatState ( ) ) ;
4145 }
4246 window . onpopstate = function ( event ) {
4347 if ( event . state ) {
44- return _this . updateFromState ( event . state ) ;
48+ return this . updateFromState ( event . state ) ;
4549 }
4650 } ;
4751 this . map . on ( "moveend" , function ( ) {
4852 var pstate ;
49- pstate = _this . formatState ( ) ;
50- if ( location . hash !== pstate [ 2 ] && ! _this . moving ) {
53+ pstate = this . formatState ( ) ;
54+ if ( location . hash !== pstate [ 2 ] && ! this . moving ) {
5155 return history . pushState . apply ( history , pstate ) ;
5256 }
53- } ) ;
57+ } , this ) ;
5458 } else {
5559 if ( ! location . hash ) {
5660 location . hash = this . formatState ( ) [ 2 ] ;
5761 }
5862 onHashChange = function ( ) {
5963 var pstate ;
60- pstate = _this . formatState ( ) ;
61- if ( location . hash !== pstate [ 2 ] && ! _this . moving ) {
64+ pstate = this . formatState ( ) ;
65+ if ( location . hash !== pstate [ 2 ] && ! this . moving ) {
6266 return location . hash = pstate [ 2 ] ;
6367 }
6468 } ;
65- this . map . on ( "moveend" , onHashChange ) ;
69+ this . map . on ( "moveend" , onHashChange , this ) ;
6670 if ( ( 'onhashchange' in window ) && ( window . documentMode === void 0 || window . documentMode > 7 ) ) {
6771 window . onhashchange = function ( ) {
6872 if ( location . hash ) {
69- return _this . updateFromState ( _this . parseHash ( location . hash ) ) ;
73+ return this . updateFromState ( this . parseHash ( location . hash ) ) ;
7074 }
7175 } ;
7276 } else {
7579 }
7680 return this . map . on ( "baselayerchange" , function ( e ) {
7781 var pstate , _ref ;
78- _this . base = ( _ref = _this . options . lc . _layers [ e . layer . _leaflet_id ] . name ) . replace . apply ( _ref , _this . options . formatBase ) ;
79- pstate = _this . formatState ( ) ;
82+ this . base = ( _ref = this . options . lc . _layers [ e . layer . _leaflet_id ] . name ) . replace . apply ( _ref , _this . options . formatBase ) ;
83+ pstate = this . formatState ( ) ;
8084 if ( history . pushState ) {
81- if ( location . hash !== pstate [ 2 ] && ! _this . moving ) {
85+ if ( location . hash !== pstate [ 2 ] && ! this . moving ) {
8286 return history . pushState . apply ( history , pstate ) ;
8387 }
8488 } else {
85- if ( location . hash !== pstate [ 2 ] && ! _this . moving ) {
89+ if ( location . hash !== pstate [ 2 ] && ! this . moving ) {
8690 return location . hash = pstate [ 2 ] ;
8791 }
8892 }
89- } ) ;
93+ } , this ) ;
9094 } ,
9195 parseHash : function ( hash ) {
9296 var args , lat , latIndex , lngIndex , lon , out , path , zIndex , zoom ;
9397 path = this . options . path . split ( "/" ) ;
9498 zIndex = path . indexOf ( "{z}" ) ;
9599 latIndex = path . indexOf ( "{lat}" ) ;
96100 lngIndex = path . indexOf ( "{lng}" ) ;
101+ if ( zIndex === - 1 || latIndex === - 1 || lngIndex === - 1 ) {
102+ return ;
103+ }
97104 if ( hash . indexOf ( "#" ) === 0 ) {
98105 hash = hash . substr ( 1 ) ;
99106 }
214221 }
215222 } ) ;
216223
217- } ) . call ( this ) ;
224+ } ) . call ( this ) ;
0 commit comments