Google 可视化未显示在 Google 应用引擎上的 JSP 中
所以我想使用来自 google 的可视化地图,并希望显示在我的 JSP 生成的页面上。 t 托管在 Google AppEngine 上。当我在 Google App Engine 上运行 JSP 时,这是生成的最终输出。然而,编译后,代码看起来不错,当我放入谷歌代码游乐场时,它可以工作,但在谷歌应用程序引擎上,它根本不起作用!这是发送到网页的代码。我完全不知道如何解决这个问题。任何帮助将不胜感激。
谢谢! 乔恩
<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>
So I want to use the visualization map from google and I want to display on my JSP generated page. t is being hosted on Google AppEngine. When I run the JSP on Google App Engine, this is the final output that is generated. However, after being compiled, the code looks good and when I put into google code playground, it works, but on the google app engine, it doesn't work at all! Here is the code that is sent to the webpage. I am at a complete loss as to how to fix this. Any help would greatly be appreciated.
Thanks!
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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
存在一些问题:
块包含以下属性:
language="text/javascript"
。这应该是:type="text/javascript"
document.getElementById('map_canvas'));
而不是document.getElementById( 'container.page-wrap.mainContent.map_canvas'));
drawVisualization
,但请考虑一下:google.setOnLoadCallback(drawVisualization);
将在加载时调用该函数。通过这些更改,代码将运行。希望有帮助!
There are a few issues:
<script>
block that holds your main javascript content includes the following attribute:language="text/javascript"
. This should be:type="text/javascript"
document.getElementById('map_canvas'));
notdocument.getElementById('container.page-wrap.mainContent.map_canvas'));
drawVisualization
, but consider this:google.setOnLoadCallback(drawVisualization);
which will call the function on load.With those changes the code runs. Hope that helps!