[OpenLayers-Users] setCenter for polylines and polygons

Gery . gamejihou at hotmail.com
Tue Feb 19 10:19:45 PST 2013


great trick, thanks a lot Arnd.


__________________________________________________________________________________________
Piensa en el medio ambiente - mantenlo en la pantalla. NO lo imprimas si NO es necesario.
Think green - keep it on the screen. Do NOT print if it is NOT necessary.
Denken Sie an die Umwelt - bewahren Sie es auf dem Bildschirm. Drucken Sie es NICHT, wenn es NICHT notwendig ist.


From: arnd.wippermann at web.de
To: gamejihou at hotmail.com
CC: openlayers-users at lists.osgeo.org
Subject: AW: [OpenLayers-Users] setCenter for polylines and polygons
Date: Tue, 19 Feb 2013 19:12:41 +0100








Hi,
 
this should work for all 
geometries:
 
var ft = 
vectorLayer.features[0];
var bounds = 
ft.geometry.bounds;
if(zoom)
    
map.zoomToExtent(bounds);
else
    
map.setCenter(bounds.getCenterLonLat());

Regards,
Arnd
 




Von: openlayers-users-bounces at lists.osgeo.org 
[mailto:openlayers-users-bounces at lists.osgeo.org] Im Auftrag von Gery 
.
Gesendet: Dienstag, 19. Februar 2013 18:00
An: 
openlayers-users at lists.osgeo.org
Betreff: [OpenLayers-Users] setCenter 
for polylines and polygons



Hello folks,

I'm using 
this line to center my points in 
the map screen:

var centerPoint = new 
OpenLayers.LonLat(feature.geometry.x, feature.geometry.y);
map.setCenter(centerPoint);

what should I use to center 
polylines and polygons?

thanks in 
advance,

Regards,

Gery



__________________________________________________________________________________________
Piensa 
en el medio ambiente - mantenlo en la pantalla. NO lo imprimas 
si NO es necesario.
Think green - keep it on the screen. Do NOT print if it is NOT 
necessary.
Denken Sie an die 
Umwelt - bewahren Sie es auf dem Bildschirm. Drucken Sie es 
NICHT, wenn es NICHT notwendig 
ist.
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20130219/f9a0fb71/attachment-0001.html>


More information about the Users mailing list