From 007dd19ceceaef523ac0f0da4f167462f8e3c2a1 Mon Sep 17 00:00:00 2001 From: DennisSchiefer Date: Fri, 30 Mar 2012 10:10:51 +0100 Subject: [PATCH] added buttons to switch to JOSM and OSM Bugs, added getCenter function that respects UI visibility --- WebContent/OSRM.GUI.js | 3 +++ WebContent/OSRM.Localization.js | 8 ++++++-- WebContent/OSRM.Map.js | 8 ++++++++ WebContent/main.css | 13 +++++++++++++ WebContent/main.html | 15 ++++++++++----- WebContent/routing/OSRM.Routing.js | 2 +- WebContent/routing/OSRM.RoutingGUI.js | 21 +++++++++++++++++++++ 7 files changed, 62 insertions(+), 8 deletions(-) diff --git a/WebContent/OSRM.GUI.js b/WebContent/OSRM.GUI.js index 76ec2b682..b1ede611b 100644 --- a/WebContent/OSRM.GUI.js +++ b/WebContent/OSRM.GUI.js @@ -30,6 +30,9 @@ init: function() { OSRM.GUI.visible = true; OSRM.GUI.width = document.getElementById("main-wrapper").clientWidth; + // translate + document.getElementById("open-josm").innerHTML = OSRM.loc("OPEN_JOSM"); + document.getElementById("open-osmbugs").innerHTML = OSRM.loc("OPEN_OSMBUGS"); document.getElementById("gui-reset").innerHTML = OSRM.loc("GUI_RESET"); document.getElementById("gui-reverse").innerHTML = OSRM.loc("GUI_REVERSE"); document.getElementById("gui-option-highlight-nonames-label").innerHTML = OSRM.loc("GUI_HIGHLIGHT_UNNAMED_ROADS"); diff --git a/WebContent/OSRM.Localization.js b/WebContent/OSRM.Localization.js index 110d16bbb..6d377f38a 100644 --- a/WebContent/OSRM.Localization.js +++ b/WebContent/OSRM.Localization.js @@ -39,12 +39,14 @@ OSRM.loc = OSRM.Localization.translate; // German language support OSRM.Localization["de"] = { //gui +"OPEN_JOSM": "JOSM Öffnen", +"OPEN_OSMBUGS": "OSM Bugs Öffnen", "GUI_START": "Start", "GUI_END": "Ziel", "GUI_RESET": "Reset", "GUI_SEARCH": "Zeigen", "GUI_REVERSE": "Umdrehen", -"GUI_OPTIONS": "Optionen", +"GUI_OPTIONS": "Kartenwerkzeuge", "GUI_HIGHLIGHT_UNNAMED_ROADS": "Unbenannte Straßen hervorheben", "GUI_START_TOOLTIP": "Startposition eingeben", "GUI_END_TOOLTIP": "Zielposition eingeben", @@ -80,12 +82,14 @@ OSRM.Localization["de"] = { // English language support OSRM.Localization["en"] = { //gui +"OPEN_JOSM": "Open JOSM", +"OPEN_OSMBUGS": "Open OSM Bugs", "GUI_START": "Start", "GUI_END": "End", "GUI_RESET": "  Reset  ", "GUI_SEARCH": "  Show  ", "GUI_REVERSE": "Reverse", -"GUI_OPTIONS": "Options", +"GUI_OPTIONS": "Mapping Tools", "GUI_HIGHLIGHT_UNNAMED_ROADS": "Highlight unnamed streets", "GUI_START_TOOLTIP": "Enter start", "GUI_END_TOOLTIP": "Enter destination", diff --git a/WebContent/OSRM.Map.js b/WebContent/OSRM.Map.js index 727ad35aa..b57ab30cb 100644 --- a/WebContent/OSRM.Map.js +++ b/WebContent/OSRM.Map.js @@ -49,6 +49,14 @@ OSRM.MapView = L.Map.extend({ bounds.extend( OSRM.G.map.unproject(sw_point,zoom) ); bounds.extend( OSRM.G.map.unproject(ne_point,zoom) ); this.fitBounds( bounds ); + }, + getCenterUI: function(unbounded) { + var viewHalf = this.getSize(); + if( OSRM.GUI.visible == true ) + viewHalf.x += OSRM.GUI.width; + var centerPoint = this._getTopLeftPoint().add(viewHalf.divideBy(2)); + + return this.unproject(centerPoint, this._zoom, unbounded); } }); diff --git a/WebContent/main.css b/WebContent/main.css index 062bb3f9d..8d890f639 100644 --- a/WebContent/main.css +++ b/WebContent/main.css @@ -148,8 +148,21 @@ html, body, #map { .main-options { + position:relative; font-size:10px; } +.main-options-left-box +{ + position:absolute; + left:5px; + top:0px; +} +.main-options-right-box +{ + position:absolute; + right:5px; + top:5px; +} #options-toggle { cursor:pointer; diff --git a/WebContent/main.html b/WebContent/main.html index 7aa2047e2..cc451d7e9 100644 --- a/WebContent/main.html +++ b/WebContent/main.html @@ -113,11 +113,16 @@ or see http://www.gnu.org/licenses/agpl.txt. -
-
Options
-
- Unbenannte Straßen hervorheben -
+ Kartenwerkzeuge +
+ + Unbenannte Straßen hervorheben + + + JOSM Öffnen + OSM Bugs Öffnen + +
diff --git a/WebContent/routing/OSRM.Routing.js b/WebContent/routing/OSRM.Routing.js index ed5b8fd8e..2796d187d 100644 --- a/WebContent/routing/OSRM.Routing.js +++ b/WebContent/routing/OSRM.Routing.js @@ -143,6 +143,6 @@ _snapRoute: function() { OSRM.Geocoder.updateAddress(OSRM.C.SOURCE_LABEL); OSRM.Geocoder.updateAddress(OSRM.C.TARGET_LABEL); -}, +} }; \ No newline at end of file diff --git a/WebContent/routing/OSRM.RoutingGUI.js b/WebContent/routing/OSRM.RoutingGUI.js index ea5329270..bb2da16ad 100644 --- a/WebContent/routing/OSRM.RoutingGUI.js +++ b/WebContent/routing/OSRM.RoutingGUI.js @@ -89,6 +89,27 @@ inputChanged: function(marker_id) { OSRM.Geocoder.call(OSRM.C.SOURCE_LABEL, document.getElementById('input-source-name').value); else if( marker_id == OSRM.C.TARGET_LABEL) OSRM.Geocoder.call(OSRM.C.TARGET_LABEL, document.getElementById('input-target-name').value); +}, + +// click: button "open JOSM" +openJOSM: function() { + var x = OSRM.G.map.getCenterUI(); + var ydelta = 0.01; + var xdelta = ydelta * 2; + var p = [ 'left=' + (x.lng - xdelta), 'bottom=' + (x.lat - ydelta), 'right=' + (x.lng + xdelta), 'top=' + (x.lat + ydelta)]; + var url = 'http://localhost:8111/load_and_zoom?' + p.join('&'); + + var frame = L.DomUtil.create('iframe', null, document.body); + frame.style.width = frame.style.height = "0px"; + frame.src = url; + frame.onload = function(e) { document.body.removeChild(frame); }; +}, + +//click: button "open OSM Bugs" +openOSMBugs: function() { + var position = OSRM.G.map.getCenterUI(); + document.location.href = "http://osmbugs.org/?lat="+position.lat.toFixed(6)+"&lon="+position.lng.toFixed(6)+"&zoom="+OSRM.G.map.getZoom(); + //window.open( "http://osmbugs.org/?lat="+position.lat.toFixed(6)+"&lon="+position.lng.toFixed(6)+"&zoom="+OSRM.G.map.getZoom() ); } }; \ No newline at end of file