消息:“ _ e3”为空或不是对象
行:19
字符:1068
代码:0
URI:http://maps.gstatic.com/intl/en_us/mapfiles/api-3/6/6/main.js

我真的对JavaScript没有任何了解,这是别人的代码,但是有人知道为什么它会在Internet Explorer中导致上述错误吗?

<!DOCTYPE html>
    <html>
    <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <title>Google Maps JavaScript API v3 Example: Marker Animations</title>
    <link href="http://code.google.com/apis/maps/documentation/javascript/examples/default.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
    <script type="text/javascript">
      var stockholm = new google.maps.LatLng(59.32522, 18.07002);
      var parliament = new google.maps.LatLng(59.327383, 18.06747);
      var marker;
      var map;

      google.maps.event.addListener(marker, 'drag', function(event){
           document.getElementById("latbox").value = event.latLng.lat();
           document.getElementById("lngbox").value = event.latLng.lng();
    });

      function initialize() {
        var mapOptions = {
          zoom: 13,
          mapTypeId: google.maps.MapTypeId.ROADMAP,
          center: stockholm
        };

        map = new google.maps.Map(document.getElementById("map_canvas"),
                mapOptions);


        marker = new google.maps.Marker({
          map:map,
          draggable:true,
          animation: google.maps.Animation.DROP,
          position: parliament
        });
        google.maps.event.addListener(marker, 'drag', toggleBounce);

      }

      function toggleBounce() {

        if (marker.getAnimation() != null) {
          marker.setAnimation(null);
        } else {
          marker.setAnimation(google.maps.Animation.BOUNCE);
          document.getElementById("latbox").value=marker.getPosition().lat();
          document.getElementById("lngbox").value=marker.getPosition().lng();
        }
      }
    </script>
    </head>
    <body onload="initialize()">
    <div id="map_canvas" style="width: 500px; height: 400px;">map div</div>
    Lat:<input type="text" id="latbox" name="latbox" style="width:100px;" >
    <br>
    Long:<input type="text" id="lngbox" name="lngbox" style="width:100px;" >
    </body>
    </html>

最佳答案

如果打开IE的开发人员工具,更改为script标记,然后开始调试,则在页面刷新并发生错误时,开发人员工具将显示一个以您的调用为标题的调用堆栈,以将侦听器添加到标记的拖动事件中,并且引用的__e3_是标记的属性,但是尚未创建标记。

创建addListener(marker ...后,将initialize()调用移至marker函数中。

关于javascript - '__e3_'为空或不是对象-Google Maps,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7628796/

10-08 21:04