[OpenLayers-Users] zoom to feature(s) extent

Phil Scadden p.scadden at gns.cri.nz
Sun Dec 18 19:44:51 EST 2011


When I query a get results back as GML. In the my processor for the 
returned GML, I put:
     if (request.data && request.data.bbox) {
           var b = request.data.bbox;
           sExt = new OpenLayers.Bounds(b[0],b[1],b[2],b[3]);
     }else {
           var fts = request.features;
           if (fts.length>0) {
               sExt = fts[0].geometry.getBounds().clone();
               for(var i=1;i<fts.length;i++) {
                  sExt.extend(fts[i].geometry.getBounds());
               }
           }
     };

At an appropriate place, I do zoomToExtent(sExt);

Notice: This email and any attachments are confidential. If received in error please destroy and immediately notify us. Do not copy or disclose the contents.



More information about the Users mailing list