0

Trying to add an address list in ELG.geocode. error: Cannot read property '0' of undefined; (results)
Original: https://codesandbox.io/s/geocoding-in-react-leaflet-v3x-forked-uilpl?file=/src/MyMap.jsx:632-725

    ELG.geocode()
        .text(address)
        .run((err, results, response) => {
            console.log(results.results[0].latlng);
            const { lat, lng } = results.results[0].latlng;
            map.setView([lat, lng], 12);
            L.marker([lat, lng])
                .addTo(map)
                .bindPopup(address)
                .openPopup();
        });

    return null;
Seth Lutske
  • 9,154
  • 5
  • 29
  • 78
  • There is no error for me. I get the response as expected – kboul Jun 11 '21 at 13:58
  • Have You tried on local project or codesandbox? because on codesandbox it works correctly but on my local project doesn't work error: Cannot read property '0' of undefined; (results) – Raffaele Conte Jun 11 '21 at 14:09
  • I will try it now – kboul Jun 11 '21 at 14:10
  • works both locally and on codesandbox – kboul Jun 11 '21 at 14:32
  • working fine for me, at least on csb. i recommend checking the network tab of your browser as you load the page, and see that the call / response being made by esri is as you'd expect. you may find clues there as to why its not working. – Seth Lutske Jun 11 '21 at 16:04
  • {"error":{"code":499,"message":"Token Required","details":[]}} This is the error after call / response – Raffaele Conte Jun 14 '21 at 08:05

0 Answers0