谷歌可视化没有显示在谷歌应用程序引擎的JSP中
Google Visualization not showing in JSP on google app engine
所以我想使用谷歌的可视化地图,并且我想在JSP生成的页面上显示。t正在Google AppEngine上托管。当我在GoogleAppEngine上运行JSP时,这是生成的最终输出。然而,编译后,代码看起来不错,当我把它放进谷歌代码游乐场时,它可以工作,但在谷歌应用程序引擎上,它根本不工作!这是发送到网页的代码。我完全不知道如何解决这个问题。如有任何帮助,我们将不胜感激。
谢谢!Jon
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>People</title>
<script src="http://maps.google.com/maps?file=api&v=2&sensor=true&key=GOOGLEAPIKEYTHATISVALID" type="text/javascript"></script>
<script type='text/javascript' src='https://www.google.com/jsapi'></script>
<script language="text/javascript">
google.load('visualization', '1', {packages: ['geomap']});
function drawVisualization() {
var data = new google.visualization.DataTable();
data.addRows(4);
data.addColumn('string', 'State');
data.addColumn('number', 'Popularity');
data.setValue(0, 0, 'Pennsylvania');
data.setValue(0, 1, 10);
data.setValue(1, 0, 'New York');
data.setValue(1, 1, 15);
data.setValue(2, 0, 'California');
data.setValue(2, 1, 5);
data.setValue(3, 0, 'New Jersey');
data.setValue(3, 1, 8);
var options = {};
options['region'] = 'US';
var geomap = new google.visualization.GeoMap(
document.getElementById('container.page-wrap.mainContent.map_canvas'));
geomap.draw(data, options);
}
</script>
</head>
<body > ##I have also done <body onload="drawVisualization()"> and that doesn't work either!
<div id="container">
<div id="headerBar">
<P> this is a pretty header </p>
</div>
<div id="page-wrap">
<div id="mainContent">
<div id="map_canvas"></div>
</div>
</div>
<!-- This clearing element should immediately follow the #mainContent div in order to force the #container div to contain all child floats -->
<div id="footer">
<P> This is the footer</P>
<!-- end #footer -->
</div>
<!-- end #container -->
</div>
</body>
</html>
有几个问题:
- 包含主javascript内容的
<script>
块包括以下属性:language="text/javascript"
。这应该是:type="text/javascript"
- 对元素的引用应该是
document.getElementById('map_canvas'));
而不是document.getElementById('container.page-wrap.mainContent.map_canvas'));
- 我不确定您打算如何触发
drawVisualization
,但请考虑一下:google.setOnLoadCallback(drawVisualization);
,它将在加载时调用函数
有了这些更改,代码就会运行。希望能有所帮助!
相关文章:
- 谷歌文档表面引擎
- 自定义运行时Can'在谷歌应用引擎中看不到我的自定义日志
- 在谷歌应用引擎上用jQuery处理json表单
- 如何创建谷歌图像引擎效果
- 频道谷歌应用程序引擎频道.open()不工作
- 一个网站有什么方法可以区分微软边缘和谷歌Chrome吗;的渲染引擎
- 无法使用谷歌应用引擎播放音频.它在本地工作
- 在谷歌应用引擎(python)中实时更新图表
- 如何将数据从谷歌应用引擎数据存储获取到客户端的角度js中
- 谷歌地图API - 融合表/地图引擎打开/关闭..与搜索相结合
- 如何更新谷歌地图引擎表
- 如何向谷歌应用引擎发出许多 ajax 请求 blob
- 地图引擎谷歌-地图插入
- 使用谷歌云端点将文件上传到谷歌应用程序引擎应用程序
- Javascript没有'我不能在本地主机上使用谷歌应用程序引擎
- jQuery在谷歌应用引擎上不适用于我
- 谷歌应用程序引擎频道令牌无效
- 带有ajax请求和python交互的谷歌应用程序引擎
- 通过谷歌应用程序引擎通道api发送数据uri
- 如何在谷歌应用引擎中返回延迟任务的数据