@@ -8754,60 +8754,64 @@ L.control.layers.provided = function (baseLayers, overlays, options) {
87548754 }
87558755 if ( this . options . lc && ! this . options . formatBase ) {
87568756 this . options . formatBase = [
8757- / [ \s A - Z ] / g, function ( match ) {
8757+ / [ \s \: A - Z ] / g, function ( match ) {
87588758 if ( match . match ( / \s / ) ) {
8759- return "_ " ;
8759+ return "_" ;
8760+ } else if ( match . match ( / \: / ) ) {
8761+ return "" ;
87608762 }
87618763 if ( match . match ( / [ A - Z ] / ) ) {
87628764 return match . toLowerCase ( ) ;
87638765 }
87648766 }
87658767 ] ;
87668768 }
8767- if ( this . map . _loaded ) {
8769+ if ( this . map . _loaded || location . hash ) {
87688770 return this . startListning ( ) ;
87698771 } else {
8770- return this . map . on ( "load" , this . startListning ) ;
8772+ return this . map . on ( "load" , this . startListning , this ) ;
87718773 }
87728774 } ,
87738775 startListning : function ( ) {
8774- var onHashChange ,
8775- _this = this ;
8776+ var onHashChange , phash ;
87768777 if ( location . hash ) {
8777- this . updateFromState ( this . parseHash ( location . hash ) ) ;
8778+ phash = this . parseHash ( location . hash ) ;
8779+ if ( phash ) {
8780+ this . updateFromState ( phash ) ;
8781+ }
87788782 }
87798783 if ( history . pushState ) {
87808784 if ( ! location . hash ) {
87818785 history . replaceState . apply ( history , this . formatState ( ) ) ;
87828786 }
87838787 window . onpopstate = function ( event ) {
87848788 if ( event . state ) {
8785- return _this . updateFromState ( event . state ) ;
8789+ return this . updateFromState ( event . state ) ;
87868790 }
87878791 } ;
87888792 this . map . on ( "moveend" , function ( ) {
87898793 var pstate ;
8790- pstate = _this . formatState ( ) ;
8791- if ( location . hash !== pstate [ 2 ] && ! _this . moving ) {
8794+ pstate = this . formatState ( ) ;
8795+ if ( location . hash !== pstate [ 2 ] && ! this . moving ) {
87928796 return history . pushState . apply ( history , pstate ) ;
87938797 }
8794- } ) ;
8798+ } , this ) ;
87958799 } else {
87968800 if ( ! location . hash ) {
87978801 location . hash = this . formatState ( ) [ 2 ] ;
87988802 }
87998803 onHashChange = function ( ) {
88008804 var pstate ;
8801- pstate = _this . formatState ( ) ;
8802- if ( location . hash !== pstate [ 2 ] && ! _this . moving ) {
8805+ pstate = this . formatState ( ) ;
8806+ if ( location . hash !== pstate [ 2 ] && ! this . moving ) {
88038807 return location . hash = pstate [ 2 ] ;
88048808 }
88058809 } ;
8806- this . map . on ( "moveend" , onHashChange ) ;
8810+ this . map . on ( "moveend" , onHashChange , this ) ;
88078811 if ( ( 'onhashchange' in window ) && ( window . documentMode === void 0 || window . documentMode > 7 ) ) {
88088812 window . onhashchange = function ( ) {
88098813 if ( location . hash ) {
8810- return _this . updateFromState ( _this . parseHash ( location . hash ) ) ;
8814+ return this . updateFromState ( this . parseHash ( location . hash ) ) ;
88118815 }
88128816 } ;
88138817 } else {
@@ -8816,25 +8820,28 @@ L.control.layers.provided = function (baseLayers, overlays, options) {
88168820 }
88178821 return this . map . on ( "baselayerchange" , function ( e ) {
88188822 var pstate , _ref ;
8819- _this . base = ( _ref = _this . options . lc . _layers [ e . layer . _leaflet_id ] . name ) . replace . apply ( _ref , _this . options . formatBase ) ;
8820- pstate = _this . formatState ( ) ;
8823+ this . base = ( _ref = this . options . lc . _layers [ e . layer . _leaflet_id ] . name ) . replace . apply ( _ref , _this . options . formatBase ) ;
8824+ pstate = this . formatState ( ) ;
88218825 if ( history . pushState ) {
8822- if ( location . hash !== pstate [ 2 ] && ! _this . moving ) {
8826+ if ( location . hash !== pstate [ 2 ] && ! this . moving ) {
88238827 return history . pushState . apply ( history , pstate ) ;
88248828 }
88258829 } else {
8826- if ( location . hash !== pstate [ 2 ] && ! _this . moving ) {
8830+ if ( location . hash !== pstate [ 2 ] && ! this . moving ) {
88278831 return location . hash = pstate [ 2 ] ;
88288832 }
88298833 }
8830- } ) ;
8834+ } , this ) ;
88318835 } ,
88328836 parseHash : function ( hash ) {
88338837 var args , lat , latIndex , lngIndex , lon , out , path , zIndex , zoom ;
88348838 path = this . options . path . split ( "/" ) ;
88358839 zIndex = path . indexOf ( "{z}" ) ;
88368840 latIndex = path . indexOf ( "{lat}" ) ;
88378841 lngIndex = path . indexOf ( "{lng}" ) ;
8842+ if ( zIndex === - 1 || latIndex === - 1 || lngIndex === - 1 ) {
8843+ return ;
8844+ }
88388845 if ( hash . indexOf ( "#" ) === 0 ) {
88398846 hash = hash . substr ( 1 ) ;
88408847 }
@@ -8955,4 +8962,4 @@ L.control.layers.provided = function (baseLayers, overlays, options) {
89558962 }
89568963 } ) ;
89578964
8958- } ) . call ( this ) ;
8965+ } ) . call ( this ) ;
0 commit comments