AW: [OpenLayers-Users] re set map center, or specify zoom level with mapzoomtoextent

Arnd Wippermann arnd.wippermann at web.de
Thu Jun 23 14:45:51 EDT 2011


try this:

var new_cent = map.zoomToExtent(bounds.getCenterLonLat());

Arnd
 
  _____  

Von: openlayers-users-bounces at lists.osgeo.org
[mailto:openlayers-users-bounces at lists.osgeo.org] Im Auftrag von Nicholas
Efremov-Kendall
Gesendet: Donnerstag, 23. Juni 2011 19:25
An: users at openlayers.org
Betreff: [OpenLayers-Users] re set map center,or specify zoom level with
mapzoomtoextent


Hi all, 

wanted to solicit some advice from the community. I'm working on a simple
dynamic app I wanted to ask about the best method to approach this.

the app sets an arbitrary point, which I suppose could simply be changed to
zoomtomaxextent, but re-centers the map once the user has agreed to opt-in
to being geolocated. The issue is that the bounds of the single marker are
much smaller than the 50km search radius of the script

var bounds = marker.getDataExtent();
map.zoomToExtent(bounds);

I don't want the map to recenter the bounds with every additionally added
point (nearby tweets), which I feel contributes to a poor UI. How could I
get the centerlonlat of the marker layer? I'm trying this method and it
isn't working

var bounds = marker.getDataExtent();
var new_cent = map.zoomToExtent(bounds).getCenterLonLat();
map.setCenter(new OpenLayers.LonLat(new_cent).transform(new
OpenLayers.Projection("EPSG:4326"),map.getProjectionObject()),2);


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20110623/d8e0e549/attachment-0001.html


More information about the Users mailing list