@@ -94,7 +94,7 @@ var connect = function() {
9494 document . getElementById ( "footer" ) . innerHTML = "<font color='#494'>" + pagefoot + "</font>" ;
9595 }
9696 ws . send ( JSON . stringify ( { action :"connected" , parameters :Object . fromEntries ( ( new URL ( location ) ) . searchParams ) , clientTimezone :Intl . DateTimeFormat ( ) . resolvedOptions ( ) . timeZone || false } ) ) ;
97- setTimeout ( function ( ) { onoffline ( ) ; } , 500 ) ;
97+ setTimeout ( function ( ) { onoffline ( ) ; pickMapLayer ( ) ; } , 500 ) ;
9898 } ;
9999 ws . onclose = function ( ) {
100100 console . log ( "DISCONNECTED" ) ;
@@ -862,23 +862,7 @@ function showMapCurrentZoom() {
862862 } , 750 ) ;
863863}
864864
865- map . on ( 'zoomend' , function ( ) {
866- showMapCurrentZoom ( ) ;
867- window . localStorage . setItem ( "lastzoom" , map . getZoom ( ) ) ;
868- var b = map . getBounds ( ) ;
869- oldBounds = { sw :{ lat :b . _southWest . lat , lng :b . _southWest . lng } , ne :{ lat :b . _northEast . lat , lng :b . _northEast . lng } } ;
870- ws . send ( JSON . stringify ( { action :"bounds" , south :b . _southWest . lat , west :b . _southWest . lng , north :b . _northEast . lat , east :b . _northEast . lng , zoom :map . getZoom ( ) } ) ) ;
871- edgeAware ( ) ;
872- } ) ;
873- map . on ( 'moveend' , function ( ) {
874- window . localStorage . setItem ( "lastpos" , JSON . stringify ( map . getCenter ( ) ) ) ;
875- var b = map . getBounds ( ) ;
876- if ( b . _southWest . lat !== oldBounds . sw . lat && b . _southWest . lng !== oldBounds . sw . lng && b . _northEast . lat !== oldBounds . ne . lat && b . _northEast . lng !== oldBounds . ne . lng ) {
877- ws . send ( JSON . stringify ( { action :"bounds" , south :b . _southWest . lat , west :b . _southWest . lng , north :b . _northEast . lat , east :b . _northEast . lng , zoom :map . getZoom ( ) } ) ) ;
878- oldBounds = { sw :{ lat :b . _southWest . lat , lng :b . _southWest . lng } , ne :{ lat :b . _northEast . lat , lng :b . _northEast . lng } } ;
879- }
880- edgeAware ( ) ;
881-
865+ function pickMapLayer ( ) {
882866 // if we have bounds meta data for the current baselayer (usually pmtiles)
883867 if ( basemaps [ baselayername ] && basemaps [ baselayername ] . hasOwnProperty ( "meta" ) ) {
884868 const m = basemaps [ baselayername ] . meta
@@ -931,6 +915,25 @@ map.on('moveend', function() {
931915 }
932916 }
933917 }
918+ }
919+
920+ map . on ( 'zoomend' , function ( ) {
921+ showMapCurrentZoom ( ) ;
922+ window . localStorage . setItem ( "lastzoom" , map . getZoom ( ) ) ;
923+ var b = map . getBounds ( ) ;
924+ oldBounds = { sw :{ lat :b . _southWest . lat , lng :b . _southWest . lng } , ne :{ lat :b . _northEast . lat , lng :b . _northEast . lng } } ;
925+ ws . send ( JSON . stringify ( { action :"bounds" , south :b . _southWest . lat , west :b . _southWest . lng , north :b . _northEast . lat , east :b . _northEast . lng , zoom :map . getZoom ( ) } ) ) ;
926+ edgeAware ( ) ;
927+ } ) ;
928+ map . on ( 'moveend' , function ( ) {
929+ window . localStorage . setItem ( "lastpos" , JSON . stringify ( map . getCenter ( ) ) ) ;
930+ var b = map . getBounds ( ) ;
931+ if ( b . _southWest . lat !== oldBounds . sw . lat && b . _southWest . lng !== oldBounds . sw . lng && b . _northEast . lat !== oldBounds . ne . lat && b . _northEast . lng !== oldBounds . ne . lng ) {
932+ ws . send ( JSON . stringify ( { action :"bounds" , south :b . _southWest . lat , west :b . _southWest . lng , north :b . _northEast . lat , east :b . _northEast . lng , zoom :map . getZoom ( ) } ) ) ;
933+ oldBounds = { sw :{ lat :b . _southWest . lat , lng :b . _southWest . lng } , ne :{ lat :b . _northEast . lat , lng :b . _northEast . lng } } ;
934+ }
935+ edgeAware ( ) ;
936+ pickMapLayer ( ) ;
934937} ) ;
935938map . on ( 'locationfound' , onLocationFound ) ;
936939map . on ( 'locationerror' , onLocationError ) ;
0 commit comments