From 342a0d22bd1dc8843009616aba7d138841909991 Mon Sep 17 00:00:00 2001 From: DennisSchiefer Date: Wed, 28 Mar 2012 10:51:54 +0100 Subject: [PATCH] - removed bug in centering routes when UI was hidden - moved all browser dependencies to OSRM.Browser - refactored via code to use Leaflet functions - added function to extract route layerPoints --- WebContent/OSRM.Browser.js | 17 +++++++++-- WebContent/OSRM.Geocoder.js | 1 - WebContent/OSRM.Route.js | 38 +++++++++++++---------- WebContent/{via.js => OSRM.Via.js} | 32 ++++++++++++-------- WebContent/main.html | 2 +- WebContent/utils.js | 48 ------------------------------ 6 files changed, 57 insertions(+), 81 deletions(-) rename WebContent/{via.js => OSRM.Via.js} (70%) diff --git a/WebContent/OSRM.Browser.js b/WebContent/OSRM.Browser.js index 29de462c3..90459869c 100644 --- a/WebContent/OSRM.Browser.js +++ b/WebContent/OSRM.Browser.js @@ -15,10 +15,11 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA or see http://www.gnu.org/licenses/agpl.txt. */ -// OSRM browser detection -// [simple detection routines to respect some browser peculiarities] +// OSRM old browser support +// [simple browser detection and routines to support some old browsers] +// browser detection (runs anonymous function to prevent local variables cluttering global namespace) (function() { var useragent = navigator.userAgent; @@ -28,4 +29,14 @@ or see http://www.gnu.org/licenses/agpl.txt. }; }()); -// (runs anonymous function to prevent local variables cluttering global namespace) \ No newline at end of file + +// compatibility tools for old browsers +function getElementsByClassName(node, classname) { + var a = []; + var re = new RegExp('(^| )'+classname+'( |$)'); + var els = node.getElementsByTagName("*"); + for(var i=0,j=els.length; i nearest_index) { new_via_index = i; break; @@ -60,4 +66,6 @@ function findViaPosition( new_via_position ) { getRoute(OSRM.C.FULL_DESCRIPTION); return new_via_index; -} \ No newline at end of file +} + +}; \ No newline at end of file diff --git a/WebContent/main.html b/WebContent/main.html index be0b68cf4..14dd67d2c 100644 --- a/WebContent/main.html +++ b/WebContent/main.html @@ -57,7 +57,7 @@ or see http://www.gnu.org/licenses/agpl.txt. - + diff --git a/WebContent/utils.js b/WebContent/utils.js index ccccbb82c..a0d609221 100644 --- a/WebContent/utils.js +++ b/WebContent/utils.js @@ -15,19 +15,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA or see http://www.gnu.org/licenses/agpl.txt. */ -// compatibility tools for old browsers -function getElementsByClassName(node, classname) { - var a = []; - var re = new RegExp('(^| )'+classname+'( |$)'); - var els = node.getElementsByTagName("*"); - for(var i=0,j=els.length; i= Math.min(x0, x1) && o.x <= Math.max(x0, x1) && o.y >= Math.min(y0, y1) && o.y <= Math.max(y0, y1))){ - var l1 = lineLength(x, y, x0, y0), l2 = lineLength(x, y, x1, y1); - return l1 > l2 ? l2 : l1; - } - else { - var a = y0 - y1, b = x1 - x0, c = x0 * y1 - y0 * x1; - return Math.abs(a * x + b * y + c) / Math.sqrt(a * a + b * b); - } -}; \ No newline at end of file