I have a query layer that is published onto arcGIS server. I am having difficulty returning the fields in a javascript application. I need to be able to iterate over this array. Code is bellow.. ServiceURL and HEatMapOptions are defined elsewhere before any of this is called. The function returns undefined..

var heatmapOptions = {
    mode: FeatureLayer.MODE_SNAPSHOT,
    outFields: ["*"]
}; //end of options
var heatmapFeatureLayer = new FeatureLayer(serviceURL, heatmapOptions);
    var heatmapRenderer = new HeatmapRenderer();
    heatmapRenderer.blurRadius = 6;

function getFields(h) {
    var lyr = h;
    var f = lyr.fields;


on(heatmapFeatureLayer, "load", getFields(heatmapFeatureLayer));

This is because getFields is being called immediately. To avoid this, wrap it in a function.

on(heatmapFeatureLayer, "load", function(){
  • Bingo! Callbacks throw me off every time. – LCaraway Nov 8 '16 at 15:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.