[OpenLayers-Users] Vector feature projection
Leigh Holcombe
lholcombe at triple-bypass.net
Wed Dec 21 23:30:01 EST 2011
Hello,
I'm trying to add some WGS84 points to a spherical mercator map. After
studying examples and reading some documentation, I've been led to
believe that the following code should work. And yet, it does not.
var wgs84 = new OpenLayers.Projection("EPSG:4326");
var sphermerc = new OpenLayers.Projection("900913");
// vector points overlay
var pointslayer = new OpenLayers.Layer.Vector("Points Layer", {
styleMap: stylepoint,
displayInLayerSwitcher: false
});
// define the points
var start = new OpenLayers.Geometry.Point(-157, 21);
start.transform(wgs84, sphermerc);
var startfeature = new OpenLayers.Feature.Vector(start);
pointslayer.addFeatures([startfeature]);
map.addLayer(pointslayer);
This isn't all of the code, but I'm pretty sure it's the only part that
isn't working. I think the reason I can't figure this out is that I
don't quite understand how transforming "in place" works. Which version
of 'start' is being passed to OpenLayers.Feature.Vector: the original,
or the transformed?
Code ideas and/or explanatory speeches (of any length) would be greatly
appreciated.
Thank you,
Leigh Holcombe
More information about the Users
mailing list