[OpenLayers-Dev] work out lons and lats for map corners?

Tim Schaub tschaub at opengeo.org
Mon Jul 7 18:42:43 EDT 2008


Hey-

Zac Barton wrote:
> Hey Darko
> 
> You can use your_map_object.getExtent() to get what you're after.
> 
> Regards
> 
> Zac
> 
> 2008/7/4 Darko Radiceski <radiceski at gmail.com <mailto:radiceski at gmail.com>>:
> 
>     Dear all,
>      
>     Is it possible to work out the lons and lats of all 4 corners of a
>     map at a particular zoom level?
>      

Also, if you want to know the extent for a zoom level different than the 
current zoom level, resolution is your friend.

Resolution is the number of map units per pixel.  So, first find the 
resolution given the zoom.

var res = map.getResolutionForZoom(zoom);
var upperLeft = new OpenLayers.LonLat(
     map.center.lon + (res * map.size.w / 2),
     map.center.lat + (res * map.size.h / 2)
);

Other corners are up to you.

Tim

>     Cheers
>     Dan
> 
>     -- 
>     Radiceski Dan
>     University of Wollongong
>     Australia
>     SIFE - UOW Chapter - Alumni
>     CASUAL ACADEMIC STAFF TEACHING - UOW SITACS
>     (School of Information Technology and Computer Science,University of
>     Wollongong)
>     Univeristy of Wollongong - Alumni
> 
>     _______________________________________________
>     Dev mailing list
>     Dev at openlayers.org <mailto:Dev at openlayers.org>
>     http://openlayers.org/mailman/listinfo/dev
> 
> 
> !DSPAM:4033,486dcdfc276108992556831!
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Dev mailing list
> Dev at openlayers.org
> http://openlayers.org/mailman/listinfo/dev
> 
> 
> !DSPAM:4033,486dcdfc276108992556831!




More information about the Dev mailing list