<div dir="ltr">Hi, i have this problem, i want to show a popup with feature info, but in method getfeatureinfo, the attribute event.features is empty.<div style>in the code below</div><div>with info variable the popup works</div>
<div>with info2 variable the popup is empty<br><div style>I use geoext2, ext 4.1, OL 2.12</div><div style><br></div><div style><div>Ext.define("MP.view.MapPanel", {</div><div> extend: "GeoExt.panel.Map",</div>
<div><br></div></div><div style><div> initComponent: function() {</div><div> this.map = new OpenLayers.Map('map',</div><div> {</div><div> projection: 'EPSG:3857', </div>
<div> numZoomLevels: 20,</div><div> allOverlays: true,</div><div> controls: [</div><div> new OpenLayers.Control.Navigation({</div><div> dragPanOptions: {</div>
<div> enableKinetic: true</div><div> }</div><div> }),</div><div> new OpenLayers.Control.Attribution(),</div><div> new OpenLayers.Control.Zoom()</div><div> ]</div><div> });</div>
<div><br></div><div> var wms_layer = new OpenLayers.Layer.WMS("Global Imagery",</div><div> "<a href="http://172.16.102.42:8080/geoserver/sf/wms">http://172.16.102.42:8080/geoserver/sf/wms</a>",</div>
<div> {</div><div> layers : "sf:Cuencas superficiales"</div><div> },</div><div> { </div><div> isBaseLayer:true </div>
<div> }, {</div><div> buffer: 0,</div><div> visibility: true</div><div> }</div><div> );</div><div> </div><div> this.map.addLayer(wms_layer); </div><div><br>
</div><div> </div><div>var info = new OpenLayers.Control.WMSGetFeatureInfo({ </div><div> title: 'Identify features by clicking',</div><div> //maxFeatures: 10,</div><div> infoFormat: "text/html",</div>
<div> layers: [wms_layer],</div><div> queryVisible: true,</div><div> eventListeners: {</div><div> getfeatureinfo: function(event) {</div><div> this.map.addPopup(new OpenLayers.Popup.FramedCloud(</div>
<div> "chicken", </div><div> this.map.getLonLatFromPixel(event.xy),</div><div> null,</div><div> event.text,</div><div> null,</div>
<div> true</div><div> ));</div><div> }</div><div> }</div><div> });</div><div><br></div><div>var info2 = new OpenLayers.Control.WMSGetFeatureInfo({ </div>
<div> autoActivate: true,</div><div> infoFormat: "application/vnd.ogc.gml", </div><div> layers: [wms_layer], </div><div> eventListeners: { </div><div> getfeatureinfo: function(event) { </div>
<div> var items = [];</div><div> Ext.each(event.features, function(feature) {</div><div> items.push({</div><div> xtype: "propertygrid",</div><div> title: feature.fid,</div>
<div> source: feature.attributes</div><div> });</div><div> });</div><div> </div><div> Ext.create("GeoExt.window.Popup",{</div><div> title: "Feature Info",</div>
<div> width: 200,</div><div> height: 200,</div><div> layout: "accordion",</div><div> map: this.map,</div><div> location: event.xy,</div>
<div> items: items</div><div> }).show();</div><div> }</div><div> }</div><div>});</div><div><div> //this.map.addControl(info);</div><div> //info.activate();</div></div><div><br></div><div>
this.map.addControl(info2);</div><div> info2.activate(); </div><div> this.callParent();</div><div> }</div><div>}</div><div><br></div><div style>thanks!</div></div></div></div>