I have an application that is using ESRI for leaflet to pull in MapServices. I can successfully pull in map services and render in my application. However, sometimes the map services return an error (400, 500, etc). When this occurs I can no longer click on other data I am showing on the map (geojson data coming from a MongoDB). Is there a way to handle these errors so they do not interfere with the user experience?
1 Answer
if the services are returning errors intermittently when you attempt to load them, my suggestions in the issue below should be helpful.
https://github.com/Esri/esri-leaflet/issues/705
if something else is going on, please provide a little more info (particularly im interested in what type of services you're loading and what specific types of requests are failing.
-
This is a beautiful solution for the services that have MetaData as a child resource. Any ideas on how to handle services that do not? An example of such a service is geocommunicator.gov/ArcGIS/rest/services/PLSS/MapServer– shaneCommented Mar 23, 2016 at 16:10
-
This is the error I am getting XMLHttpRequest cannot load geocommunicator.gov/ArcGIS/rest/services/PLSS/MapServer/?f=json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'localhost:3000' is therefore not allowed access.– shaneCommented Mar 23, 2016 at 16:18
-
we don't look for a metadata child resource, we make an 'f=json' request to the service itself: jsbin.com/sizujicera/edit?html,output Commented Mar 23, 2016 at 16:20
-
that's because your web server doesn't support CORS. see my jsbin for a working example. Commented Mar 23, 2016 at 16:20
-
Ahh, some of the services do support CORS, some do not. Working perfectly now, thanks for the help!– shaneCommented Mar 23, 2016 at 17:15