<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0" />
<title>Sample</title>
<script src="cordova-2.7.0.js" type="text/javascript"></script>
<script type="text/javascript">
if (!navigator.userAgent.toLowerCase().match('chrome')) {
document.write("<script src='phonegap.js'><\/script>");
}
</script>
</head>
<body onload="onLoaded()">
<div class="info" style="font-size:12px">CCN TEST</div>
<script>
function onLoaded() {
alert('onLoaded');
document.addEventListener("deviceready", onDeviceReady, false);
}
function onDeviceReady() {
alert('onDeviceReady');
if(window.navigator.geolocation)
{
alert('你的應用程式支援地理位置定位!');
var geolocation=window.navigator.geolocation;
geolocation.getCurrentPosition(getPositionSuccess, getPositionError);
}else
{
alert('你的程式不支援地理位置定位!');
}
}
function getPositionSuccess(position){
alert('getPositionSuccess');
var lat=position.coords.latitude;
var lon=position.coords.longitude;
alert('你所在的位置:經度'+lat+',緯度'+lon);
}
function getPositionError(err){
alert('getPositionError');
alert('code:'+err.code+'\n'+
'message:'+err.message+'\n');
}
</script>
</body>
</html>

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 amychang2014 的頭像
    amychang2014

    工作需要筆記

    amychang2014 發表在 痞客邦 留言(0) 人氣()