You can't change the projection of the Google layer - it comes in one projection, spherical mercator. If you want to overlay your data on the Google base data, you have to serve it up in a spherical mercator projection. There is an ad-hoc EPSG code for this, EPSG:900913 and you can find the actual projection parameters at:
http://spatialreference.org/ref/user/google-mapsmicrosoft-live/ I believe that there is now a real EPSG code for this projection in the latest EPSG release but I am not sure how widely supported it is yet. I would suggest starting with the spherical mercator examples. Cheers Paul On 27-Jun-08, at 1:16 AM, Matthew Pettis wrote: > Hi List, > > I'm trying to put 2 baselayers in my OpenLayers web object. One > layer is my political map of Minnesota, which has data in epsg: > 26915. The other object I want to use is a Google Maps street view > layer. What I am having trouble doing is making them agree on the > projection and having Google Maps use that projection to render it's > layer. I thought the code below (at end of email) should work, but > I am obviously missing something. > > If I use the ol_ms layer with the map object without the gmap layer, > it renders fine. If I use the gmap layer by itself, and define map > like: > > map = new OpenLayers.Map('map'); > > that is, same as the first one but with no configuration > information, that too works fine. > > However, putting them as base layers on the same map as laid out > below doesn't work. When I switch to the google map, I get some > gray rectangle and the standard google branding stuff at the bottom, > but no real map. I would like it so the same bounds that were being > used for the mapserver map were used. > > I suspect it is a projection thing that I am not understanding that > is in the way. I note that the Bounds object I use for the > mapserver map has bounds like: > > new OpenLayers.Bounds(184056.505,4809728.25,767381.245,5478975.75) > > which is obviously in meters. But when I dump out the bounds for > the working google map by itself, the 4 numbers are in latlon > (-180,-90,180,90). I suspect it is trying to read the epsg:26915 > bounds, which are in meters, as latlon bounds, and making the > display with the map as some orders of magnitude large scale map > that has the entire world mapped to a pixel on my screen. > > Question: how do I make Google realize that the map is in epsg:26915 > and give me its map in commensurate units? I thought that by > defining the projection of the map with epsg:26915, that when I > added the google layer to the map that it would know to project > itself correctly. Do I have to somehow manually coerce these > things, and if so, how? > > Thanks for your time and help, > Matt > > > = > = > ====================================================================== > <html xmlns="http://www.w3.org/1999/xhtml"> > <head> > <title>OpenLayers Example</title> > <!-- <script src="http://www.openlayers.org/api/OpenLayers.js"></ > script> --> > <script src="http://localhost/_common//OpenLayers-2.6/OpenLayers.js > "></script> > <script > src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAytPEybOjkPfSINF9aqMnSRRV_Z48x51l4m6KiJWs2Yue7BruuxS9q420SXqAbRhYk8GzmgwCugf2Fw > > " > type="text/javascript"></script> > <script type="text/javascript"> > var map = null; > function init(){ > > map = new OpenLayers.Map( > 'map', > { > maxResolution: 'auto' > , maxExtent: new > OpenLayers.Bounds(184056.505,4809728.25,767381.245,5478975.75) > , units: 'm' > , projection: "EPSG:26915" > } > ); > > var ol_ms = new OpenLayers.Layer.MapServer( > "Mapserver Untiled" > , "http://localhost/cgi-bin/mapserv.exe?map=C:\\ms4w\ > \Apache\\htdocs\\ol\\map.map" > , {layers: 'state'} > , {singleTile: true} > ); > map.addLayer(ol_ms); > > var gmap = new OpenLayers.Layer.Google("Google Streets"); > map.addLayer(gmap); > > map.zoomToMaxExtent(); > map.addControl(new OpenLayers.Control.LayerSwitcher()); > > } > </script> > </head> > > <body onload="init()"> > <div id="map" class="smallmap" style="width:400;height:300"></div> > </body> > > </html> > = > = > ====================================================================== > > -- > It is from the wellspring of our despair and the places that we are > broken that we come to repair the world. > -- Murray Waas _______________________________________________ > Users mailing list > [email protected] > http://openlayers.org/mailman/listinfo/users _______________________________________________ Users mailing list [email protected] http://openlayers.org/mailman/listinfo/users
