InvalidStateError: "An Attempt Was Made To Use An Object That Is Not, Or Is No Longer, Usable" In Basic Google Map Tutorial Example
I have an XML, which is transformed to HTML via an XSLT. The XML is able to contain JavaScript, and it translates this correctly to HTML, as I do in many other pages as well. It ju
Solution 1:
I find the most common cause of this error is simply an invalid img src.
Solution 2:
I found this Google page (webarchive). It seems undocumented, though. Click on the button. Works on both FF and IE. Check out the markup and the Javascript, it loads the map via a callback.
Thanks for putting me on the right track.
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Google Maps JavaScript API v3 Example: Dynamic Loading</title>
<script type="text/javascript">
function handleApiReady() {
var myLatlng = new google.maps.LatLng(-34.397, 150.644);
var myOptions = {
zoom: 8,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
}
function appendBootstrap() {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "http://maps.google.com/maps/api/js?sensor=false&callback=handleApiReady";
document.body.appendChild(script);
}
</script>
</head>
<body style="margin:0px; padding:0px;">
<input type="button" value="Load Bootstrap + API" onclick="appendBootstrap()">
<div id="map_canvas" style="width:400px; height:400px"></div>
</body>
</html>
Solution 3:
My error was something similar (which is why I found this post), but only in Internet Explorer (version 11):
File: eval code (401), Line: 39, Column: 304
This was caused because I used svg-images as markers:
var marker = map.addMarker({
lat: position.coords.latitude,
lng: position.coords.longitude,
icon : {
url : '/images/marker.svg'
}
});
Switching to png-images instead of svg solved my problem!
Post a Comment for "InvalidStateError: "An Attempt Was Made To Use An Object That Is Not, Or Is No Longer, Usable" In Basic Google Map Tutorial Example"