[OpenLayers-Users] Layer.GML.features.length

Pierre GIRAUD bluecarto at gmail.com
Thu Jun 7 13:40:54 EDT 2007


I would suggest you to use the extend() method that comes with the
Bounds class. It is exactly made for those type of needs.
Something like this :


var bounds = new OpenLayers.Bounds();
for (var i = 0; i < gmlLayer.features.length; i++)
       {
               bounds.extend(gmlLayer.features[i].bounds);
       }

Regards

Pierre

On 6/7/07, Tim Schaub <noreply at geocartic.com> wrote:
> Jeff Dege wrote:
> > I'm creating a GML layer from a GML file.
> >
> > I want the map to zoom to the smallest box bounding all the features in
> > the GML file.
> >
> > What I've tried is:
> >
>
> ...
>
> >
> >       var minx = 999999;
> >       var miny = 999999;
> >       var maxx = -999999;
> >       var maxy = -999999;
> >
>
> As an aside, 999999 may look like a big number, but it isn't always.
> Better to use Number.POSITIVE_INFINITY and Number.NEGATIVE_INFINITY here.
>
> ...
>
> >
> > Seems to me the best hook, for dealing with these sorts of issues, might
> > be a doneInsertingFeatures() callback.  Added after the end of the loop
> > in Layer\Vector.js.
> >
>
> I agree, I think layers that load data asynchronously should call a
> doneLoading callback that you can define in the layer options.
>
> I'd suggest making a ticket if nobody else has a better workaround.
>
> Tim
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>



More information about the Users mailing list