Skip to content Skip to sidebar Skip to footer

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><metaname="viewport"content="initial-scale=1.0, user-scalable=no" /><metahttp-equiv="content-type"content="text/html; charset=UTF-8"/><title>Google Maps JavaScript API v3 Example: Dynamic Loading</title><scripttype="text/javascript">functionhandleApiReady() {
    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);
  }

  functionappendBootstrap() {
    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><bodystyle="margin:0px; padding:0px;"><inputtype="button"value="Load Bootstrap + API"onclick="appendBootstrap()"><divid="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:evalcode(401),Line:39,Column:304

This was caused because I used svg-images as markers:

varmarker=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"