[OpenLayers-Users] Re: Image Layer unable to span across map extents [SOVLED]

teknocreator teknocreator at gmail.com
Tue Mar 27 21:39:13 EDT 2012


[SOLVED] Note that this is just one possible solution when using the
OpenLayers.Layer.Image.  We might be able to solve this better by using
MapServer and tiling the image instead.  However, here's what appears to
work at the moment:

Found the problem is that for the normal spherical mercator backgrounds that
if the map center is negative (west longitude) or positive (east longitude),
OpenLayers attempts to render the image with bounds relative to the center. 
Therefore, if the image is georeferenced such that its bounds are in west
longitudes, it disappears if the map center is west of 180.  The solution
then is to find appropriate bounds for both cases.  Via GDAL for image
transformation and information retrieval about the image extents, I then
used the spherical mercator map extents to determine the two possible
extents for the image (in spherical mercator map units of meters):

    wbounds = new OpenLayers.Bounds(-23344864.188, 4932580.448,
-10424521.962, 13100281.98);
    ebounds = new OpenLayers.Bounds(16719151.812, 4932580.448, 29650494.038,
13100281.98);

As you can see, the lower left lon extent for wbounds goes beyond the map
extent of -20037508 and the upper right lon extent of ebound goes beyond the
map extent of 20037508.  Next register a map 'moveend' event that will swap
these extents into the layer extent should the map center change from east
longitudes to west or vice versa.  Layer is redrawn in either of these
cases.  Need to include wrapDateLine: true in the layer creation in order
for the image to be displayed in either of those extents.  Seems to work
fairly well for the limited testing I've done so far.  But as I indicated
above, we will also look into working with our MapServer to see if it will
correctly tile the image no matter which side of 180 the image is on.

Dave M

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/Image-Layer-unable-to-span-across-map-extents-tp4657181p4662800.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.


More information about the Users mailing list