[OpenLayers-Users] How to overwrite OpenLayers.Format.KML

Christopher Schmidt crschmidt at metacarta.com
Thu Oct 4 11:36:01 EDT 2007


On Thu, Oct 04, 2007 at 03:15:31PM +0200, Arnd Wippermann wrote:
> 
> I want to display kml-files in SphericalMercator on google maps. kml-files
> works with lon-lat-values, so I have to reproject the data. With the
> functionality of OpenLayers it's no problem.
> 
> Problem is:
> 
> I don't know how to overwrite the OpenLayers.Format.KML-class before
> creating the layer. I want to change the functions 
> 
> point: function(node) {...
> linestring: function(node, ring) {...

> OpenLayers.Format.KML.prototype.point = function(){... didn't work, neither
> set a new property with OpenLayers.Format.KML.fromEPSG.

OpenLayers.Format.KML.prototype.parseGeometry.point = function(node) { }

The geometry parsing functions are inside of the parseGeometry object.

OpenLayers.Format.KML.prototype.fromEPSG = function() {} should work,
too.

> So I have copied the whole class, changed the name of the class, entered my
> stuff. To choose between klmns 2.0 and 2.1 I have a second copy with only
> change for the klmns.

This is no longer neccesary as of trunk/RC4 yesterday: The kmlns for the
Placemarks is determined automatically.

> The loading of KML-files in EPSG:4326 and reprojecting them to EPSG:900913
> works great! 

For the record, in 2.6, we should have reprojection support built into
OpenLayers, using proj4js to do the reprojection. I've tested this with
KML files, and it works. It won't be going into trunk for a little bit
yet, but you should keep an eye out. 

> Question : Is there a better way to establish this behaviour without copy
> the class two times.

Yep -- use trunk :)

Regards,
-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list