[OpenLayers-Users] wms layer over openstreet base map

Gery . gamejihou at hotmail.com
Thu May 24 10:46:45 PDT 2012



Hello,

I think you're right, projection has something to do there, this link may help you: http://blog.sonxurxo.com/2011/04/28/tutorial-de-openlayers-ii-capas-de-google/

There is a lot of stuff about google maps and openlayers and projection, just google them.

Hope this helps,



> Date: Thu, 24 May 2012 13:37:52 -0400
> From: jdmorgan at unca.edu
> To: openlayers-users at lists.osgeo.org
> Subject: [OpenLayers-Users] wms layer over openstreet base map
> 
> 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
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20120524/23e7f238/attachment-0001.html


More information about the Users mailing list