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

teknocreator teknocreator at gmail.com
Mon Mar 26 10:57:45 EDT 2012


Good day!

We're creating PNG image overlays (OpenLayers.Layer.Image) of various data
fields (e.g. temperature) over the lower 48 United States and displaying
them on Spherical Mercator background maps such as Google Maps and Open
Street Map.  We'd like to do the same with Alaska.  However, even with the
wrapDateLine set to true, one can only view the image overlay if the map is
panned such that most of the image is in the eastern portion of the map. 
Pan too far east and the image disappears.  Pan back and it reappears.  I've
searched the list here and didn't really find an answer for this particular
layer type.   I did have a thought to split the image so there are two parts
ending at the different map extents.  Then it would be a matter of ensuring
that the second part is displayed when the first one is.  But, I was
wondering if there was a better way, something that I missed in
documentation, or anything undocumented that I might be able to use for
this.  

A bit of code to show how I'm setting this up in our test page:
....
    map = new OpenLayers.Map("map", {

        projection: new OpenLayers.Projection("EPSG:3857"),
        units: "m",
        maxResolution: 156543.0339,
        maxExtent: new OpenLayers.Bounds(-20037508, -20037508, 20037508,
20037508.34),

        displayProjection: new OpenLayers.Projection("EPSG:4326"),
        controls: [
            new OpenLayers.Control.Navigation(),
            new OpenLayers.Control.KeyboardDefaults(),
            new OpenLayers.Control.PanZoomBar(),
            new OpenLayers.Control.Scale(),
            new OpenLayers.Control.Attribution()
        ]

    });

// create spherical mercator background layers
    var googleLayer = new OpenLayers.Layer.Google("Google Physical", {type:
google.maps.MapTypeId.TERRAIN, visibility: true});
    var gstr = new OpenLayers.Layer.Google("Google Streets", {type:
google.maps.MapTypeId.ROAD, visibility: true});
    var osmLayer = new OpenLayers.Layer.OSM("OpenStreetMap");

    overlay= new OpenLayers.Layer.Image("wxelement","img/tmp/tmpimg3.png",
         new OpenLayers.Bounds(16719151.812, 4932580.448, -10424521.962,
13100281.98),     //ALASKA
         new OpenLayers.Size(632, 399),
         {isBaseLayer: false, opacity: 0.5, wrapDateLine: true, 
          projection: new OpenLayers.Projection("EPSG:3857")});

//add layers to map
    map.addLayers([osmLayer, googleLayer, gstr, overlay]);
....

So I welcome suggestions.  Thanks!

Dave M

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


More information about the Users mailing list