知道我在这个谷歌地图视图中做错了什么?
我从下面的代码中得到此错误。 未捕获的TypeError:无法设置未定义的属性“位置”
var MapView = function () {
// var latlong;
this.initialize = function() {
$(document).ready(function() {
//initializeMap();
});
this.$el = $('<div/>');
this.render();
};
initializeMap = function() {
console.log("initializing map");
var mapc = $("#map-canvas");
console.log(mapc);
var mapOptions = {
center: { lat: -34.397, lng: 150.644},
zoom: 8
};
console.log(mapOptions);
var map;
if (mapc){
map = new google.maps.Map(mapc,
mapOptions);
}
if (map){
console.log(map);
}
else {console.log("no map") };
}
this.render = function() {
this.$el.html(this.template());
google.maps.event.addDomListener(window,"load", initializeMap(), false);
return this;
};
this.initialize();
}
控制台日志
初始化地图MapView.js:16
2014-11-25 15:51:20.181 [context:document,selector:“#map-canvas”,jquery:“2.1.1”,constructor:function,toArray:function ...] MapView.js:21 < / p>
2014-11-25 15:51:20.184Object {center:Object,zoom:8} MapView.js:26
2014-11-25 15:51:20.188Ln {gm_bindings_:Object,__ gm:Wh,gm_accessors_:Object,center:df,zoom:8 ...} MapView.js:35
2014-11-25 15:51:20.189初始化地图MapView.js:16
2014-11-25 15:51:20.189 [context:document,selector:“#map-canvas”,jquery:“2.1.1”,constructor:function,toArray:function ...] MapView.js:21 < / p>
2014-11-25 15:51:20.191Object {center:Object,zoom:8} MapView.js:26
2014-11-25 15:51:20.192Ln {gm_bindings_:Object,__ gm:Wh,gm_accessors_:Object,center:df,zoom:8 ...} MapView.js:35
2014-11-25 15:51:20.226Uncaught TypeError:无法设置undefined的属性'position'