Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle Maps API load failure ("'google' is undefined") in IE8
    primarykey
    data
    text
    <p>When I load <a href="http://maps.google.com/maps/api/js?sensor=false" rel="noreferrer">http://maps.google.com/maps/api/js?sensor=false</a> in a script tag, everything works fine for me in Chrome, Safari, Firefox, and IE9.</p> <p>However, when I look in IE9 <strong>in compatibility mode</strong> (or, I'm told, in <strong>IE8</strong>) the map does not load and "'google' is undefined" is logged in the console.</p> <p>Here's the relevant code, with the line that is triggering the error identified with a comment:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;Test Map&lt;/title&gt; &lt;script type="application/javascript" src="http://maps.google.com/maps/api/js?sensor=false"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="map_canvas"&gt;&lt;/div&gt; &lt;script type="text/javascript"&gt; var lat=37.763154; var lon=-122.457941; var initialZoom=17; var mapTypeId = 'Custom Map'; var mapStyle = [{featureType:"landscape", elementType:"all", stylers:[{hue:"#dae6c3"},{saturation:16},{lightness:-7}]}, {featureType:"road", elementType:"geometry", stylers:[{hue:"#ffffff"},{saturation:-100},{lightness:100}]}]; //**The error is tripped in this next line, again only in IE9 compatibility mode or IE8* var styledMap = new google.maps.StyledMapType(mapStyle); var mapType = new google.maps.ImageMapType({ tileSize: new google.maps.Size(256,256), getTileUrl: function(coord,zoom) { return "img/tiles/"+zoom+"/"+coord.x+"/"+coord.y+".png"; } }); var map = new google.maps.Map(document.getElementById("map_canvas"), {center:new google.maps.LatLng(lat,lon), mapTypeId:google.maps.MapTypeId.ROADMAP, zoom:initialZoom, mapTypeControl:false}); map.overlayMapTypes.insertAt(0, mapType); map.mapTypes.set(mapTypeId, styledMap); map.setMapTypeId(mapTypeId); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>So, for some reason, and only in IE9+compatibility-mode and IE8, the script tag specifying <a href="http://maps.google.com/maps/api/js?sensor=false" rel="noreferrer">http://maps.google.com/maps/api/js?sensor=false</a> isn't loading and/or executing before the subsequent embedded script in the body.</p> <p>Are others able to replicate? How do I correct this problem?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload