Skip to content

Commit

Permalink
OSM naminatim URL (fixes #13)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasHalwax committed Aug 10, 2023
1 parent b6c2a91 commit d2d1fdd
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/renderer/store/Nominatim.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const Strategy = {
*/
export default function Nominatim (store) {
this.strategy = Strategy.sticky(store)
this.url = process.env.NOMINATIM_URL || 'https://nominatim.openstreetmap.org/search'
}

Nominatim.prototype.sync = async function (query) {
Expand Down Expand Up @@ -92,7 +93,7 @@ Nominatim.prototype.sync = async function (query) {

Nominatim.prototype.request = function (query) {
const options = {
formal: 'json',
format: 'json',
dedupe: 1,
polygon_geojson: 1,
limit: 20
Expand All @@ -115,11 +116,10 @@ Nominatim.prototype.request = function (query) {
}
})

const params = Object.entries(options)
.reduce((acc, [key, value]) => acc.concat([`${key}=${value}`]), ['format=json'])
.join('&')
const params = new URLSearchParams(options)
params.append('q', query)

const url = `https://nominatim.openstreetmap.org/search/${query}?${params}`
const url = `${this.url}?${params}`
const async = true
xhr.open('GET', url, async)
xhr.setRequestHeader('Accept-Language', 'de')
Expand Down

0 comments on commit d2d1fdd

Please sign in to comment.