'__e3_'为空或不是对象-Google Maps [英] '__e3_' is null or not an object - google maps
问题描述
消息:"_ e3 "为空或不是对象行:19字符:1068代码:0URI: 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示例:标记动画</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标记;var map;google.maps.event.addListener(marker,'drag',function(event){document.getElementById("latbox").value = event.latLng.lat();document.getElementById("lngbox").value = event.latLng.lng();});函数initialize(){var mapOptions = {变焦:13mapTypeId:google.maps.MapTypeId.ROADMAP,中心:斯德哥尔摩};map = new google.maps.Map(document.getElementById("map_canvas"),mapOptions);marker = new google.maps.Marker({地图:地图,draggable:true,动画:google.maps.Animation.DROP,立场:议会});google.maps.event.addListener(marker,'drag',toggleBounce);}函数toggleBounce(){如果(marker.getAnimation()!= null){marker.setAnimation(null);} 别的 {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>纬度:<输入type ="text" id ="latbox" name ="latbox" style ="width:100px;">< br>长:<输入type ="text" id ="lngbox" name ="lngbox" style ="width:100px;"></body></html>
如果打开IE的开发人员工具,更改为脚本标签,然后开始调试,那么当页面刷新并发生错误时,开发人员工具将显示一个以您的调用为首的调用堆栈,以将侦听器添加到标记的拖动事件中,并且引用的 __ e3 _
是标记的属性,但是尚未创建标记.
在创建 marker
后,将 addListener(marker ...
)调用移至 initialize()
函数中./p>
Message: '_e3' is null or not an object Line: 19 Char: 1068 Code: 0 URI: http://maps.gstatic.com/intl/en_us/mapfiles/api-3/6/6/main.js
I really have no clue on javascript and this is someone elses code, but does anyone know why it causes the above error in 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>
If you open IE's developer tools, change to the script tag, and start debugging, then when the page refreshes and the error occurs, the developer tools will show a call stack headed by your call to add a listener to the drag event of a marker, and the __e3_
being referenced is a property of the marker, but you have not created the marker.
Move the addListener(marker ...
call to within the initialize()
function, after you've created the marker
.
这篇关于'__e3_'为空或不是对象-Google Maps的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!