[OpenLayers-Users] Write a KML file in proper projection.

bartvde at osgis.nl bartvde at osgis.nl
Mon Mar 15 07:57:47 EDT 2010


Define internalProjection and externalProjection on your format:

    /**
     * APIProperty: externalProjection
     * {<OpenLayers.Projection>} When passed a externalProjection and
     *     internalProjection, the format will reproject the geometries it
     *     reads or writes. The externalProjection is the projection used by
     *     the content which is passed into read or which comes out of write.
     *     In order to reproject, a projection transformation function for
the
     *     specified projections must be available. This support may be
     *     provided via proj4js or via a custom transformation function. See
     *     {<OpenLayers.Projection.addTransform>} for more information on
     *     custom transformations.
     */
    externalProjection: null,

    /**
     * APIProperty: internalProjection
     * {<OpenLayers.Projection>} When passed a externalProjection and
     *     internalProjection, the format will reproject the geometries it
     *     reads or writes. The internalProjection is the projection used by
     *     the geometries which are returned by read or which are passed into
     *     write.  In order to reproject, a projection transformation
function
     *     for the specified projections must be available. This support
may be
     *     provided via proj4js or via a custom transformation function. See
     *     {<OpenLayers.Projection.addTransform>} for more information on
     *     custom transformations.
     */
    internalProjection: null,

Best regards,
Bart

>
> Hi all.
>
> I have a vectorlayer with a drawFeature control.
> When a user has drawn something onto the layer I use the following code to
> get the KML:
>         var format = new OpenLayers.Format.KML();
>         var markup = format.write(redliningLayer.features);
> Now, this KML is using my baselayers projection (EPSG:25832) which is
> pretty
> useless if I try to render it in eg. Google Earth.
> Is it possible to save KML in another projection than the baselayer?
> --
> View this message in context:
> http://n2.nabble.com/Write-a-KML-file-in-proper-projection-tp4736343p4736343.html
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>





More information about the Users mailing list