[OpenLayers-Users] Question on using multiple layers in different
projections
Stephen Woodbridge
woodbri at swoodbridge.com
Wed Jun 30 19:02:32 EDT 2010
Hi all,
I have an OL app setup the is using epsg4326 and everything it fine.
It has a mapserver base layer and a vector overlay with markers and
another with lines.
I have been asked to add Google as an additional base layer.
So my understanding is that the map object will take on the projection
of the base layer when you switch between them.
I have few questions:
1. I assume that the vector features are not transformed when the base
layer is switched? Is this true? Which probably means I need to cycle
through the features and transform them to the base layers projection
something like:
map.events.register('changebaselayer', map, function(evt, element) {
var fromProj = map.getUnit()=='m'?epsg4326:epsg900913;
for (var i=0, var len=layer.features.length; i<len; i++)
layer.features[i].geometry.transform(fromProj,
map.getProjectionObject());
layer.redraw();
});
2. I have a WKT parser object. It need to reproject the features based
on the current base layer. Can I change the internalProjection on base
layer change like:
parser.internalProjection = map.getProjectionObject();
Or do I need to destroy and recreate the parser on each change?
I just trying to thing this all through. I can probably try it, but
getting some conformation or corrections will great reduce the spinning
wheels effect :).
Thanks,
-Steve
More information about the Users
mailing list