Skip to content

Commit

Permalink
AGOL Arcgis layers are working now
Browse files Browse the repository at this point in the history
  • Loading branch information
EricSoroos committed May 14, 2024
1 parent a63131c commit f952b7c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions ckanext/geoview/public/js/ol_preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@

var esrirestExtractor = function(resource, proxyUrl, proxyServiceUrl, layerProcessor, map) {
var parsedUrl = resource.url.split('#');
var url = proxyServiceUrl || parsedUrl[0];
var url = parsedUrl[0]; // proxy urls don't work with ckan's resource proxy and the /query added on at the end.

var layerName = parsedUrl.length > 1 && parsedUrl[1];
var proxifyFn = (_url) => _url.includes('/query') ? url + _url : proxyServiceUrl + _url;

OL_HELPERS.withArcGisLayers(url, layerProcessor, layerName, parsedUrl[0]);
OL_HELPERS.withArcGisLayers('', layerProcessor, layerName, proxifyFn, map);
}

ckan.geoview.layerExtractors = {
Expand Down
4 changes: 3 additions & 1 deletion ckanext/geoview/public/js/vendor/ol-helpers/ol-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2388,7 +2388,9 @@ ol.proj.addProjection(createEPSG4326Proj('EPSG:4326:LONLAT', 'enu'));
layer.getSource().setState(ol.source.State.LOADING)

return fetch(url + (url.indexOf('?') >= 0 ? '&' : '?') + kvp2string(queryParams),
{method:'GET', credentials: 'include'}
{method:'GET'}
// can't use credentials:include here with AGOL, because they send back
// Access-Control-Allow-Origin: *, and the combination doesn't work.
).then(
function (response) {
return response.text();
Expand Down

0 comments on commit f952b7c

Please sign in to comment.