I have some features I've created via some Kml data.
Now, to display these features on a Google Map, I need to project them from 'EPSG:4326' to 'EPSG:3857'. This works great.
Now, i need to convert this to WKT 4326. When I do that, i re-transform the features but the google map doesn't display them any more because the features are in the wrong projection.
Can anyone suggest a way to clean up my code so I can keep the features in 4326 format, but when I need to display these features on my Layer, it's smart enough to transform it into 3857.
Here's my full javascript code ... but here's the important bits in there...
// Converts some Kml string data into an array of Features.
function convertKmlToFeatures(kml) {
var kmlFormat = new OpenLayers.Format.KML();
var features = kmlFormat.read(kml);
for (var i = 0, l = features.length; i < l; i++) {
features[i].geometry.transform('EPSG:4326', 'EPSG:3857');
}
return features;
}
.....
// Display features.
// NOTE: (This will be as 3857 .. but i wish i can leave this as 4326 and
// just transform on the fly, here).
map.layers[1].addFeatures(features);
.....
// Finally Output the features as WKT. This needs to be as 4326.
// Right now, it's still as 3857.
var wktFormat = new OpenLayers.Format.WKT();
return wktFormat.write(features);