[OpenLayers-Users] Aligning mapserver wms layer with google maps again

Christopher Schmidt crschmidt at metacarta.com
Wed Oct 1 03:00:25 EDT 2008


On Tue, Sep 30, 2008 at 10:59:30PM -0700, bmrg wrote:
> 
> I am not sure if this is an issue with projections or what, but I am having a
> peculiar problem trying to align my mapserver wms layer with a google layer.
> I have tried playing around with projections ect. to try and remedy this but
> to no avail. 

You need to be using sphericalMercator. (Your server will need to
support EPSG:900913.) Set the sphericalMercator option on your Google
Map.

Start with that, and then comment on how you're having problems getting
that working.

-- Chris

> The misalignment seems to depend on the latitude of the feature. Features
> drawn at the central latitude of the map align very well and the
> misalignment increases the further north or south of the map centre. This is
> even the case when I reposition the map. The wms layers are compresses in
> the north-south dimension. 
> 
> Is it obvious to anyone what I may be doing wrong? I have attahced part of
> the openlayers script below for reference. 
> 
> 
> 
>              map = new OpenLayers.Map( 'map', {
> 
>                         numZoomLevels: 20, maxZoomLevel: 20 });
>               
> 
>                
>              var gsat = new OpenLayers.Layer.Google(
>                 "Google Satellite",
>                 {type: G_SATELLITE_MAP}
>             );
>                //map.addLayer(gsat);
> 			   
> 			var gphy = new OpenLayers.Layer.Google(
>                 "Google Physical",
>                 {type: G_PHYSICAL_MAP}
>             );
> 			   //map.addLayer(gphy);
>              var gmap = new OpenLayers.Layer.Google(
>                 "Google Streets" // the default
>             );
> 			   //map.addLayer(gmap);
>             var ghyb = new OpenLayers.Layer.Google(
>                 "Google Hybrid",
>                 {type: G_HYBRID_MAP}
>             );
> 			   //map.addLayer(ghyb);
>   
>                map.addLayers([gsat, gphy, gmap, ghyb]);
> 
>                 
>                  wms = new OpenLayers.Layer.MapServer( "Regional
> Ecosystems",
>                          "http://localhost/cgi-bin/mapserv.exe", {map:
> 'C:/ms4w/Apache/htdocs/re.map', transparent: 'true', format: 'png'},
>                         {'isBaseLayer': false, 'opacity': 0.5, 'reproject':
> true, 'gutter': 15, 'singleTile': true} );
>                  map.addLayer(wms);
>                 
>                 cadastre = new OpenLayers.Layer.MapServer( "Cadastre",
>                         "http://localhost/cgi-bin/mapserv.exe", {map:
> 'C:/ms4w/Apache/htdocs/cadastre.map', transparent: 'true', format: 'png'},
>                         {'isBaseLayer': false, 'opacity': 0.5, 'reproject':
> true, 'gutter': 15, 'singleTile': true} );
>                  map.addLayer(cadastre);
> 				 
> 				cad_label = new OpenLayers.Layer.MapServer( "Cadastre Labels",
>                         "http://localhost/cgi-bin/mapserv.exe", {map:
> 'C:/ms4w/Apache/htdocs/cad_label.map', transparent: 'true', format: 'png'},
>                         {'isBaseLayer': false, 'opacity': 0.5, 'reproject':
> true, 'gutter': 15, 'singleTile': true} );
>                  map.addLayer(cad_label);
> 
> 				 
>             wms.setVisibility(false);
>             cadastre.setVisibility(false);
> 			cad_label.setVisibility(false);
> 
> -- 
> View this message in context: http://www.nabble.com/Aligning-mapserver-wms-layer-with-google-maps-again-tp19754401p19754401.html
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
> 
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users

-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list