我有自己生成一個基本的谷歌地圖下面的腳本:生成谷歌地圖錯誤
$(document).ready(function(){
var weatherAPP = {
generateMap: function(){
console.log('called');
var mapHolder = document.getElementById('#map');
var mapOptions = {
center: new google.maps.LatLng(51.5072, 0.1275),
zoom:10,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(mapHolder, mapOptions);
}
};
weatherAPP.generateMap();
});
console.log('called')
被調用的罰款。
我已經包括以以下腳本:
- 谷歌地圖API
- jQuery的
- 腳本
但是我收到以下錯誤:
Uncaught TypeError: Cannot read property 'offsetWidth' of null
'的getElementById( '#圖')'。你的元素其實是'id =「#map」嗎?' – Stryner 2014-10-20 10:46:59
是 – Alex 2014-10-20 10:47:48