From f571b5c7e550e1cc2be5cdb880b2408b4b5928ad Mon Sep 17 00:00:00 2001 From: DennisSchiefer Date: Wed, 22 Aug 2012 07:25:45 +0100 Subject: [PATCH] circumvent leaflet racing condition #918 by switching off animation during initialization --- WebContent/base/OSRM.Map.js | 10 ++++++++-- WebContent/main.js | 3 +++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/WebContent/base/OSRM.Map.js b/WebContent/base/OSRM.Map.js index 1b6b0154b..1a96fb774 100644 --- a/WebContent/base/OSRM.Map.js +++ b/WebContent/base/OSRM.Map.js @@ -51,8 +51,8 @@ init: function() { center: new L.LatLng(OSRM.DEFAULTS.ONLOAD_LATITUDE, OSRM.DEFAULTS.ONLOAD_LONGITUDE), zoom: OSRM.DEFAULTS.ONLOAD_ZOOM_LEVEL, layers: [base_maps[tile_servers[0].display_name]], - zoomAnimation: true, // remove animations -> routes are not hidden during zoom - fadeAnimation: true + zoomAnimation: false, // animations have to be inactive during initialization (leaflet issue #918) + fadeAnimation: false }); // add layer control @@ -75,6 +75,12 @@ init: function() { OSRM.G.map.on('contextmenu', OSRM.Map.contextmenu ); OSRM.G.map.on('mousemove', OSRM.Map.mousemove ); }, +initFinally: function() { + L.Util.setOptions( OSRM.G.map, { + zoomAnimation: true, + fadeAnimation: true + } ); +}, // init map position and zoom (respect UI visibility / use browser geolocation) initPosition: function() { diff --git a/WebContent/main.js b/WebContent/main.js index e1cc52f1c..c581b785a 100644 --- a/WebContent/main.js +++ b/WebContent/main.js @@ -42,6 +42,9 @@ OSRM.init = function() { // only init default position / geolocation position if GET parameters do not specify a different one if( OSRM.G.initial_position_override == false ) OSRM.Map.initPosition(); + + // finalize initialization of map + OSRM.Map.initFinally(); };