2016-01-20 74 views
0

我已经尝试过这种代码无法读取的未定义的属性“地图”玉和骨干,而它与HTML

<html> 
<head> 
<script src="http://maps.googleapis.com/maps/api/js"></script> 
<script> 
function initialize() { 
var mapProp = { 
center:new google.maps.LatLng(41.63, -1), 
zoom:5, 
mapTypeId:google.maps.MapTypeId.ROADMAP 
}; 
var map=new google.maps.Map(document.getElementById("googleMap"), mapProp); 
} 
google.maps.event.addDomListener(window, 'load', initialize); 
</script> 
</head> 
<body> 
<div id="googleMap" style="width:500px;height:380px;"></div> 
</body> 
</html> 

和它的工作完美地展示了谷歌地图的图像,但我已经集成了这个工作提高到一个用木偶和玉做了较大的项目,它表明: 遗漏的类型错误:无法读取属性“地图”的不确定 不收取整个谷歌地图的文件(如:http://maps.googleapis.com/maps-api-v3/api/js/23/5/map.js) 我views.js我已经写了:

mod.mapTemplate = Marionette.ItemView.extend({ 
    template:_.template($('#actors-map-template').html()), 
initialize: function() { 
    var mapProp = { 
    center: new google.maps.LatLng(41.63, -1), 
    zoom: 5, 
    mapTypeId: google.maps.MapTypeId.ROADMAP 
    }; 
    var map = new google.maps.Map(document.getElementById(
    'googleMap'), mapProp); 
}, 
onRender: function() { 
    //this.initializemap(); 
    google.maps.event.addDomListener(window, 'load', this.initialize); 
} 
}); 

,在我玉页:

#googleMap(style='width:500px;height:380px;') 

脚本在其他文件中添加与初始化整个应用程序的所有脚本,我不能改变的架构,这是不是我的。

回答

0

如果有人得到了同样的问题,在这里是如何为我工作: 我已经添加在头两个脚本: 脚本(SRC =“/ lib中/谷歌地图/ lib目录/ Google.js”) 脚本(src ='http://maps.googleapis.com/maps/api/js') 并用此行替换变量映射: var map = new google.maps.Map(this。$ el [0],mapProp); 因为它应该读取元素。 但仍然是渲染问题

相关问题