我在google appengine上将谷歌地图添加到我的webapp时出现问题。我运行locally时工作正常。
我的index.html如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<link type="text/css" rel="stylesheet" href="style.css">
<script type="text/javascript" language="javascript" src="js/mingitegevus.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?sensor=true"></script>
<script type="text/javascript" language="javascript" src="js/map_canvas_initialize().js"></script>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Spordikaart</title>
</head>
<body>
<table>
<tr>
<p id="test">Vinge programm</p>
</tr>
<tr>
<form><input type='button' value="Touch me" onclick="touch()";></form>
</tr>
</table>
<div id="map_canvas" class="map_canvas"></div>
</body>
</html>
所以map_canvas_initialize()。js不起作用/加载。 Appengines日志也不多说:
/js/map_canvas_initialize().js 200 81ms 0kb Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36 module=default version=1
90.213.123.96 - - [18/Feb/2014:04:51:12 -0800] "GET /js/map_canvas_initialize().js HTTP/1.1" 200 59 "http://spordikaart.appspot.com/" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36" "spordikaart.appspot.com" ms=81 cpu_ms=2902 cpm_usd=0.000007 app_engine_release=1.8.9 instance=00c61b117c9fde1367f47afa69ce18e068eec8
map_canvas_initialize()。js如下:
var initialLocation;
var browserSupportFlag = new Boolean();
var l = new google.maps.LatLng(52, 22);
function initialize() {
var map_canvas = document.getElementById('map_canvas');
var mapOptions = {
zoom : 18,
mapTypeId : google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(map_canvas, mapOptions);
if (navigator.geolocation) {
browserSupportFlag = true;
navigator.geolocation.getCurrentPosition(function(position) {
initialLocation = new google.maps.LatLng(position.coords.latitude,
position.coords.longitude);
map.setCenter(initialLocation);
}, function() {
handleNoGeolocation(browserSupportFlag);
});
} else {
browserSupportFlag = false;
handleNoGeolocation(browserSupportFlag);
}
function handleNoGeolocation(errorFlag) {
if (errorFlag == true) {
alert("Geolocation service failed");
initialLocation = l;
} else {
alert("Browser does not support geolocation.");
initialLocation = l;
}
map.setCenter(initialLocation);
}
}
google.maps.event.addDomListener(window, 'load', initialize);
的web.xml:
<?xml version="1.0" encoding="utf-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<servlet>
<servlet-name>Kaart</servlet-name>
<servlet-class>com.kaart.KaartServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Kaart</servlet-name>
<url-pattern>*.js</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Kaart</servlet-name>
<url-pattern>*.css</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Kaart</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
项目结构:
任何想法从哪里开始寻找?