我試圖從WebWorks應用程序內顯示Google地圖。這是在應用程序,網頁的完整的HTML(注意,在瀏覽器中正常工作):在BlackBerry WebWorks應用程序中顯示Google地圖
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" id="viewport" content="height=device-height,width=device-width,user-scalable=no" />
<title>Waste Management Service Request</title>
<style type="text/css">
body {
min-height: 500px;
}
.center {
text-align: center;
}
#page {
font-family: Arial, sans-serif;
font-size: 85%;
width: 408px;
margin: 0 auto;
padding: 0 30px;
}
h3 {
color: #006A3C;
}
#map-canvas {
height: 300px;
}
</style>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
if (typeof(blackberry) != "undefined") {
blackberry.system.event.onHardwareKey(blackberry.system.event.KEY_BACK, function() {
history.back();
});
}
$(document).ready(function(){
var geocoder, map;
geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(-34.397, 150.644);
var mapOptions = {
zoom: 8,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
address = '100 1st St., New York City, NY'; // Hardcoded for testing.
geocoder.geocode({'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
} else {
alert("The map failed because: " + status);
}
});
})
</script>
</head>
<body>
<div id="page">
<h3>Local Map</h3>
<div id="map-canvas"></div>
</div>
</body>
</html>
從應用程序中,它只是顯示一個灰色框,應用程序應該會出現。
請注意,代碼主要從this example page的源代碼中抽取,該代碼鏈接從here鏈接。
任何想法?我最好在這裏採用Google提供動態呈現靜態圖像的方式(即this technique),還是有些東西我錯過了以獲取真實的東西?
順便說一句,我試着爬過gmaps的JS調用堆棧,並將每個域添加到應用程序權限列表中。我擁有gmaptiles.co.kr,google.com,googleapis.com和gstatic.com的權限條目(包括http和https)。
我剛剛發現的另一個問題WebWorks系統並未指出基於頭部的ajax請求,這破壞了檢測到ajax請求的CakePHP系統,返回html而沒有
等標籤。沒有樂趣調試這個東西! – Russell 2011-03-21 04:00:59