From: Tom Hughes Date: Mon, 28 Sep 2015 12:42:00 +0000 (+0100) Subject: Move the MapQuest API key to the configuration file X-Git-Tag: live~3978 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/7dd23a4b5637cce3723abc242ea961841d835305?ds=sidebyside Move the MapQuest API key to the configuration file --- diff --git a/app/assets/javascripts/index/directions/mapquest.js b/app/assets/javascripts/index/directions/mapquest.js index fbbc55a5f..d667ea4e4 100644 --- a/app/assets/javascripts/index/directions/mapquest.js +++ b/app/assets/javascripts/index/directions/mapquest.js @@ -32,9 +32,10 @@ function MapQuestEngine(id, vehicleParam) { draggable: false, getRoute: function (points, callback) { - var url = document.location.protocol + "//open.mapquestapi.com/directions/v2/route?key=Fmjtd%7Cluur290anu%2Crl%3Do5-908a0y"; + var url = document.location.protocol + "//open.mapquestapi.com/directions/v2/route"; var from = points[0]; var to = points[points.length - 1]; + url += "?key=" + OSM.MAPQUEST_KEY; url += "&from=" + from.lat + ',' + from.lng; url += "&to=" + to.lat + ',' + to.lng; url += "&" + vehicleParam; @@ -90,6 +91,8 @@ function MapQuestEngine(id, vehicleParam) { }; } -OSM.Directions.addEngine(new MapQuestEngine("mapquest_bicycle", "routeType=bicycle"), true); -OSM.Directions.addEngine(new MapQuestEngine("mapquest_foot", "routeType=pedestrian"), true); -OSM.Directions.addEngine(new MapQuestEngine("mapquest_car", "routeType=fastest"), true); +if (OSM.MAPQUEST_KEY) { + OSM.Directions.addEngine(new MapQuestEngine("mapquest_bicycle", "routeType=bicycle"), true); + OSM.Directions.addEngine(new MapQuestEngine("mapquest_foot", "routeType=pedestrian"), true); + OSM.Directions.addEngine(new MapQuestEngine("mapquest_car", "routeType=fastest"), true); +} diff --git a/app/assets/javascripts/osm.js.erb b/app/assets/javascripts/osm.js.erb index 6afebf8e5..93faad8d1 100644 --- a/app/assets/javascripts/osm.js.erb +++ b/app/assets/javascripts/osm.js.erb @@ -10,6 +10,7 @@ OSM = { MAX_NOTE_REQUEST_AREA: <%= MAX_NOTE_REQUEST_AREA.to_json %>, OVERPASS_URL: <%= OVERPASS_URL.to_json %>, NOMINATIM_URL: <%= NOMINATIM_URL.to_json %>, + MAPQUEST_KEY: <%= MAPQUEST_KEY.to_json %>, MARKER_GREEN: <%= image_path("marker-green.png").to_json %>, MARKER_RED: <%= image_path("marker-red.png").to_json %>, diff --git a/config/example.application.yml b/config/example.application.yml index 7435fea89..59980cdf3 100644 --- a/config/example.application.yml +++ b/config/example.application.yml @@ -98,6 +98,8 @@ defaults: &defaults #facebook_auth_secret: "" #windowslive_auth_id: "" #windowslive_auth_secret: "" + # MapQuest authentication details + #mapquest_key: "" development: <<: *defaults