AnsweredAssumed Answered

Combining Scripts

Question asked by jbcbirder on May 15, 2014
Latest reply on May 15, 2014 by kenbuja
Hi,

     I'm just getting started with using the ArcGIS API for Javascript. I have been trying samples using the sandbox site. I've had some general trouble trying to combine the functionality of one sample with another. So what I'm looking for is some guidance in how to effectively combine these scripts.

For example, I brought up the measurement sample and I wanted to add a home button. So I added references to "esri/dijit/HomeButton" to the list in the "Require" function and added "HomeButton" to the function defined as the second argument in "Require" and then added code

var home = new HomeButton({
  map: map
}, "HomeButton");
home.startup();


at the end (before the final "});" near the end of the </script> tag.

It seems to make everything stop working if everything isn't in the right order and even putting it at the end means that it works up until that code snippet that I included runs (I can check by adding an "alert" popup and I see that it stops working).

Questions:
1. Should this work (if so, what am I doing wrong)?
2. Am I correct in assuming that listing these items (objects ?) in the wrong order will upset the script or should I be able to put that "HomeButton" anywhere in that list of arguments?

function(dom, Color, keys, parser, esriConfig, has, Map, SnappingManager, Measurement, FeatureLayer, SimpleRenderer, GeometryService, SimpleLineSymbol, SimpleFillSymbol, HomeButton){<lots of code>}

Outcomes