[OpenLayers-Users] Untiled WMS on top of Google Maps doesn't always show up

Arjen de Korte arjendk at gmx.net
Tue Aug 3 10:38:08 EDT 2010


Dear all,

I'm trying to show an untiled WMS layer on top of a Google Map in
OpenLayers, but under certain conditions (esp. zoomlevel 2) the overlay
is not displayed. I have this problem with our own WMS layers but also
with the "default" MetaCarta WMS layer, both in Firefox 3.6 and IE8,
using Openlayers 2.9.1.

The code below (init function is called on page load) will load Google
Maps as the base layer and overlay it with the default MetaCarta WMS as
an untiled WMS layer. The WMS layer is set to display by default but it
is not shown in the browser in the default extent. When you zoom in it
does show up.

Note that this only applies to untiled WMS, for tiled WMS (singleTile =
false) it works fine. Also note that the WMS layer is actually loaded
correctly (as can be shown by e.g. Firebug), it just isn't displayed for
some reason.

I'd be grateful for any hints or suggestions to solve this problem!

Kind regards,

Arjen.



var map, layer;

function init(){

	var options = {
		projection: new OpenLayers.Projection("EPSG:900913"),
		displayProjection: new OpenLayers.Projection("EPSG:4326"),
		units: "m",
		numZoomLevels: 18,
		maxResolution: 156543.0339,
		maxExtent: new OpenLayers.Bounds(-20037508, -20037508, 20037508, 20037508.34)
	};

	map = new OpenLayers.Map('map', options);

	var gmap = new OpenLayers.Layer.Google(
		"Google Maps",
		{'sphericalMercator': true}
	);

	map.addLayer(gmap);

	var wmslayer = new OpenLayers.Layer.WMS("OpenLayers WMS","http://labs.metacarta.com/wms/vmap0?",
		   {'layers': 'basic', 'format':'image/png', 'transparent':'true'},
		   {'opacity': 0.9, 'isBaseLayer': false, 'visibility': true, 'singleTile' : true}
	);

	map.addLayer(wmslayer);

	map.addControl(new OpenLayers.Control.LayerSwitcher());
	map.addControl(new OpenLayers.Control.MousePosition());

	var point = new OpenLayers.LonLat(-20, 50);
	point.transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject());
	map.setCenter(point, 2);
}



More information about the Users mailing list