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
6 changes: 5 additions & 1 deletion scripts/replace.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ const fs = require('fs')
const path = require('path')

// Define filepaths
const indexJsFile = path.join(__dirname, '..', 'src', 'index.js')
const leafletOptions = path.join(__dirname, '..', 'src', 'leaflet_options.js')
const debug = path.join(__dirname, '..', 'debug', 'index.html')

// Read & Replace options
for (const filepath of [leafletOptions, debug]) {
for (const filepath of [indexJsFile, leafletOptions, debug]) {
let options = fs.readFileSync(filepath, 'utf8')

// Define Environment variables
Expand All @@ -21,6 +22,7 @@ for (const filepath of [leafletOptions, debug]) {
const LANGUAGE = process.env.OSRM_LANGUAGE || 'en'
const DEFAULT_LAYER = process.env.OSRM_DEFAULT_LAYER || 'streets'
const MAPBOX_TOKEN = process.env.OSRM_MAPBOX_TOKEN || 'pk.eyJ1IjoibXNsZWUiLCJhIjoiclpiTWV5SSJ9.P_h8r37vD8jpIH1A6i1VRg'
const NOMINATIM_ENDPOINT = process.env.NOMINATIM_ENDPOINT || 'https://nominatim.openstreetmap.org/'

// Edit Leaflet Options
if (BACKEND) options = options.replace(/http[s]?:\/\/router\.project-osrm\.org/, BACKEND)
Expand All @@ -42,6 +44,8 @@ for (const filepath of [leafletOptions, debug]) {
else options = options.replace('38.8995,-77.0269', latlng)
}

if (NOMINATIM_ENDPOINT) options = options.replace('https://nominatim.openstreetmap.org/', NOMINATIM_ENDPOINT)

// Save Leaflet Options
fs.writeFileSync(filepath, options)
}
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function makeIcon(i, n) {
}
}
var plan = new ReversablePlan([], {
geocoder: L.Control.Geocoder.nominatim(),
geocoder: L.Control.Geocoder.nominatim({serviceUrl: 'https://nominatim.openstreetmap.org/'}),
routeWhileDragging: true,
createMarker: function(i, wp, n) {
var options = {
Expand Down