AnsweredAssumed Answered

How to create a list of rasters contained in an image service

Question asked by jamiehollingsworth on Sep 22, 2016

it is a long story but this website was built a few years back using javscript 3.5 API and it is currently broken.  So i am hoping some really smart person out there can have a look and help me out .

 

Here is a link to full site.  GeoNIS  but the only location that has any data is AND, it is the top one on the list on the right hand side of page.  click it to zoom there.  or use this link  GeoNIS .

 

So here is the problem i am having ...I can not generate the list of rasters that are contained within the imageservice.  it seems like the problem is in the section where it is supposed to create a stack of images.  I included that section of code  below but you can get all the code from the website.  The rest of the functionality seems to be working.  there is a link for the mapservice with the vector data   there is a link to the imageservice with the raster data.  there are check boxes for each layer in the mapservice.  the images (0) is the problem there are four rasters in there.  the package list even works and shows all the information for each layer in both the mapservice and the imageservice.  

 

thanks

jamie

 

p.s.  the coding is pretty messy and it was not me.

 

// Create the image stack and click handlers for the image menu
$.getJSON(window.mapInfo.imageUrl + "?f=pjson&callback=?", function (response) {
if (!response.error) {
var imageParams = new esri.layers.ImageServiceParameters();
imageParams.noData = 0;
window.imageStack = new esri.layers.ArcGISImageServiceLayer(
mapInfo.imageUrl, {
id: 'imageStack',
imageServiceParameters: imageParams,
opacity: 0.75
}
);
window.imageLayer = true;
dojo.connect(imageStack, 'onLoad', function (images) {
var i, imageTitleLink, imageChecks;
imageTitleLink = $('<a />')
.attr('href', '#')
.text("Images (" + Object.keys(imageData).length + ")")
.click(function () {
$('#image-checks').slideToggle('fast');
});
$('#image-checks-title').prepend($('<p />').append(imageTitleLink));
imageChecks = $('<ul />').appendTo('#image-checks');
$.each(imageData, function () {
checkbox = $('<label />').text(this.layername).addClass('drop-down-font');
checkbox.prepend($('<input />')
.attr('type', 'checkbox')
.attr('name', 'checkbox-' + this.layername)
.attr('id', 'checkbox-' + this.layername)
.click({'layername': this.layername}, function (event) {
var visibleImage, mosaicRule;
if (embeddedMap.layerIds.indexOf('imageStack') !== -1) {
visibleImage =
imageStack.mosaicRule.where.split('=')[1].split('\'')[1];
}
mosaicRule = new esri.layers.MosaicRule({
"method": esri.layers.MosaicRule.METHOD_LOCKRASTER,
"ascending": true,
"operation": esri.layers.MosaicRule.OPERATION_FIRST,
"where": "Name='" + event.data.layername + "'"
});
imageStack.setMosaicRule(mosaicRule);
$(event.target).parents().eq(2).find(':checked').prop('checked', false);
$(event.target).prop('checked', true);
if (embeddedMap.layerIds.indexOf('imageStack') === -1) {
embeddedMap.addLayer(imageStack);
window.imageLayer = true;
}
else if (visibleImage === event.data.layername) {
embeddedMap.removeLayer(
embeddedMap.getLayer('imageStack')
);
$(event.target).parent().children().prop('checked', false);
window.imageLayer = false;
}
$('#active-layers').show();
$.each(window.imageData, function () {
$('#image' + this.layername).addClass('hidden');
});
$('#image' + event.data.layername).removeClass('hidden');
$('#image' + event.data.layername).trigger('click');
if (!window.imageLayer && layerStack.visibleLayers &&
layerStack.visibleLayers.length === 1 &&
(layerStack.layerInfos[layerStack.visibleLayers[0]].name ===
'LTER site boundary')) {
$('#active-layers').hide();
}
})
);
imageChecks.append($('<li />').append(checkbox));
});
});
}
else {
$('#image-checks-title').html('<a href="#">Images (0)</a>');
}
});

Outcomes