[OpenLayers-Users] Zoom on GML extent

christophe triquet nethou at aliceadsl.fr
Mon Jan 18 07:32:24 EST 2010


Hi,

I'm adding a GML file in my map with the object OpenLayers.Layer.GML. I'm
trying to zoom to this layer extent at map's loading. I can do this if I
know de bounding box coordinates with a postgis query.

My PHP code :

        var bounds = new OpenLayers.Bounds();
        bounds.extend((new
OpenLayers.LonLat(<?=$xmin?>,<?=$ymin?>)).transform(wgs84,
map.getProjectionObject()));
        bounds.extend((new
OpenLayers.LonLat(<?=$xmax?>,<?=$ymax?>)).transform(wgs84,
map.getProjectionObject()));
        bounds.toBBOX();
        map.zoomToExtent(bounds);

But this requires a server call and I want my map to use only datas in the
GML file and not to have to connect to a database.

I have seen that GML files includes bounded box informations like :

  <gml:boundedBy>
    <gml:Box>

<gml:coord><gml:X>1.473839004763629</gml:X><gml:Y>43.43941299999661</gml:Y></gml:coord>

<gml:coord><gml:X>1.647671004707115</gml:X><gml:Y>43.58098800002078</gml:Y></gml:coord>
    </gml:Box>
  </gml:boundedBy>

Is it possible the get the gml extent to be able to automaticaly zoom on it
at loading ?

Thanks,
Christophe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20100118/ad806670/attachment.html


More information about the Users mailing list