var template = new esri.InfoTemplate(); var featureLayer = new esri.layers.FeatureLayer("http://servicesbeta.esri.com/ArcGIS/rest/services/SanFrancisco/SFStreetTreesRendered/MapServer/0",{ id: "My Feature Layer Name", mode: esri.layers.FeatureLayer.MODE_SELECTION, outFields: ["*"], infoTemplate:template }); //first pass infoTemplate, then instantiate feature layer, then set title using id template.setTitle(featureLayer.id);
connect.connect(map, "onClick", executeIdentifyTask); identifyTask = new esri.tasks.IdentifyTask(parameters.url); identifyParams = new esri.tasks.IdentifyParameters(); identifyParams.tolerance = 3; identifyParams.returnGeometry = true; //identifyParams.layerIds = [0, 117]; identifyParams.layerIds = myLayer.visibleLayers; identifyParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_ALL; identifyParams.width = map.width; identifyParams.height = map.height; map.infoWindow.resize(415, 200); map.infoWindow.setTitle("Results"); function executeIdentifyTask(evt) { identifyParams.geometry = evt.mapPoint; identifyParams.mapExtent = map.extent; identifyParams.layerIds = myLayer.visibleLayers; //in case the visible layers have changed for the layer var deferred = identifyTask.execute(identifyParams); deferred.addCallback(function (response) { return dojo.map(response, function (result) { var feature = result.feature; var infoTemplate = new esri.InfoTemplate("test", "${*}"); var contentString = ""; var sp = new Array(); var sp = feature.attributes; contentString += "<b>" + result.layerName + "</b><hr width = '90%'>"; for (x in sp) { contentString += x + ": " + feature.attributes + "<br/>"; } var infoTemplate = new esri.InfoTemplate(); var titleText = "<div>" + "Title" + "</div>" infoTemplate.setTitle(titleText); infoTemplate.setContent(contentString); feature.setInfoTemplate(infoTemplate); return feature; }); }); map.infoWindow.setFeatures([deferred]); map.infoWindow.show(evt.mapPoint); }
One option is to define a function that will generate your popup content using setContent. Then you can use the graphic.getLayer method to retrieve the graphics layer name. Here's an example that shows how this works: http://jsfiddle.net/AddHT/
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.