Hi, I produce the layer as
var mybounds = new OpenLayers.Bounds(-1693861.59,6469059.01,-107949.94,7643808.37); var oMapOptions = null; //-----Define Map options ------------ oMapOptions = { controls:[ new OpenLayers.Control.Attribution() , new OpenLayers.Control.PanZoomBar() , new OpenLayers.Control.Scale() ] , maxResolution: 'auto' , units: 'm' , maxExtent: mybounds , projection: new OpenLayers.Projection("EPSG:900913") , displayProjection: new OpenLayers.Projection("EPSG:900913") ,eventListeners: { "zoomend": mapEvent, "movestart": mapEvent, "moveend": mapEvent } }; //-----Create Map Control Object ------------ oMapControl = new OpenLayers.Map ('MapPanel',oMapOptions); if (oMapControl == null) { return ; } . . . . //----------Vector---------- var myscales = [13867008,6933504,3466752,1733376,866688,433344,216672,108336,54168,27084,13542,6771,3385,1692,846.375];var oD738e521bc9024f578ad922a7c62b25e0 = new OpenLayers.Style({pointRadius: 16, fillColor: '#ffcc66', fillOpacity: 0, strokeColor: '#cc6633', strokeWidth: 2, strokeOpacity: 0.1}); var oH738e521bc9024f578ad922a7c62b25e0 = new OpenLayers.Style({pointRadius: 16, fillColor: '#FF0000', fillOpacity: 0.2, strokeColor: '#cc6633', strokeWidth: 2, strokeOpacity: 0.1}); var oStyleMap738e521bc9024f578ad922a7c62b25e0 = new OpenLayers.StyleMap({'default': oD738e521bc9024f578ad922a7c62b25e0,'select': oD738e521bc9024f578ad922a7c62b25e0, 'delete': oD738e521bc9024f578ad922a7c62b25e0,'temporary': oH738e521bc9024f578ad922a7c62b25e0}); var oLayerScales=[55168.002,27084.001,13542.0005,6771.0003,3385.5001,1692.7501,846.375]; var oToolTipPreviewLayer = new OpenLayers.Layer.Vector('Incidents 2008',{ styleMap: oStyleMap738e521bc9024f578ad922a7c62b25e0, scales: oLayerScales, eventListeners: {"featuresadded": featuresadded,"beforefeaturesadded": beforefeaturesadded}, strategies: [new OpenLayers.Strategy.BBOX({ ratio: 1 }), new OpenLayers.Strategy.Cluster({ distance: 20 })], protocol: new OpenLayers.Protocol.HTTP({ url: 'http://193.120.94.23/LPA40DCC/Layers/VectorLayer.aspx?LayerID=LP4_91', format: new OpenLayers.Format.GeoJSON()}), projection: new OpenLayers.Projection("EPSG:3857")}); if (oToolTipPreviewLayer != null){ oMapControl.addLayer(oToolTipPreviewLayer); } var oLayerScales=[55168.002,28084.001,14542.0005,7771.0003,4385.5001,2692.7501,846.375]; var oPreviewLayer = new OpenLayers.Layer.WMS('Incidents 2008', 'http://193.120.94.23:8080//cgi-bin/mapserv.exe?map=C:/MS4W/apps/CacheMapConfig/LP4_91WMS.map', { scales: oLayerScales, layers: ['INCIDENTS'], format: 'image/png', VERSION: "1.1.1", transparent: true , projection: new OpenLayers.Projection("EPSG:3857") },{ isBaseLayer: false , attribution: " \"http://www.IMGS.ie/\" © IMGS 2010 " , singleTile: true}); if (oPreviewLayer != null){ oMapControl.addLayer(oPreviewLayer); } //here I want to set the legend function setlegend(slayername) { oLayers = oMapControl.getLayersByName(slayername); for (cnt = 0; cnt < oLayers.length; cnt++) { if (oLayers[cnt].CLASS_NAME != "OpenLayers.Layer.WMS") { alert(oLayers[cnt].features.length); //always coming as zero //do other stuff here. } } } -- View this message in context: http://osgeo-org.1803224.n2.nabble.com/Openlayers-Check-the-map-content-and-tell-if-the-feature-exists-in-the-map-bound-tp6776147p6786648.html Sent from the OpenLayers Dev mailing list archive at Nabble.com. _______________________________________________ Dev mailing list d...@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/openlayers-dev