From 26262541a4ff90a03ade41aded5849e93b532539 Mon Sep 17 00:00:00 2001 From: shiin Date: Tue, 15 May 2012 21:03:58 +0200 Subject: [PATCH] completed language-dependent bing maps --- WebContent/OSRM.config.js | 18 ++++++++++-------- WebContent/base/OSRM.Map.js | 2 +- .../leaflet/L.TileLayer.Bing.js} | 10 ++++++++-- WebContent/localization/OSRM.Localization.js | 13 +++---------- WebContent/main.html | 2 +- WebContent/printing/OSRM.Printing.js | 1 + WebContent/printing/printing.html | 2 +- WebContent/printing/printing.js | 3 ++- 8 files changed, 27 insertions(+), 24 deletions(-) rename WebContent/{leaflet/TileLayer.Bing.js => base/leaflet/L.TileLayer.Bing.js} (95%) diff --git a/WebContent/OSRM.config.js b/WebContent/OSRM.config.js index 4f21e636d..2aff5eaba 100644 --- a/WebContent/OSRM.config.js +++ b/WebContent/OSRM.config.js @@ -43,12 +43,12 @@ OSRM.DEFAULTS = { LANGUAGE: "en", LANUGAGE_ONDEMAND_RELOADING: true, LANGUAGE_SUPPORTED: [ - {encoding:"en", name:"English", culture:"en-US"}, - {encoding:"de", name:"Deutsch", culture:"de-DE"}, - {encoding:"dk", name:"Dansk", culture:"en-US"}, - {encoding:"fi", name:"Suomi", culture:"en-US"}, - {encoding:"fr", name:"Français", culture:"fr-FR"}, - {encoding:"it", name:"Italiano", culture:"it-IT"}, + {encoding:"en", name:"English"}, + {encoding:"de", name:"Deutsch"}, + {encoding:"dk", name:"Dansk"}, + {encoding:"fi", name:"Suomi"}, + {encoding:"fr", name:"Français"}, + {encoding:"it", name:"Italiano"}, {encoding:"pl", name:"Polski", culture:"en-US"} ], @@ -75,14 +75,16 @@ OSRM.DEFAULTS = { }, { display_name: 'Bing Road', - apikey:'AjCb2f6Azv_xt9c6pl_xok96bgAYrXQNctnG4o07sTj4iS9N68Za4B3pRJyeCjGr', + apikey:'AjCb2f6Azv_xt9c6pl_xok96bgAYrXQNctnG4o07sTj4iS9N68Za4B3pRJyeCjGr', // please use your own apikey (http://msdn.microsoft.com/en-us/library/ff428642.aspx) type:"Road", + options:{minZoom: 1}, bing:true, }, { display_name: 'Bing Aerial', - apikey:'AjCb2f6Azv_xt9c6pl_xok96bgAYrXQNctnG4o07sTj4iS9N68Za4B3pRJyeCjGr', + apikey:'AjCb2f6Azv_xt9c6pl_xok96bgAYrXQNctnG4o07sTj4iS9N68Za4B3pRJyeCjGr', // please use your own apikey (http://msdn.microsoft.com/en-us/library/ff428642.aspx) type:"Aerial", + options:{minZoom: 1}, bing:true, } ] diff --git a/WebContent/base/OSRM.Map.js b/WebContent/base/OSRM.Map.js index 848a71363..414f8a01a 100644 --- a/WebContent/base/OSRM.Map.js +++ b/WebContent/base/OSRM.Map.js @@ -37,7 +37,7 @@ init: function() { var base_maps = {}; for(var i=0, size=tile_servers.length; i' + 'Terms of Use', + + supportedCultures: {"en":"en-US", "de":"de-DE", "fr":"fr-FR", "it":"it-IT", "es":"es-ES", "nl":"nl-BE"}, initialize: function(/*String*/ apiKey, /*String*/ mapType, /*Object*/ options) { @@ -42,6 +44,11 @@ L.TileLayer.Bing = L.TileLayer.extend({ L.Util.setOptions(this, options); }, + redraw: function() { + this._reset(); + this._update(); + }, + _loadMetadata: function() { this._callbackId = "_l_tilelayer_bing_" + (L.TileLayer.Bing._callbackId++); var that = this; @@ -110,8 +117,7 @@ L.TileLayer.Bing = L.TileLayer.extend({ } return this._url - //.replace('{culture}', OSRM.Localization.current_culture) - .replace('{culture}', "en-US") + .replace('{culture}', this.supportedCultures[OSRM.Localization.current_language] || "en-US" ) .replace('{subdomain}', subdomains[(xy.x + xy.y) % subdomains.length]) .replace('{quadkey}', quadDigits.join("")); }, diff --git a/WebContent/localization/OSRM.Localization.js b/WebContent/localization/OSRM.Localization.js index 69ff58aff..25bc56901 100644 --- a/WebContent/localization/OSRM.Localization.js +++ b/WebContent/localization/OSRM.Localization.js @@ -52,21 +52,14 @@ setLanguage: function(language) { // change value of both language selectors OSRM.GUI.selectorChange( document.getElementById('gui-language-toggle'), language ); OSRM.GUI.selectorChange( document.getElementById('gui-language-2-toggle'), language ); -// // change culture value -// OSRM.Localization.current_culture = language+"-"+language; -// var supported_languages = OSRM.DEFAULTS.LANGUAGE_SUPPORTED; -// for(var i=0, size=supported_languages.length; i - + diff --git a/WebContent/printing/OSRM.Printing.js b/WebContent/printing/OSRM.Printing.js index 5787b1f19..081f1b8bf 100644 --- a/WebContent/printing/OSRM.Printing.js +++ b/WebContent/printing/OSRM.Printing.js @@ -231,6 +231,7 @@ printWindowLoaded: function(){ } // localization + print_window.OSRM.Localization.current_language = OSRM.Localization.current_language; print_document.getElementById('description-label').innerHTML = OSRM.loc( "ROUTE_DESCRIPTION" ); print_document.getElementById('overview-map-label').innerHTML = OSRM.loc( "OVERVIEW_MAP" ); if( !OSRM.G.route.isRoute() || !OSRM.G.route.isShown() ) { // error message if no route available (can trigger if user refreshes print-window) diff --git a/WebContent/printing/printing.html b/WebContent/printing/printing.html index 9ce67d8ae..b22418c94 100644 --- a/WebContent/printing/printing.html +++ b/WebContent/printing/printing.html @@ -38,10 +38,10 @@ or see http://www.gnu.org/licenses/agpl.txt. - + diff --git a/WebContent/printing/printing.js b/WebContent/printing/printing.js index 1480a8efc..93d549a30 100644 --- a/WebContent/printing/printing.js +++ b/WebContent/printing/printing.js @@ -20,6 +20,7 @@ or see http://www.gnu.org/licenses/agpl.txt. OSRM = {}; OSRM.GLOBALS = { main_handle:{boxVisible:function(){return false;}} }; // needed for fitBoundsUI to work +OSRM.Localization = { current_language:"en"}; // needed for localized map tiles OSRM.G = OSRM.GLOBALS; @@ -54,7 +55,7 @@ OSRM.prefetchIcons = function(images_list) { OSRM.drawMap = function(tile_server, bounds) { // setup map var tile_layer; - if( tile_server.bing ) tile_layer = new L.TileLayer.Bing(tile_server.apikey, tile_server.type); + if( tile_server.bing ) tile_layer = new L.TileLayer.Bing(tile_server.apikey, tile_server.type, tile_server.options); else tile_layer = new L.TileLayer(tile_server.url, tile_server.options); OSRM.G.map = new OSRM.MapView("overview-map", { center: new L.LatLng(48.84, 10.10),