Select to view content in your preferred language

PictureMarkerSymbol loading issues

53
3
yesterday
Aeseir
by
Occasional Contributor II

We have a situation where some of the older image URLs are getting new CORS settings added to them, due to this naturally the PictureMarkerSymbol fails to load as the domain doesn't align. 

Is there any way to catch this error before it tries to put it on the map so that we can identify the image in question and get the cors remediated?

0 Kudos
3 Replies
TonyAbo
New Contributor II

I'm not exactly sure what you do or do not want in your CORS headers, but adding your image server to the esriConfig.request.trustedServers array may solve the problem.  Otherwise, you can use esriConfig.request.interceptors to add code that will be run before requests to a particular URL that can examine and change the request parameters, including headers, body, query string, etc.  to whatever you want.

See https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#request

Aeseir
by
Occasional Contributor II

Let me explain the whole situation. Essentially scenario is we have users that add their own images to map using PictureMarkerSymbol.
We advise in advance that they need to ensure image url CORS allow our domain, headers etc, before they add it in, otherwise it won't work. We then store all these Graphics as JSON array, and load them as needed.


Recently some users raised instances of Images failing to load with CORS messages appearing in console, because their cors settings changed.

 

What we want to do is when a graphic is created from JSON, before or during load process (i.e. adding it to graphicslayer) to alert that this won't work due to CORS access issues.



I been going over the documentation to see if the there is a trycatch kind of scenario we can use but so far no luck.

0 Kudos
TonyAbo
New Contributor II

Well then maybe you want to use esriConfig.request.interceptors errorCallBack to check for the error, or maybe the afterCallBack to change the failed image to some kind of stock broken link image to give the user a visual clue that the image did not load.