OpenLayers – Can’t Display Overlay in OpenLayers 2

openlayers-2overlay

I am trying to add a WMS radar overlay to my map but it won't seem to gather it.

  noaaRdr = new OpenLayers.Layer.WMS("Latest Radar", "http://nowcoast.noaa.gov/wms/com.esri.wms.Esrimap/obs?", {
    layers: 'RAS_RIDGE_NEXRAD',
    transparent: true,
    format: 'image/png'
  }, {
    visibility: true, isBaseLayer: false, singleTile: true,
    ratio: 1,opacity: 0.7
  });


  radarArray = [noaaRdr];     //adding more layers later..
  map.addLayers(radarArray);

I have seen this URL used elsewhere but i can't figure out whats wrong. The layer shows up in the layer switcher but the image never shows on the map and the file "obs" never gets requested from the NOAA server ??

Can anyone help me with this.

Best Answer

Here is working code:

options = {
    div: "map",
    zoom: 5,
    center: [-10796366.372312, 4426748.6429884],
    layers: [
        new OpenLayers.Layer.OSM()
    ],
    projection: "EPSG:3857"
};
map = new OpenLayers.Map(options);

var noaaRdr = new OpenLayers.Layer.WMS(
    "Latest Radar",
    "http://nowcoast.noaa.gov/wms/com.esri.wms.Esrimap/obs?",
    {
        layers: 'RAS_RIDGE_NEXRAD',
        transparent: true
    },
    {
        isBaseLayer: false,
        singleTile: true,
        opacity: 0.7
    }
);

map.addControl(new OpenLayers.Control.LayerSwitcher());
map.addLayer(noaaRdr);

Live example HERE.

Related Question