var map = new esri.Map("map", { extent: esri.geometry.geographicToWebMercator(initialExtent), slider: true, nav: false }); dojo.connect(map, "onLoad", initSelectToolbar); var baseMapLayer = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"); map.addLayer(baseMapLayer); //Add regional summation data var content = "<b>Region</b>: ${Region_1}" + "<br><b>Value USD(Millions)</b>: ${SUM_MAX_TotalAmt}" + "<br><b>Number of Projects</b>: ${SUM_COUNT_ProjectID}"; var infoTemplate = new esri.InfoTemplate("${FIELD_NAME}", content); featureLayer = new esri.layers.FeatureLayer("http://maps4.arcgisonline.com/ArcGIS/rest/services/World_Bank/WB_World_Bank_Projects/MapServer/1",{ mode: esri.layers.FeatureLayer.MODE_ONDEMAND, infoTemplate: infoTemplate, outFields: ["*"] }); map.addLayer(featureLayer);
Solved! Go to Solution.
Use a dynamic map service layer. You can control individual layer visibility with setVisibileLayers.
function init() { //use the info window instead of the popup var infoWindow = new esri.dijit.InfoWindow(null, dojo.create("div")); infoWindow.startup(); //var bbox = new Extent({"xmin":-7600182.13249805,"ymin":-446969.667305208,"xmax":2866021.96822699,"ymax":5458542.14371841,"spatialReference":{"wkid":102039}}); map = new esri.Map("map", { //extent: bbox, basemap: "streets", center: [-96, 37], infoWindow: infoWindow, zoom: 4 }); var template = new esri.InfoTemplate(); //flag icons are from http://twitter.com/thefella, released under creative commons template.setTitle("Store <b>${StoreNum}</b>"); template.setContent(getWindowContent); //create a renderer for the stores layer to override default symbology var storeSymbol = new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_CIRCLE,9,new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID,new dojo.Color([0,0,0]), .5),new dojo.Color([0,92,230])); var storeRenderer = new SimpleRenderer(storeSymbol); //create a feature layer to show store points //var storesLayer = new esri.layers.FeatureLayer("http://gis-server.greatriv.com/ArcGIS/rest/services/ShamrockMktg/StoreLocations/MapServer/0", { var storesURL = "http://gis-server.greatriv.com/ArcGIS/rest/services/ShamrockMktg/StoreLocations/MapServer/0"; var stores = new FeatureLayer(storesURL, { mode: esri.layers.FeatureLayer.MODE_ONDEMAND, outFields: ["*"], id: "stores", infoTemplate: template, }); var labelField = "StoreNum"; stores.setRenderer(storeRenderer); map.addLayer(stores); map.infoWindow.resize(675, 475); //create a text symbol to define the style of labels var storesColor = new Color("#666"); var storesLabel = new TextSymbol().setColor(storesColor); storesLabel.font.setSize("8pt"); storesLabel.font.setFamily("arial"); storesLabelRenderer = new SimpleRenderer(storesLabel); var labels = new LabelLayer({id: "labels" }); //tell the label layer to label the stores feature layer //using the field named "StoreNum" labels.addFeatureLayer(stores, storesLabelRenderer, "${" + labelField + "}"); //add the label layer to the map map.addLayer(labels); }
add option
showLabels: true
for map constructor
same as
map = new Map("map", { extent: bbox, showLabels : true //very important that this must be set to true! });