0
我只是想嘗試與Android設備的手機差距。我發現了一個基於地圖的應用程序here針對android的手機間隙地圖問題
以下是我試圖運行
<html>
<head>
<meta name="viewport" content="width=device-width; height=device-height; user-scalable=no" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Beer Me</title>
<link rel="stylesheet" href="/master.css" type="text/css" media="screen" />
<script type="text/javascript" src="scripts/phonegap.js"></script>
<script type="text/javascript">
function loader()
{
var state = document.readyState;
if (state == 'loaded' || state == 'complete')
{
run();
}
else
{
if (navigator.userAgent.indexOf('Browzr') > -1)
{
setTimeout(run, 250);
}
else
{
document.addEventListener('deviceready',run,false);
}
}
}
function run()
{
var win = function(position) { // Grab coordinates object from the Position object passed into success callback.
var coords = position.coords;
var url = "http://maps.google.com/maps/api/staticmap?center=" + coords.latitude + "," + coords.longitude + "&zoom=13&size=320x480&maptype=roadmap&key=xxxxxxxxxxxxxxxxxxx&sensor=true";
document.getElementById('map').setAttribute('src',url);
};
var fail = function(e)
{
alert('Can\'t retrieve position.\nError: ' + e);
};
navigator.geolocation.getCurrentPosition(win, fail);
}
</script>
</head>
<body onload="loader();">
<img id="map" />
</body>
</html>
的JavaScript時,我在Android設備上運行它顯示一個警告框,Can\'t retrieve position
。 位置函數未被調用。如何獲得電話差距的地方的位置javascript,請幫助我....