I am able to load kml/kmz files using KmlLayer of the v4.25 javascript SDK. The issue is some images within the KML cause CORS errors. I would like to programmatically update the image URL to a locally hosted copy of the image during kml layer load. I just can't determine where/how to find the images within the layer.
Code to load the layer:
[esri.views.2d.engine.webgl.mesh.templates.WGLTemplateStore] s {name: 'mapview-invalid-resource', details: undefined, message: 'Could not fetch requested resource at https:…ages/modis_mod14/modis_prev_6_days_fire.png.'}
I want to change the path from:
https://fsapps.nwcg.gov/afm/data/kml/images/modis_mod14/modis_prev_6_days_fire.png
To:
https://{myappdomain.com}/images/modis_prev_6_days_fire.png
Solved! Go to Solution.
It seems to me you could use esriConfig.request.interceptors to do this. If so, it would look something like:
require(["esri/config", function(esriConfig) {
esriConfig.request.interceptors.push({
urls: "https://fsapps.nwcg.gov/afm/data/kml/images/",
before: function(params) {
params.url = "https://myServer/images" + params.url.substr(params.url.lastIndexOf("/"));
return null;
}
});
});
It seems to me you could use esriConfig.request.interceptors to do this. If so, it would look something like:
require(["esri/config", function(esriConfig) {
esriConfig.request.interceptors.push({
urls: "https://fsapps.nwcg.gov/afm/data/kml/images/",
before: function(params) {
params.url = "https://myServer/images" + params.url.substr(params.url.lastIndexOf("/"));
return null;
}
});
});
I think this is what I'm looking for. Thanks for the quick reply.