[OpenLayers-Users] beginner Q - misaligned layers, must be a projection?

deduikertjes DeDuikertjes at xs4all.nl
Wed Oct 21 07:49:44 EDT 2009


Chris,

You'll have to reproject the kml layer to the Bing layer.

Start reading here:
http://docs.openlayers.org/library/spherical_mercator.html
(and don't forget to search the archives).

By the way: don't forget to include the proj4 library which seems to be the
most commonly made mistake when doing projection stuff.

Marco






chrisjongkind wrote:
> 
>  http://n2.nabble.com/file/n3864257/walesprojection.jpg 
> 
> hi guys,
> 
> first, please feel free to point me to a more beginner forum if need be;
> OL is totally new to me and I am only a WFS/WMS newbie anyway in general,
> so I don't mind being told to post elsewhere or whatever...
> 
> right now, simple stuff, just trying to overlay a kml I made from a
> shapefile, onto the bing aerial layer.  I had no trouble overlaying the
> same kml onto the OL WMS (I think it was "OpenLayers WMS",
> "http://labs.metacarta.com/wms/vmap0" in my page), but their projection
> matched, now you can see in the attached image that my wales.kml and bing
> aerial do not match, but what shall I do?
> 
> here is my code (largely from tutorials, just tailored for my work):
> 
> <html xmlns="http://www.w3.org/1999/xhtml">
>   <head>
>     <title>chris tutorialsContd3</title>
>     <link rel="stylesheet" href="../theme/default/style.css"
> type="text/css" />
>     <link rel="stylesheet" href="style.css" type="text/css" />
>     <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
>     <script
> src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2&mkt=en-us"></script>
> 
>     <script src="OpenLayers.js"></script>
> 
>     <script>
> 
>         var map;
> 
>         function init(){
>             map = new OpenLayers.Map("map");
>             map.addControl(new OpenLayers.Control.LayerSwitcher());
> 
>             var aerial = new OpenLayers.Layer.VirtualEarth("Aerial", {
>                 type: VEMapStyle.Aerial
>             });
> 
>                         var layerWales = new OpenLayers.Layer.GML("Wales
> polygon", "chris/waleskml.kml", {format: OpenLayers.Format.KML})
> 
>             map.addLayers([aerial,layerWales]);
> 
>             map.setCenter(new OpenLayers.LonLat(-5, 51), 7);
>         }
> 
>     </script>
>   </head>
>   <body onload="init()">
>     <h1 id="title">Bing Example</h1>
> 
>     <div id="tags"></div>
> 
>     <p id="shortdesc">
>         Demonstrates the use of Bing layers.
>     </p>
> 
>     <div id="map" class="smallmap"></div>
>     <div id="docs">This example demonstrates the ability to create layers
> using tiles from Bing maps.</div>
>   </body>
> </html>
> 
> thanks a lot to anyone who can help,
> 
> chris j 
> 

-- 
View this message in context: http://n2.nabble.com/beginner-Q-misaligned-layers-must-be-a-projection-tp3864257p3864753.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.



More information about the Users mailing list