rikke

Layer objects cannot be accessed

Discussion created by rikke on Mar 10, 2011
Latest reply on Mar 22, 2011 by rikke
Hello,

I am having trouble accessing the objects of a dynamiclayer using JSAPI v2.1. Its strange, because Im almost certain that I have done it before..

I have the following lines executing:
console.log("---- OBJECT DEBUG STARTS HERE ----");
console.log(layer);
console.log(layer.version);
console.log(layer.layerInfos);
console.log("---- OBJECT DEBUG END HERE ----");


Chrome console shows the following:
---- OBJECT DEBUG STARTS HERE ----
basemapviewer.html:118
a
_defaultVisibleLayers: Array[29]
_div: HTMLDivElement
_divAlphaImageFunc: function (){return _bb.apply(_ba,arguments||[]);}
_errorHandler: function (){return _bb.apply(_ba,arguments||[]);}
_exportMapImageHandler: function (){return _bb.apply(_ba,arguments||[]);}
_img: HTMLImageElement
_imgSrcFunc: function (){return _bb.apply(_ba,arguments||[]);}
_img_dragOrigin: Object
_img_loading: HTMLImageElement
_inherited: Object
_initLayer: function (){return _bb.apply(_ba,arguments||[]);}
_layerIndex: 2
_load: function (){return _bb.apply(_ba,arguments||[]);}
_loadCallback: undefined
_map: a
_onExtentChangeHandler_connect: Array[4]
_onPanHandler_connect: Array[4]
_onResizeHandler_connect: Array[4]
_onZoomHandler_connect: Array[4]
_opacityChangeHandler_connect: Array[4]
_params: Object
_setIsPNG32: function (){return _bb.apply(_ba,arguments||[]);}
_startRect: Object
_tileErrorHandler: a
_tileLoadHandler: a
_titleForLegend: "INFORMATION"
_unsetMap_connect: Array[4]
_updateStarted: true
_url: Object
_visibilityChangeHandler_connect: Array[4]
capabilities: "Map,Query,Data"
copyright: ""
description: ""
dpi: 96
fullExtent: a
getImageUrl: function (){return _bb.apply(_ba,arguments||[]);}
id: "layer2"
imageFormat: "png8"
imageTransparency: true
initialExtent: a
isPNG32: undefined
layerInfos: Array[29]
legendResponse: Object
loaded: true
onLoad: function (){var ap=Array.prototype,c=arguments.callee,ls=c._listeners,t=c.target;var r=t&&t.apply(this,arguments);var i,lls;lls=[].concat(ls);for(i in lls){if(!(i in ap)){lls[i].apply(this,arguments);}}return r;}
onOpacityChange: function (){var ap=Array.prototype,c=arguments.callee,ls=c._listeners,t=c.target;var r=t&&t.apply(this,arguments);var i,lls;lls=[].concat(ls);for(i in lls){if(!(i in ap)){lls[i].apply(this,arguments);}}return r;}
onUpdateEnd: function (){var ap=Array.prototype,c=arguments.callee,ls=c._listeners,t=c.target;var r=t&&t.apply(this,arguments);var i,lls;lls=[].concat(ls);for(i in lls){if(!(i in ap)){lls[i].apply(this,arguments);}}return r;}
onVisibilityChange: function (){var ap=Array.prototype,c=arguments.callee,ls=c._listeners,t=c.target;var r=t&&t.apply(this,arguments);var i,lls;lls=[].concat(ls);for(i in lls){if(!(i in ap)){lls[i].apply(this,arguments);}}return r;}
opacity: 0.75
ovcConnect: Array[4]
spatialReference: a
units: "esriDecimalDegrees"
url: "--removed--"
useMapImage: false
version: 10.01
visibleLayers: Array[29]
__proto__: anonymous
basemapviewer.html:119undefined
basemapviewer.html:120[]
basemapviewer.html:122---- OBJECT DEBUG END HERE ----


What you can see here is that the first console line prints the layer object ("a") - have expanded it to show all the objects stored within it (including "version" and "layerInfos"). However, when it is required to write one of these objects, it shows "undefined" and an empty array.

I have tried accessing by looping through the object as well, with the same results. I have tried calling the object using different JS notation, without success. I have also (out of desperation) re-published and restarted the service and tried on a different service all with the same results.

What is (clearly) incongruous here is that the full object can be read fine, but the embedded objects cannot. Presumably I am missing something OBVIOUS, but Ive tried re-writing a million times without success.

Please help!

Regards,
Richard.

Outcomes