[OpenLayers-Users] Question on using multiple layers in
different projections
christopher.schmidt at nokia.com
christopher.schmidt at nokia.com
Wed Jun 30 19:13:46 EDT 2010
On Jun 30, 2010, at 7:02 PM, ext Stephen Woodbridge wrote:
> 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();
> });
Yes.
>
> 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();
That should work.
-- Chris
More information about the Users
mailing list