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

Nicholas Efremov-Kendall n.e.kendall at gmail.com
Thu Jun 23 13:25:18 EDT 2011


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/d09e909e/attachment.html


More information about the Users mailing list