这个Google jQuery GeoChart 插件像这样工作得很好:
<script type='text/javascript' src='https://www.google.com/jsapi'></script>
<script type='text/javascript'>
google.load('visualization', '1', {'packages': ['geochart']});
google.setOnLoadCallback(drawRegionsMap);
function drawRegionsMap() {
// code to draw map
};
</script>
但是将代码移动到类中会破坏一切。浏览器为空白,状态仍为“正在从 www.google.com 传输数据”。
(function( someClass, undefined ) {
someClass.init= function() {
console.log(google); //google object defined but next line breaks:
google.load('visualization', '1', {'packages': ['geochart']});
...remainder of code
};
}( window.Project.Pages.someClass = window.Project.Pages.someClass || {}));
关于为什么的任何想法?