map.on('layer-add-result', function (layer, error) { if (layer.layer.id == LAYERS_SERVER[0].name) map.setExtent(new esri.geometry.Extent(layer.layer.fullExtent.xmin, layer.layer.fullExtent.ymin, layer.layer.fullExtent.xmax, layer.layer.fullExtent.ymax, new esri.SpatialReference({ wkid: map.extent.spatialReference.wkid }))); });
addLayers(map, LAYERS_SERVER); };
var addLayers = function(map, layers) { var template = new esri.InfoTemplate(); template.setTitle("Info"); // If a feature layer is setup in system but not in Webmap, add them to the map $.each(layers, function (i, val) { var gisServerLayer = new esri.layers.FeatureLayer(val.url, { mode: esri.layers.FeatureLayer.MODE_ONDEMAND, outFields: ["*"], id: val.name, displayOnPan: true, visible: true, infoTemplate: template }); map.addLayer(gisServerLayer); }); };
Any help in resolving this would be greatly appreciated. Or if you can point me in the right direction.