[OpenLayers-Users] KML reprojection?

Jeremy Husmann Jeremy.Husmann at critchlow.co.nz
Mon Aug 17 20:18:23 EDT 2009


Hello everyone,

 

I am in the process of adding a KML as a baselayer (I was quickly helped
by Eric and Christopher by finding the constructor attribute need for
this.).

 

Now I seem to have stuck another in relation to projections.  

 

I have noticed that if I add the KML as the only base layer it comes out
a bit squashed, when if I don't change any projection settings and just
add a WMS layer as another base layer it seems to correct the KML. -
Unsure if anything is going on behind the scenes (with my KML being
reprojected?) or if im just missing something extremely obvious. - Any
help would be appreciated.

 

        function mapInit() 

            {

                        var nzBounds = new OpenLayers.Bounds(165, -47,
180, -34.5).transform((new OpenLayers.Projection("EPSG:4326")), (new
OpenLayers.Projection("EPSG:900913")));

                 

                        var options = 

                        {

                                    projection: new
OpenLayers.Projection("EPSG:900913"),

                                    displayProjection: new
OpenLayers.Projection("EPSG:4326"),

                                    units: "m",

                                    maxResolution: 16543.0339,

                        

                                    maxExtent: nzBounds,

                                    numZoomLevels: 24, 

                                    minZoomLevel: 6, 

                                    maxZoomLevel:18,

                                    controls: [

                        new OpenLayers.Control.Navigation(),

                        new
OpenLayers.Control.LayerSwitcher({'ascending':false}),

                                    new
OpenLayers.Control.PanZoomBar({zoomWorldIcon:true})

                                    ]

                        };

            

                map = new OpenLayers.Map('map', options);

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

                                                    

                         

 

                        

                                    var mapnik = new
OpenLayers.Layer.TMS(

                "OpenStreetMap (Mapnik)",

                "http://tile.openstreetmap.org/",

                {

                    type: 'png', 

                    displayOutsideMaxExtent: true,

                    attribution: '<a
href="http://www.openstreetmap.org/">OpenStreetMap</a>'

                }

            );

                

                mapnik.setVisibility(false);

                

                        var time = new Date();

                        var secs = time.getSeconds();

                        postCodeKml = new
OpenLayers.Layer.GML("CoverageTEST", "kml/coverage_1.kml?" + secs, 

                        {

                    format: OpenLayers.Format.KML, 

projection:map.displayProjection,

 

                        

 

                            isBaseLayer:true,

                            formatOptions: {

                        extractStyles: true, 

                        extractAttributes: true

                    }

                }

            );

                

               map.addLayers([mapnik]);

            

                        postCodeKml.setVisibility(true);

                        map.addLayer(postCodeKml);

                        postCodeKml.setOpacity(0.25);

                              

                        map.zoomToExtent(nzBounds);  

                map.addControl(new OpenLayers.Control.MousePosition());

            

 

            

            

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20090818/053dba70/attachment.html


More information about the Users mailing list