chagan02

Adding Layers on top of AGOL WebMap

Discussion created by chagan02 on May 13, 2014
Latest reply on May 16, 2014 by chagan02
All,

I'm working on an application where I need to turn layers on/off.  I thought it best to build a basemap on AGOL, pull that in using the webmap ID method, then add layers on top of that.  However, whenever I try adding a new layer using the CSVLayer module, my basemap will not load.  Can someone help me out?

Thanks!

<script src="http://js.arcgis.com/3.9/"></script>
<script>
  require([
 "dojo/parser",
 "dojo/ready",
 "dijit/layout/BorderContainer",
 "dijit/layout/ContentPane",
 "dojo/dom",
 "esri/map", 
 "esri/urlUtils",
 "esri/arcgis/utils",
 "esri/dijit/Legend",
 "esri/dijit/Scalebar",
 "dojo/domReady!"
  ], function(
 parser,
 ready,
 BorderContainer,
 ContentPane,
 dom,
 Map,
 urlUtils,
 arcgisUtils,
 Legend,
 Scalebar
  ) {
 ready(function(){

 parser.parse();


 arcgisUtils.createMap("Some IDNUM","map").then(function(response){
   //update the app 
   dom.byId("title").innerHTML = response.itemInfo.item.title;
   dom.byId("subtitle").innerHTML = response.itemInfo.item.snippet;

   var map = response.map;



   //add the scalebar 
   var scalebar = new Scalebar({
  map: map,
  scalebarUnit: "english"
   });

   //add the legend. Note that we use the utility method getLegendLayers to get 
   //the layers to display in the legend from the createMap response.
   var legendLayers = arcgisUtils.getLegendLayers(response); 
   var legendDijit = new Legend({
  map: map,
  layerInfos: legendLayers
   },"legend");
   legendDijit.startup();


 });


 });

  });
</script>

Outcomes