scraly/developers-conferences-agenda

Unable to get geocode for location

Closed this issue · 2 comments

I've got two troubles to identify geocoding even if it's working on openstreetmap website

Unable to get geocode for location:  Tacoma, WA (USA)
Unable to get geocode for location:  Burlington, VT (USA)
Unable to get geocode for location:  Yogyakarta (Indonesia)
Unable to get geocode for location:  Hyderabad (India)
Unable to get geocode for location:  Metro Manila (Philippines)
* 20: [GitHub Field Philippines](https://githubfieldday.com/ph2024/) - Philippines

Upon deeper inspection, not providing 'User-Agent' header violates OSM Policy:
image

This works:

const fetch = require('fix-esm').require('node-fetch').default;

const NodeGeocoder = require('node-geocoder');
let options = {
  provider: 'openstreetmap',
  fetch(url, options) {
    return fetch(url, {...options, headers: { 'user-agent': 'dca-0' }})
  }
};

const geocoder = NodeGeocoder(options);
const locations = ['Tacoma, WA (USA)'];

geocoder.batchGeocode(locations).then(result => {
  console.dir(result, {depth:null});
});

Thanks!
Fixed in commit: eb3f093

dca-0 is a good idea for a unique user-agent thanks :)