我按照api一步一步,但不能加載成功..爲什麼「谷歌是沒有定義」當我加載谷歌JS API
這是我的代碼:
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
</head>
<body >
<script type="text/javascript" src="http://www.google.com/jsapi?autoload=%7B%22modules%22%3A%5B%7B%22name%22%3A%22gdata%22%2C%22version%22%3A%222.x%22%2C%5B%22callback%22%3A%22onLoad%22%2C%22packages%22%3A%5B%22maps%22%5D%5D%7D%5D%7D"></script>
<script type="text/javascript">
var service = new google.gdata.maps.MapsService('docs-example');
</script>
</body>
</html>
錯誤是:google沒有定義
爲什麼??
upedted
我改變我的代碼,它的工作,但它火的ErrorHandler,然後警告 「錯誤!!!」:
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
</head>
<body >
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
// Load the latest version of the Google Data JavaScript Client
google.load('gdata', '2.x', {packages: ['maps']});
function onGoogleDataLoad() {
// Put your code here
}
// Call function once the client has loaded
google.setOnLoadCallback(onGoogleDataLoad);
</script>
<script type="text/javascript">
var service = new google.gdata.maps.MapsService('docs-example');
listMaps()
function listMaps() {
var list = document.createElement('ul');
var mapFeedUrl = 'http://maps.google.com/maps/feeds/maps/default/owned';
service.getMapFeed(mapFeedUrl, function(feedRoot) {
var feed = feedRoot.feed;
var entries = feed.getEntries();
for (var i = 0; i < entries.length; i++) {
var entry = entries[i];
var mapTitle = entry.getTitle().getText();
var listItem = document.createElement('li');
var listText = document.createTextNode(mapTitle);
listItem.appendChild(listText);
list.appendChild(listItem);
}
document.body.appendChild(list);
}, errorHandler)
}
function errorHandler(){
alert('error!!!')
}
</script>
</body>
</html>
爲什麼呢?
感謝
您是否試過這個http://code.google.com/apis/maps/documentation/javascript/basics.html – 2011-12-07 04:58:54