1

I am trying to convert the Toggle Identify example to AMD style. However, I am stuck with an empty map. Debugging in Firebug doesn't help too much. Could anyone help me to find where I am wrong? The code is in here:

http://jsfiddle.net/neWnE/

I am trying to modify Blord Castillo's code from this thread:

Identify with Layer Toggling

Any support appreciated!!!

1

Your code is breaking in the initIdentify function.

Since you're listening to the map's load event with on, your callback (initIdentify) receives an event object as an argument. The map is a property of this object. Here's an updated version of that function:

function initIdentify(e) {
    //create identify tasks and setup parameters
    identifyTask = new esri.tasks.IdentifyTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Louisville/LOJIC_PublicSafety_Louisville/MapServer");

    identifyParams = new IdentifyParameters();
    identifyParams.tolerance = 12;
    identifyParams.returnGeometry = true;
    identifyParams.layerIds = dynlayer.visibleLayers;
    identifyParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_VISIBLE;
    identifyParams.width = e.map.width;
    identifyParams.height = e.map.height;
    console.log('set up ID', e.map);

    on(e.map, "click", executeIdentifyTask);
}

Also note that you have some references to things from the global esri namespace which you should update so that you're 100% AMD.

I also did a little other cleanup with the map and basemap and put it all here: http://jsfiddle.net/neWnE/1/

  • Perfect- Thanks Derek! I am still learning with this migration. If your team can put together a AMD migration documentation, that'll be really helpful. Since most of the sample codes are still non-AMD, I find it little hard (being a beginner). Thanks again for your support! – Ann Dec 10 '13 at 15:10
  • @Ann glad to help, all samples linked from the sidebar here developers.arcgis.com/en/javascript/jssamples should be AMD. We also did a blog post on migrating to AMD which you should read: blogs.esri.com/esri/arcgis/2013/10/14/the-abcs-of-amd – Derek Swingley Dec 10 '13 at 16:40
  • Thanks Derek. In the above example- is there a way I can grey out the check box based on layer visibility? – Ann Dec 10 '13 at 19:19

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.