[Users] Is there a workaround to display own basemaps with google maps?

Charles Galpin cgalpin at lhsw.com
Thu Mar 3 15:42:51 CET 2011


Robert this is really an openlayers question, but the answer is that you don't have to do anything other than configure the map options properly to have the displayProjection be EPSG:4326 and the projection EPSG:900913.

There should be plenty of examples out there of people using maps that let you use both google and other base layers (like OSM) on the same map. Here is how I do it

	    var options = {
                // the "community" epsg code for spherical mercator
                projection: "EPSG:900913",
                displayProjection: new OpenLayers.Projection("EPSG:4326"),

                // map horizontal units are meters
                units: "m",
 
                // this resolution displays the globe in one 256x256 pixel tile
                maxResolution: 78271.51695,
  
                // these are the bounds of the globe in sperical mercator
                maxExtent: new OpenLayers.Bounds(-20037508, -20037508,
                                                 20037508, 20037508)
                                                 
                ,controls: [ new OpenLayers.Control.Navigation()]
            };
            // construct a map with the above options
            map = new OpenLayers.Map('map', options);
			// create OSM layer
            var osm = new OpenLayers.Layer.OSM.Osmarender("OSM Osmarender");
            
            // create Google layer
            var zoomlevels = 20;
            var gmap = new OpenLayers.Layer.Google(
		"Google Streets", // the default
                {numZoomLevels: zoomlevels, sphericalMercator: true}
            );
			// more layers here

			// add the created layers to the map
            map.addLayers([gmap, osm]);
  
Etc.

hth,
charles

On Mar 3, 2011, at 9:33 AM, Robert Buckley wrote:

> Hi,
> 
> I have my own topographic maps which I would like to use as base maps. They are in EPSG:4326
> 
> To display them with googlemaps would mean I would have to transform them on the fly into 900913, correct?
> 
> Does this bring any disadvantages? quality, loading time?...or should I reproject them in geoserver first?
> 
> thanks for any tips,
> 
> Robert

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20110303/773c40ec/attachment.htm 


More information about the Users mailing list