Solved! Go to Solution.
dojo.require('esri.layers.FeatureLayer'); var baseURL; var map; function init() { var initExtent = new esri.geometry.Extent({"xmin":-8590965.388453046,"ymin":4695877.530747742,"xmax":-8553434.807565076,"ymax":4711164.936404756,"spatialReference":{"wkid":102100}}); map = new esri.Map("map",{extent:initExtent}); var basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"); map.addLayer(basemap); baseURL = "http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/HomelandSecurity/operations/MapServer"; esri.request({ url:baseURL, content:{f:"json"}, callbackParamName:"callback", load:addLayers, error:esriConfig.defaults.io.errorHandler }); } function addLayers(response,args){ dojo.forEach(response.layers,function(layer){ var featureLayer = new esri.layers.FeatureLayer(baseURL + "/" + layer.id,{ mode: esri.layers.FeatureLayer.MODE_ONDEMAND, outFields: ["*"] }); map.addLayer(featureLayer); }); } dojo.addOnLoad(init);
dojo.require('esri.layers.FeatureLayer'); var baseURL; var map; function init() { var initExtent = new esri.geometry.Extent({"xmin":-8590965.388453046,"ymin":4695877.530747742,"xmax":-8553434.807565076,"ymax":4711164.936404756,"spatialReference":{"wkid":102100}}); map = new esri.Map("map",{extent:initExtent}); var basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"); map.addLayer(basemap); baseURL = "http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/HomelandSecurity/operations/MapServer"; esri.request({ url:baseURL, content:{f:"json"}, callbackParamName:"callback", load:addLayers, error:esriConfig.defaults.io.errorHandler }); } function addLayers(response,args){ dojo.forEach(response.layers,function(layer){ var featureLayer = new esri.layers.FeatureLayer(baseURL + "/" + layer.id,{ mode: esri.layers.FeatureLayer.MODE_ONDEMAND, outFields: ["*"] }); map.addLayer(featureLayer); }); } dojo.addOnLoad(init);