[OpenLayers-Users] layerswitcher not working in IE7 or 8 Standards
Mode
Joseph Miller
jamiller at usgs.gov
Fri Nov 20 17:45:45 EST 2009
Hey All,
I am stuck in a situation where I have to set the doctype to:
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
in order to support non-map content on my page. In addition we are
forcing IE8 into compatibility mode using:
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>
Everything works fine in Firefox and Chrome but in IE8 the layerswitcher
will not switch in between Google base map options. The only way to
change layers is to switch to quirks mode (not an option) or to refresh
the entire page after click on the layerswicher radio button (also
impractical). The dimensions of the map are set in pixels in a
stylesheet, so that is not the source of the problem. An example of this
behaviour cobbled together from our headers and an example from the
OpenLayers site:
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<meta http-equiv="X-UA-Compatible"
content="IE=EmulateIE7"/>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta content="text/html;charset=ISO-8859-1" />
<title>OpenLayers Google Layer Example</title>
<link rel="stylesheet" href="../theme/default/style.css" type="text/css"
/>
<link rel="stylesheet" href="../theme/default/google.css" type="text/css"
/>
<link rel="stylesheet" href="style.css" type="text/css" />
<!-- this gmaps key generated for http://openlayers.org/dev/ -->
<script src='
http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhR_wWLPFku8Ix9i2SXYRVK3e45q1BQUd_beF8dtzKET_EteAjPdGDwqpQ
'></script>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
var map;
function init() {
map = new OpenLayers.Map('map');
map.addControl(new OpenLayers.Control.LayerSwitcher());
var gphy = new OpenLayers.Layer.Google(
"Google Physical",
{type: G_PHYSICAL_MAP}
);
var gmap = new OpenLayers.Layer.Google(
"Google Streets", // the default
{numZoomLevels: 20}
);
var ghyb = new OpenLayers.Layer.Google(
"Google Hybrid",
{type: G_HYBRID_MAP, numZoomLevels: 20}
);
var gsat = new OpenLayers.Layer.Google(
"Google Satellite",
{type: G_SATELLITE_MAP, numZoomLevels: 20}
);
map.addLayers([gphy, gmap, ghyb, gsat]);
map.setCenter(new OpenLayers.LonLat(10.2, 48.9), 5);
}
</script>
</head>
<body onload="init()">
<h1 id="title">Google Layer Example</h1>
<div id="tags"></div>
<p id="shortdesc">
Demonstrate use of the various types of Google layers.
</p>
<div id="map" class="smallmap"></div>
<div id="docs">
<p>
For best performance, you must be using a version of the Google Maps
API which is v2.93 or higher. In order to use this version of the API,
it is best to simply set your application to use the string "v=2" in
the request, rather than tying your application to an explicit
version.</p>
<p>
In order to position the Google attribution div in the default ocation,
you must include the extra theme/default/google.css stylesheet.</p>
</div>
</body>
</html>
Thanks in advance,
Joe Miller
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20091120/19d197a8/attachment.html
More information about the Users
mailing list