Hi,

register "featureadded" for the layer and create a zoom function

function zoomToLeftHalf(evt)
{
    var arrB = evt.feature.geometry.getBounds().toArray();
    var dx = arrB[2]-arrB[0];
    var bounds = new OpenLayers.Bounds(arrB[0], arrB[1], arrB[2]+dx,
arrB[3]);
    map.zoomToExtent(bounds);
}
map.layers[2].events.register("featureadded", map.layers[2],
zoomToLeftHalf);


Regards,
Arnd 

-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Puneet
Kishor
Gesendet: Freitag, 13. Januar 2012 21:03
An: [email protected]
Betreff: [OpenLayers-Users] steps to zoom and center on the selected polygon

I am trying to accomplish the following, and would appreciate advice on how
to go about doing it --

1. the user click,click,click... double-clicks to create a polygon;

2. the map zooms to the polygon so that the polygon occupies the left half
of the browser window.

Here is my attempt to draw the interface --


+----------------------------------+
|                 .                |
|                 .                |
|                 .                |
|                 .                |
|                 .                |
|     A           .        B       |
|                 .                |
|                 .                |
|                 .                |
|                 .                |
+----------------------------------+

so, once a polygon is drawn, the map zooms so the drawn polygon is centered
to its full extent within A above.

Suggestions welcome. Many thanks,

--
Puneet Kishor_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users

_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users

Reply via email to