From: Tom Hughes Date: Mon, 11 Jan 2016 19:03:47 +0000 (+0000) Subject: Move routing API endpoint addresses to config file X-Git-Tag: live~3917 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/e128e78408561cb0fc319f17eb39c34e579bedad Move routing API endpoint addresses to config file --- diff --git a/app/assets/javascripts/index/directions/graphhopper.js b/app/assets/javascripts/index/directions/graphhopper.js index 2d3455eee..c35085b35 100644 --- a/app/assets/javascripts/index/directions/graphhopper.js +++ b/app/assets/javascripts/index/directions/graphhopper.js @@ -21,7 +21,7 @@ function GraphHopperEngine(id, vehicleType) { // GraphHopper Directions API documentation // https://github.com/graphhopper/directions-api/blob/master/docs-routing.md return $.ajax({ - url: document.location.protocol + "//graphhopper.com/api/1/route", + url: document.location.protocol + OSM.GRAPHHOPPER_URL, data: { vehicle: vehicleType, locale: I18n.currentLocale(), diff --git a/app/assets/javascripts/index/directions/mapquest.js b/app/assets/javascripts/index/directions/mapquest.js index f46d94dcf..0f645ceeb 100644 --- a/app/assets/javascripts/index/directions/mapquest.js +++ b/app/assets/javascripts/index/directions/mapquest.js @@ -36,7 +36,7 @@ function MapQuestEngine(id, routeType) { var to = points[points.length - 1]; return $.ajax({ - url: document.location.protocol + "//open.mapquestapi.com/directions/v2/route", + url: document.location.protocol + OSM.MAPQUEST_DIRECTIONS_URL, data: { key: OSM.MAPQUEST_KEY, from: from.lat + "," + from.lng, diff --git a/app/assets/javascripts/index/directions/mapzen.js b/app/assets/javascripts/index/directions/mapzen.js index 73643ba46..348cb99c9 100644 --- a/app/assets/javascripts/index/directions/mapzen.js +++ b/app/assets/javascripts/index/directions/mapzen.js @@ -39,7 +39,7 @@ function MapzenEngine(id, costing) { getRoute: function (points, callback) { return $.ajax({ - url: document.location.protocol + "//valhalla.mapzen.com/route", + url: document.location.protocol + OSM.MAPZEN_VALHALLA_URL, data: { api_key: OSM.MAPZEN_VALHALLA_KEY, json: JSON.stringify({ diff --git a/app/assets/javascripts/index/directions/osrm.js b/app/assets/javascripts/index/directions/osrm.js index d9ce0a6b1..2ee9da12b 100644 --- a/app/assets/javascripts/index/directions/osrm.js +++ b/app/assets/javascripts/index/directions/osrm.js @@ -51,7 +51,7 @@ function OSRMEngine() { } return $.ajax({ - url: document.location.protocol + "//router.project-osrm.org/viaroute", + url: document.location.protocol + OSM.OSRM_URL, data: params, dataType: "json", success: function (data) { diff --git a/app/assets/javascripts/osm.js.erb b/app/assets/javascripts/osm.js.erb index 6a8b856be..138416be1 100644 --- a/app/assets/javascripts/osm.js.erb +++ b/app/assets/javascripts/osm.js.erb @@ -2,34 +2,38 @@ OSM = { <% if defined?(PIWIK) %> - PIWIK: <%= PIWIK.to_json %>, + PIWIK: <%= PIWIK.to_json %>, <% end %> - MAX_REQUEST_AREA: <%= MAX_REQUEST_AREA.to_json %>, - SERVER_URL: <%= SERVER_URL.to_json %>, - API_VERSION: <%= API_VERSION.to_json %>, - STATUS: <%= STATUS.to_json %>, - MAX_NOTE_REQUEST_AREA: <%= MAX_NOTE_REQUEST_AREA.to_json %>, - OVERPASS_URL: <%= OVERPASS_URL.to_json %>, - NOMINATIM_URL: <%= NOMINATIM_URL.to_json %>, + MAX_REQUEST_AREA: <%= MAX_REQUEST_AREA.to_json %>, + SERVER_URL: <%= SERVER_URL.to_json %>, + API_VERSION: <%= API_VERSION.to_json %>, + STATUS: <%= STATUS.to_json %>, + MAX_NOTE_REQUEST_AREA: <%= MAX_NOTE_REQUEST_AREA.to_json %>, + OVERPASS_URL: <%= OVERPASS_URL.to_json %>, + NOMINATIM_URL: <%= NOMINATIM_URL.to_json %>, + GRAPHHOPPER_URL: <%= GRAPHHOPPER_URL.to_json %>, + MAPQUEST_DIRECTIONS_URL: <%= MAPQUEST_DIRECTIONS_URL.to_json %>, + MAPZEN_VALHALLA_URL: <%= MAPZEN_VALHALLA_URL.to_json %>, + OSRM_URL: <%= OSRM_URL.to_json %>, <% if defined?(MAPQUEST_KEY) %> - MAPQUEST_KEY: <%= MAPQUEST_KEY.to_json %>, + MAPQUEST_KEY: <%= MAPQUEST_KEY.to_json %>, <% end %> <% if defined?(MAPZEN_VALHALLA_KEY) %> - MAPZEN_VALHALLA_KEY: <%= MAPZEN_VALHALLA_KEY.to_json %>, + MAPZEN_VALHALLA_KEY: <%= MAPZEN_VALHALLA_KEY.to_json %>, <% end %> - MARKER_GREEN: <%= image_path("marker-green.png").to_json %>, - MARKER_RED: <%= image_path("marker-red.png").to_json %>, + MARKER_GREEN: <%= image_path("marker-green.png").to_json %>, + MARKER_RED: <%= image_path("marker-red.png").to_json %>, - MARKER_ICON: <%= image_path("images/marker-icon.png").to_json %>, - MARKER_ICON_2X: <%= image_path("images/marker-icon-2x.png").to_json %>, - MARKER_SHADOW: <%= image_path("images/marker-shadow.png").to_json %>, + MARKER_ICON: <%= image_path("images/marker-icon.png").to_json %>, + MARKER_ICON_2X: <%= image_path("images/marker-icon-2x.png").to_json %>, + MARKER_SHADOW: <%= image_path("images/marker-shadow.png").to_json %>, - NEW_NOTE_MARKER: <%= image_path("new_note_marker.png").to_json %>, - OPEN_NOTE_MARKER: <%= image_path("open_note_marker.png").to_json %>, - CLOSED_NOTE_MARKER: <%= image_path("closed_note_marker.png").to_json %>, + NEW_NOTE_MARKER: <%= image_path("new_note_marker.png").to_json %>, + OPEN_NOTE_MARKER: <%= image_path("open_note_marker.png").to_json %>, + CLOSED_NOTE_MARKER: <%= image_path("closed_note_marker.png").to_json %>, apiUrl: function (object) { var url = "/api/" + OSM.API_VERSION + "/" + object.type + "/" + object.id;