Search code examples
openlayersbounds

Is it possible to add bounds for the OpenLayers.Layer.WMS


I have created a OpenLayers.Layer.WMS and i can able to view the picture which i expected to be on overlay. But its spreads allover the map. Please check my code below and let me know where i did the mistake.

var dm_wms = new OpenLayers.Layer.WMS( "DM Solutions Demo",
    "http://4.bp.blogspot.com/_lxtIPm_77I0/TJgxuFj5VqI/AAAAAAAAAW0/5QgltGCSviU/s1600/yellowrose.jpg",
    {
        layers: "basic",
        transparent: "true", 
        format: "image/png" 
    }, {
        opacity: 0.3,
        singleTile: true,
        maxExtent: new OpenLayers.Bounds(-74.047185, 40.679648, -50.907005, 30.882078)
    }
);

Solution

  • If you want to use an image as a layer - use the Layer.Image object instead. The WMS layer is for using a dynamic map service, not a static image.