diff --git a/scripts/replace.js b/scripts/replace.js index cd61ca5a..8ed4c0d1 100755 --- a/scripts/replace.js +++ b/scripts/replace.js @@ -12,6 +12,7 @@ function applyReplacements(content, env) { const BACKEND = env.OSRM_BACKEND || 'https://router.project-osrm.org' const LANGUAGE = env.OSRM_LANGUAGE || 'en' const DEFAULT_LAYER = env.OSRM_DEFAULT_LAYER || 'streets' + const NOMINATIM_ENDPOINT = env.NOMINATIM_ENDPOINT || 'https://nominatim.openstreetmap.org/' let options = content @@ -34,6 +35,7 @@ function applyReplacements(content, env) { // Leaflet uses LatLng else options = options.replace('38.8995,-77.0269', latlng) } + if (NOMINATIM_ENDPOINT) options = options.replace('https://nominatim.openstreetmap.org/', NOMINATIM_ENDPOINT) return options } diff --git a/src/geocoder.js b/src/geocoder.js index 64ab79ba..784b5886 100644 --- a/src/geocoder.js +++ b/src/geocoder.js @@ -41,8 +41,8 @@ function parseCoords(query) { // For non-coordinate input, falls through to Nominatim forward-geocode as normal. // Also bridges leaflet-control-geocoder's Promise API to the callback-based API // that leaflet-routing-machine's autocomplete expects. -geocoder.coordPreserving = function() { - var nominatim = L.Control.Geocoder.nominatim(); +geocoder.coordPreserving = function(nominatimUrl) { + var nominatim = L.Control.Geocoder.nominatim({serviceUrl: nominatimUrl}); function withCallback(promise, cb, context) { return promise.then(function(results) { diff --git a/src/index.js b/src/index.js index faecb1cd..ae6bc64d 100644 --- a/src/index.js +++ b/src/index.js @@ -99,7 +99,7 @@ function makeIcon(i, n) { } } var plan = new ReversablePlan([], { - geocoder: createGeocoder.coordPreserving(), + geocoder: createGeocoder.coordPreserving(leafletOptions.nominatim.path), routeWhileDragging: true, createMarker: function(i, wp, n) { var options = { diff --git a/src/leaflet_options.js b/src/leaflet_options.js index e64ae929..dbe71cbe 100644 --- a/src/leaflet_options.js +++ b/src/leaflet_options.js @@ -65,5 +65,8 @@ module.exports = { three: satellite, four: osm, five: osm_de + }, + nominatim: { + path: 'https://nominatim.openstreetmap.org/' } };