[OpenLayers-Users] Layer.GML.features.length
Roger Kunkel
rakunkel at ucdavis.edu
Thu Jun 7 13:57:13 EDT 2007
Hi Jeff,
In my app I zoom to the largest feature successfully. I sub-classed
Layer.GML and overrode the
requestSuccess function:
/**
* Overrides the ajax return process to immediately zoom to the
fetched feature.
*/
requestSuccess:function(request) {
var doc = request.responseXML;
if (!doc || request.fileType!="XML") {
doc = request.responseText;
}
map.GML = doc;
var gml = this.format ? new this.format() : new
OpenLayers.Format.GML();
this.addFeatures(gml.read(doc));
// zoom to the extent of the largest geom
this.maxIndex = 0;
var i;
for (i=0;i<=this.features.length - 1;i++) {
if (parseFloat(this.features[i].geometry.getArea()) >
parseFloat(this.features[this.maxIndex].geometry.get\
Area())) {
this.maxIndex = i
}
}
map.zoomToExtent(this.features
[this.maxIndex].geometry.getBounds());
},
Hope this helps.
Roger Kunkel
CERES Program
Dept. of Land Air & Water Resources
UC Davis
rakunkel at ucdavis.edu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20070607/7b8e5374/attachment.html
More information about the Users
mailing list