Esri / esri-leaflet-geocoder

helpers for using the ArcGIS World Geocoding Service in Leaflet
http://esri.github.io/esri-leaflet/examples/geocoding-control.html
Apache License 2.0
242 stars 97 forks source link

Esri Leaflet Geocoder - SERVICE UNAVAILABLE - The service is temporarily overloaded. #207

Closed sjshank closed 6 years ago

sjshank commented 6 years ago

Hi,

I am using leaflet, esri-leaflet and leaflet-geocoder for rendering MAP, pointing geolocation on MAP and converting text address into lat long. However, I am oftenly receiving error from leaflet-geocoder while making calls to convert text address into geo location. Error : SERVICE UNAVAILABLE - The service is temporarily overloaded. 503 Server call : (XHR)GET - https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/find?outSr=4326&forStorage=false&outFields=*&maxLocations=20&text=80%20Victoria%20St%2C%20London%2C%20SW1E%205JL%2C%20United%20Kingdom&f=json

It's a random call getting failed.

var geocoder = window.L.esri.Geocoding.geocodeService();
var address = 'London, UK'
geocoder.geocode().text(address).run(function (error, response) {
if(response){.....}
});

can anyone help me out here ?

jgravois commented 6 years ago

if you update to the latest release you should experience more consistent behavior.

see #173 for more info.

jgravois commented 6 years ago

if you're calling the service over and over again to geocode addresses in bulk you'll need to pass forStorage=true&token=[your token] in your requests as well.

sjshank commented 6 years ago

Thank you John for solution. It worked. However, I need some info on token. How can I get a token without expiration date ? Did arcgis provide token on buying paid token ?

jgravois commented 6 years ago

happy to help.

How can I get a token without expiration date?

It isn't possible to create a token without an expiration date, but you can create a hosted service proxy to simplify authenticating/storing results.

// you'll need to create and substitute a service proxy of your own
const url = `https://utility.arcgis.com/usrsvcs/appservices/${yours}/rest/services/World/GeocodeServer/`;

const geocoder = L.esri.Geocoding.geocodeService({ url });
const address = 'London, UK'
geocoder.geocode().text(address).forStorage(true).run(function (error, response) {
  console.log(response)
});

You can find more information about authenticating in ArcGIS Online to access premium services:

if you're interested in batch geocoding, you might also want to check out ArcGIS REST JS.