[OpenLayers-Users] Question on using multiple layers in different projections

Vito Tafuni vito at vitotafuni.com
Thu Jul 1 03:25:19 EDT 2010


IMHP
reprojecting the map is better than reprojecting each feature every time you
switch beetween layers.
so in my project i set map options to
       projection: new OpenLayers.Projection("EPSG:900913"),
       displayProjection: new OpenLayers.Projection("EPSG:4326"),
       maxResolution: "auto",
       maxExtent: new
OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),

and then add
         gmap = new OpenLayers.Layer.Google("Google Terrain",{ type:
G_PHYSICAL_MAP, sphericalMercator:true});
         bing = new OpenLayers.Layer.VirtualEarth("Aerial", { type:
VEMapStyle.Aerial, sphericalMercator:true});
         vector = new OpenLayers.Layer.Vector("vectors");

more info on reprojecting and spherical marcator at
http://docs.openlayers.org/library/spherical_mercator.html

but i'm using ol since a month so may be i'm wrong!!


-Vito-



--
-----------
Tafuni Vito
vito at vitotafuni.com
---------------------------------------------
"Verba volant, scripta manent... data corrupted"


2010/7/1 <christopher.schmidt at nokia.com>

>
> 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
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20100701/4a12a660/attachment.html


More information about the Users mailing list