[OpenLayers-Users] getFeatureCount function?

bartvde at osgis.nl bartvde at osgis.nl
Tue Mar 23 09:56:02 EDT 2010


Hi,

you need to listen to the loadend event of the layer, and then check the
number of features.

layer.events.register("loadend", layer, function() {
alert(this.features.length); });

Best regards,
Bart

> mmm... yes, I tried with layer.features.length but always returns 0.
> I explain you: based on the example of SOSClient
> (http://openlayers.org/dev/examples/sos.html), I want to count how many
> features obtained in the resulting layer of the GetCapabilities request:
>
>
> parseSOSCaps: function(response) {
>                 // cache capabilities for future use
>                 this.SOSCapabilities =
> this.capsformat.read(response.responseXML || response.responseText);
>
>                 this.layer = new OpenLayers.Layer.Vector(\"Stations\", {
>                     strategies: [new OpenLayers.Strategy.Fixed()],
>                     protocol: new OpenLayers.Protocol.SOS({
>                         formatOptions: {internalProjection:
> map.getProjectionObject()},
>                         url: this.url,
>                         fois: this.getFois()
>                     })
>                 });
>                 alert('Number of FOI's: '
> +this.layer.features.length);   //--->always returns 0, but on the map
> appear 7 features.
>
>
>
> bartvde at osgis.nl escribió:
>> What type of layer? Layer.Vector?
>>
>> Try layer.features.length.
>>
>> Best regards,
>> Bart
>>
>>
>>> Hi all,
>>> exists any function to obtain the number of features of a Layer?
>>> F.ex:  map.layers[i].getFeatureCount
>>>
>>>
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> Users mailing list
>>> Users at openlayers.org
>>> http://openlayers.org/mailman/listinfo/users
>>>
>>>
>>
>>
>>
>
>





More information about the Users mailing list