Hi Rich,It is because the web app is made using MVC.The topic is use in the bootstrapper to publish the event and then you register to the event in the business logic module.Not to familiar with all this, but this is how the contoller look like. Thanks[HTML]require(["dojo/parser", "dijit/layout/BorderContainer", "dijit/layout/ContentPane","dijit/layout/AccordionContainer", "my/map","dojo/aspect","dijit/registry","dojo/_base/connect", "dojo/topic", "dojo/domReady!"], function(parser, borderContainer, contentPane, accordion, map, aspect,registry,connect,topic) { parser.parse(); var _map = addMapModule(); function addMapModule() { var _map = new map('mapDiv'); _map.initialize(); return _map; }; connect.connect(_map.map, 'onZoomEnd', function () { topic.publish('zoom/end'); }); });[/HTML]
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.
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://xyz/xyz/rest/services/VECTOR_BASEMAPS/xyz/MapServer"); var opLayer1 = new esri.layers.ArcGISDynamicMapServiceLayer("http://xyz/xyz/rest/services/VECTOR_BASEMAPS/xyz/MapServer", { opacity: 0.8 }); var opLayer2 = new esri.layers.ArcGISDynamicMapServiceLayer("http://xyz/xyz/rest/services/xyz/xyz/MapServer", { opacity: 0.8 }); var opLayer3 = new esri.layers.ArcGISDynamicMapServiceLayer("http://xyz/xyz/rest/services/xyz/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://xyz/xyz/rest/services/xyz/xyz/MapServer/1",{ mode: esri.layers.FeatureLayer.MODE_ONDEMAND, infoTemplate: infoTemplate1, id: "OBJECTID", outFields: ["*"] }); return featureLayer1; } }); });
Membros conectados podem postar, seguir atualizações e mais. Novo aqui? Registre uma conta gratuita.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.