[OpenLayers-Users] Plotting a KML layer in a map that uses a different projection

Richard Marsden richard at winwaed.com
Mon Jul 13 20:14:49 EDT 2009


Hello,

I am developing a map that uses a non-cylindrical projection (Mollweide 
in this case but I'll probably use other pseudo-cylindrical projections 
later). I have OpenLayers displaying this properly with tiles delivered 
by WMS (from MapServer).

I would now like to add extra layers from KML,  and possibly GeoRSS.
Of course when I add a KML layer then the KML coordinates (geographic 
WGS84 as per the spec) are plotted as if they are metric cartesian 
coordinates in Mollweide space.

For individual coordinates, I know I can transform them one at a time 
using the OpenLayers.Projection.transform( ) method (this may prove 
useful later - eg. if I implement my own simple graticule).

However, I would like to transform the entire KML layer. How can I do this?
I've tried cribbing from the example at:

http://openlayers.org/dev/examples/sundials-spherical-mercator.html

and this doesn't make any difference.
(yes Proj4JS is loaded and I have the Mollweide EPSG code defined - the 
base WMS layer is plotting fine!)

I really do not want to go through the KML file and parse it element by 
element. Although my current test data is pushpin/marker based, I would 
like a reasonably general case that also works with polylines, polygons, 
etc.
Transforming into a "Mollweide KML" format isn't an option either  - 
this should be a general case with a user-supplied KML file.

Who do other people do in this situation?  Or is the above example broken?


Richard (M)




More information about the Users mailing list