Solved! Go to Solution.
define(["dojo/_base/declare", "esri/map", "esri/layers/FeatureLayer", "dojo/_base/connect","dojo/topic", "dojo/_base/lang"], function (declare, esriLib, featureLib,connect,topic,lang) { return declare (null, { mapDivName : null, constructor: function (mapDiv,args) { topic.subscribe('dimension/changed', lang.hitch(this, this.resizeMap)); topic.subscribe('zoom/end', lang.hitch(this, this.zoomEnd)); this.mapDivName = mapDiv; }, initialize: function() { //var initialExtent = new esri.geometry.Extent({"xmin":-13050590.679808607,"ymin":3848824.1306140213,"xmax":-13033430.566958608,"ymax":3863366.2752452563,"spatialReference":{"wkid":102100}}); this.map = new esri.Map(this.mapDivName); var baseLayer = new esri.layers.ArcGISTiledMapServiceLayer("http://xxx/xxx/rest/services/VECTOR_BASEMAPS/xxx/MapServer"); var opLayer1 = new esri.layers.ArcGISDynamicMapServiceLayer("http://xxx/xxx/rest/services/VECTOR_BASEMAPS/xxx/MapServer", { opacity: 0.8 }); var opLayer2 = new esri.layers.ArcGISDynamicMapServiceLayer("http://xxx/xxx/rest/services/xxx/xxx/MapServer", { opacity: 0.8 }); var opLayer3 = new esri.layers.ArcGISDynamicMapServiceLayer("http://xxx/xxx/rest/services/xxx/MapServer", { opacity: 0.8 }); this.map.addLayers([baseLayer,opLayer1,opLayer2,opLayer3]); this.featureLayer = this.addFeatureLayer(); this.map.resize(); this.map.addLayer(this.featureLayer); }, resizeMap: function() { this.map.resize(); this.map.reposition(); }, zoomEnd: function() { var s = dojo.byId("rightDiv"); s.innerHTML = this.map.getScale(); }, addFeatureLayer: function() { var info_content = "<table><tr><td><b>Band Number:</b></td><td style='text-align:right'>${BAND_NUMBER}</td></tr>" + "<tr><td><b>Service Center:</b></td><td style='text-align:right'>${SERVICE_CENTER}</td></tr>" + "<tr><td><b>Registered Population:</b></td><td style='text-align:right'>${REGISTERED_POPULATION}</td></tr></table>"; var infoTemplate1 = new esri.InfoTemplate("${BAND_NAME}", info_content); var featureLayer1 = new esri.layers.FeatureLayer("http://xxx/xxx/rest/services/xxx/xxx/MapServer/1",{ mode: esri.layers.FeatureLayer.MODE_ONDEMAND, infoTemplate: infoTemplate1, id: "OBJECTID", outFields: ["*"] }); return featureLayer1; } }); });
Hi Rich,
Thanks for you help and the code sample.
Using the code, I able to add all the feature layers I want.
topic.subscribe('zoom/end', lang.hitch(this, this.zoomEnd)); //Does esri.Map publish this?
Yes, zoomEnd exist as a map event.
Eric.