[Users] White map using google layers

emmexx emmexx at tiscalinet.it
Tue Nov 8 13:18:11 CET 2011


I'm new to GeoExt, sorry if I'm asking something obvious.

I'm trying to use more than one google overlay on my mapPanel (not all
overlays).

If I use just one google layer, no problem.
If I use more than one google layer the map flashes and then the map
panel becomes all white. If I pan or change layer the map appears.
This seems to happen only with google layers. I tried using a google
layer and an osm layer and everything works fine.
I tried to use only Openlayers, no extjs or geoext, and there's no problem.

Probably I mixed up too many examples form geoext web site and I'm
missing some parameter or rule.
I'm using google v3 api.

Any suggestion?

Thank you
	maxx

My js code:

Ext.onReady(function() {

map = new OpenLayers.Map('mymap',
		{
			projection: new OpenLayers.Projection("EPSG:900913"),
			displayProjection: new OpenLayers.Projection("EPSG:4326")
		}
	);

var gmap = new OpenLayers.Layer.Google(
		"Google Streets", // the default
		{numZoomLevels: 20}
	);
var ghyb = new OpenLayers.Layer.Google(
		"Google Hybrid",
		{type: google.maps.MapTypeId.HYBRID, numZoomLevels: 20}
	);

var osm = new OpenLayers.Layer.OSM();
	
map.addLayers([gmap, ghyb]);	//not working
//  	map.addLayers([gmap, osm]);	//works!

	
mygxmap = new GeoExt.MapPanel({
		region: "center",
 		map: map,
		title: 'My map',
		'center': new OpenLayers.LonLat(9.191389, 45.464167).transform(
 			new OpenLayers.Projection("EPSG:4326"),
			new OpenLayers.Projection("EPSG:900913")
 		),
 		zoom: 12
	});
	
map.addControl(new OpenLayers.Control.LayerSwitcher());
	
new Ext.Viewport({
        layout: "fit",
        hideBorders: true,
        items: {
            layout: "border",
            deferredRender: false,
            items: [mappa]
        }
    });
	
	
}); /*Ext.onReady*/


Html head:

   <script
src="http://maps.google.com/maps/api/js?v=3.5&amp;sensor=false"></script>
	<script src="/ext-3.4.0/adapter/ext/ext-base.js"
type="text/javascript"></script>
	<script src="/ext-3.4.0/ext-all.js"  type="text/javascript"></script>
	<link rel="stylesheet" type="text/css"
href="/ext-3.4.0/resources/css/ext-all.css"></link>
	<script src="/OpenLayers-2.11/OpenLayers.js"
type="text/javascript"></script>
	<script src="/GeoExt/lib/GeoExt.js" type="text/javascript"></script>
	<link rel="stylesheet" type="text/css"
href="/GeoExt/resources/css/geoext-all-debug.css"></link>


More information about the Users mailing list