我正在尝试从 WebWorks 应用程序中显示 Google map 。这是应用程序中该页面的完整 HTML(请注意,它在浏览器中运行良好):
<!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)。
最佳答案
您使用的是什么版本的模拟器?有一个 known issue在 0.9.4 之前的版本中,当在 URL 上传递参数时以及访问本地文件时会导致问题。您可以尝试链接到外部 JQuery 库以排除最后一点(不要忘记为其添加 <access>
元素)?
你能发布<access>
吗?您在 config.xml 中定义的元素?我想知道你是否需要 subdomains="true"
还是类似的东西?
<access subdomains="true" uri="http://maps.google.com/maps/api/js"/>
除此之外,我建议您继续从页面中剥离内容,直到出现某些内容,例如删除 meta name="viewport"
排队然后从那里去......
关于javascript - 在 BlackBerry WebWorks 应用程序中显示 Google map ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5208583/