[OpenLayers-Users] KML reprojection?

Eric Lemoine eric.lemoine at camptocamp.com
Tue Aug 18 01:59:18 EDT 2009


On Tuesday, August 18, 2009, Jeremy Husmann
<Jeremy.Husmann at critchlow.co.nz> wrote:
>
>
>
>
>
>
>
>
>
>
>
>
>
> Hello everyone,


Hi


>
>
>
> 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.

What if you remove the TMS layer and have the vector layer as the only
layer in the map?


>
>
>
>         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());
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

-- 
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 96
Mail : eric.lemoine at camptocamp.com
http://www.camptocamp.com


More information about the Users mailing list