代碼A



//Check if browser supports W3C Geolocation API if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(successFunction, errorFunction); } else {
alert(’It seems like Geolocation, which is required for this page, is not enabled in your browser. Please use a browser which supports it.’); }

 

代碼B
function successFunction(position) {
var lat = position.coords.latitude;
var long = position.coords.longitude;
alert(’Your latitude is :’+lat+’ and longitude is ‘+long); }

 

創作者介紹
創作者 shadow 的頭像
shadow

資訊園

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