出现google未定义,求解,代码如下
<!DOCTYPE html>
<html dir="LTR">
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<style type="text/css">
html
{
height: 100%;
}
body
{
height: 100%;
margin: 0px;
padding: 0px;
}
#map_canvas
{
height: 600px;
width: 600px;
}
</style>
<title>Google Maps</title>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
var map;
function initialize() {
var myLatlng = new google.maps.LatLng(100.300, 120.600);
var myOptions = {
zoom: 8,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
}
// function loadScript() {
// var script = document.createElement("script");
// script.type = "text/javascript";
// script.src = "http://maps.google.com/maps/api/js?sensor=false&callback=initialize";
// document.body.appendChild(script);
// }
//window.onload = loadScript;
</script>
</head>
<body onload="initialize()">
<div id="map_canvas">
</div>
</body>
</html>
但是,如果把loadScript()解注释掉,同时,解注释掉window.onload那句,注释掉<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>这句,就可以在浏览器和桌面应用程序中加载地图,求解。
------解决方案--------------------恭喜楼主,你可以结贴了
------解决方案--------------------
排队等着接分,提醒楼主,如果不把分给完的话,否则系统不返回给分的一半
------解决方案--------------------