[OpenLayers-Users] Re: re set map center,
or specify zoom level with mapzoomtoextent
Nick Kendall
n.e.kendall at gmail.com
Thu Jun 23 14:37:14 EDT 2011
Solved it
Sent from my mobile device
On Jun 23, 2011, at 1:25 PM, Nicholas Efremov-Kendall <n.e.kendall at gmail.com> wrote:
> 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);
>
>
More information about the Users
mailing list