[OpenLayers-Users] Change from OpenLayers.Layer.Google to OpenLayers.Layer.OSM
Phil Scadden
p.scadden at gns.cri.nz
Tue May 28 14:41:57 PDT 2013
>
> My project has geoserver serving layers in EPSG:4326 projection.
Geoserver might store the layers in 4326, but it will serve them up in
whatever the projection of your current baselayer is. This is very
important to understand. Change the baselayer to one with a different
projection and the projection of the map will change. As a result, it
will fire off requests to geoserver asking for data in that baselayer
projection.
>
> When I create a google layer:
>
> var gmap = new OpenLayers.Layer.Google("Google Streets",
> {numZoomLevels: 20});
>
> EPSG is 4326,
> and units are in degrees.
Actually, if you use this, then your baselayer is 900913 and so your
map will be 900913. Using 4326 as the actual "projection" doesnt make a
lot of sense. 4326 is good to set as the maps displayProjection for
mouse pointer but as a "projection" it has no features that a
cartographer could love. 900913 isnt wonderful either but its far better
than 4326. If you are going to google OR OSM, then your map will be
actually be in 900913. They are stored as image tiles and there is no
easy way to reproject these on the fly to something else. In contrast,
geoserver renders your data on the fly, into the requested image
projection. That's easy for vector data. It can reproject raster on the
fly now to but you might not like the look of it.
>
> var osm = new OpenLayers.Layer.OSM("osm", {projection: new
> OpenLayers.Projection('EPSG:4326')});
When you create a layer, the projection parameter is effectively a
hint, telling openlayers what the NATIVE projection of the layer is. The
map baselayer is what will determine the projection that is actually
requested is. For OSM, this has no effect - you can only get 900913(3587)
> - Why is OSM layer projection EPSG:900913?
Because its a tile layer and cant be reprojected on the fly. (same as
google).
> - Can I have a OSM baseLayer in a different projection?
> The {projection: new OpenLayers.Projection('EPSG:4326')} argument
> seemed to have no effect on the layer.
No.
If you really want a prerendered tile layer as base in something other
than 900913, then you are probably better to create and store it
yourself. That probably means hacking something like Tilemill or
maptiler. However, I am pretty sure that you really dont want 4326 as a
projection. My bible is Snyder's "Map Projections - A working manual".
Notice: This email and any attachments are confidential.
If received in error please destroy and immediately notify us.
Do not copy or disclose the contents.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20130529/9015ceb5/attachment.html>
More information about the Users
mailing list