Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions scripts/replace.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

options is not provided option but managed in this repository, so I think it is not needed to accept the one without trailing slash(/).


return options
}
Expand Down
4 changes: 2 additions & 2 deletions src/geocoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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});
Comment on lines +44 to +45
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nominatimUrl will never be undefined or empty as there is default value. Do we need it?


function withCallback(promise, cb, context) {
return promise.then(function(results) {
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function makeIcon(i, n) {
}
}
var plan = new ReversablePlan([], {
geocoder: createGeocoder.coordPreserving(),
geocoder: createGeocoder.coordPreserving(leafletOptions.nominatim && leafletOptions.nominatim.path),
routeWhileDragging: true,
createMarker: function(i, wp, n) {
var options = {
Expand Down
3 changes: 3 additions & 0 deletions src/leaflet_options.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,8 @@ module.exports = {
three: satellite,
four: osm,
five: osm_de
},
nominatim: {
path: 'https://nominatim.openstreetmap.org/'
}
Comment on lines +68 to 71
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test/leaflet_options.test.js looks like not having this kind of test for other parameters

};