[OpenLayers-Users] Re: google and map with projection 4352

teknocreator teknocreator at gmail.com
Tue Mar 27 09:42:28 EDT 2012


VM,

It looks like you're mixing projections and units for those.  Projection
4326 is in degrees whereas Google Maps is in meters.  What I've had to do is
set the map extents to those used in Google for EPSG 900913 (it's really
3857 now) and then adjust other layers to that:

map = new OpenLayers.Map("map_canvas", {

        projection: new OpenLayers.Projection("EPSG:900913"),
        units: "m",
        maxResolution: 156543.0339,
        maxExtent: new OpenLayers.Bounds(
            -20037508, -20037508, 20037508, 20037508.34),
        restrictedExtent: new OpenLayers.Bounds(
            -17557692.747438, -116865.2041299,
-3860177.281188,9275716.8298701),
        displayProjection: new OpenLayers.Projection("EPSG:4326"),
        controls: [
            new OpenLayers.Control.Navigation(),
            new OpenLayers.Control.KeyboardDefaults(),
            new OpenLayers.Control.PanZoom(),
            new OpenLayers.Control.ZoomBox(),
            new OpenLayers.Control.Scale(),
            new OpenLayers.Control.Attribution()
        ]

    });

Otherwise, the Google base maps won't display properly.  If you setup your
mapfile correctly for MapServer, it has the ability to reproject from 4326
to 3857 (900913).  You also have to set up that layer in OL properly too:

wmsmap = new OpenLayers.Layer.MapServer( "Layer", "/cgi-bin/mapserv", 
                {dataarray:"array[1]", mode: "map", map: mapfile, layers:
"layer",
                 format:'image/png',
           	 transparent:true, reaspect: "true"},
                {singleTile: true, ratio: 1, isBaseLayer: false, opacity:
0.8, visibility: true,
                 *projection: new OpenLayers.Projection("EPSG:3857")*});

There are some examples on the OpenLayers home page that might help.

Dave M


--
View this message in context: http://osgeo-org.1560.n6.nabble.com/google-and-map-with-projection-4352-tp4657348p4660896.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.


More information about the Users mailing list