[OpenLayers-Users] wms layer over openstreet base map

jdmorgan jdmorgan at unca.edu
Thu May 24 10:37:52 PDT 2012


Hello,
I am trying to get a wms states layer to overlay on a base openstreet 
map.  The openstreet map shows up fine but the wms layer never does.  I 
am guessing this is a projection issue but can't figure out how to 
resolve it. Any tips would be greatly appreciated.  Here is my code:

<!DOCTYPE HTML>
<html>
<head>
<title>OpenLayers Demo</title>
<style type="text/css">
       html, body, #basicMap {
           width: 100%;
           height: 100%;
           margin: 0;
       }
</style>
<script src="http://www.openlayers.org/api/OpenLayers.js"></script>
<script>
       function init() {

         map = new OpenLayers.Map("basicMap", {projection: "EPSG:900913"});
         var mapnik         = new OpenLayers.Layer.OSM();
         var fromProjection = new OpenLayers.Projection("EPSG:4326");   
// Transform from WGS 1984
         var toProjection   = new OpenLayers.Projection("EPSG:900913"); 
// to Spherical Mercator Projection
         var position       = new OpenLayers.LonLat(-98.0859375, 
39.095962936305476).transform(fromProjection, toProjection);
         var zoom           = 5;

         var stateMap = new OpenLayers.Layer.WMS(
             'States',
             'http://pathToWMSlayer/vlayers',
             {layers: 'states', transparent: true}
             {
                 isBaseLayer: false,
             }
         );

         map.addLayers([mapnik, stateMap]);
         map.setCenter(position, zoom);
       }
</script>
</head>
<body onload="init();">
<div id="basicMap"></div>
</body>
</html>


Thanks ahead of time,
Derek


More information about the Users mailing list