]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/router.js
Supply hints for OSRM
[rails.git] / app / assets / javascripts / router.js
index 200edd2664fa94e4b9aeaf78bceff3bcab3e64ac..a05ed5a9d2474bf2136669936c1b21cde825de28 100644 (file)
@@ -113,14 +113,18 @@ OSM.Router = function(map, rts) {
       var path = url.replace(/#.*/, ''),
         route = routes.recognize(path);
       if (!route) return false;
-      window.history.pushState(OSM.parseHash(url), document.title, url);
       currentRoute.run('unload');
+      window.history.pushState(OSM.parseHash(url), document.title, url);
       currentPath = path;
       currentRoute = route;
       currentRoute.run('pushstate', currentPath);
       return true;
     };
 
+    router.replace = function (url) {
+      window.history.replaceState(OSM.parseHash(url), document.title, url);
+    };
+
     router.stateChange = function(state) {
       if (state.center) {
         window.history.replaceState(state, document.title, OSM.formatHash(state));
@@ -129,7 +133,7 @@ OSM.Router = function(map, rts) {
       }
     };
   } else {
-    router.route = function (url) {
+    router.route = router.replace = function (url) {
       window.location.assign(url);
     };
 
@@ -167,6 +171,11 @@ OSM.Router = function(map, rts) {
     router.stateChange(loadState || {});
   };
 
+  router.setCurrentPath = function (path) {
+    currentPath = path;
+    currentRoute = routes.recognize(currentPath);
+  };
+
   map.on('moveend baselayerchange overlaylayerchange', router.updateHash);
   $(window).on('hashchange', router.hashUpdated);