地理定位Geolocation API

地理定位Geolocation API
•       getCurrentPosition()函數簡介
•       getCurrentPosition(successCallback,errorCallback,positionOptions)
function getLocation()
  {
  if (navigator.geolocation)
    {
    navigator.geolocation.getCurrentPosition(showPosition);
    }
  else{x.innerHTML=請升級瀏覽器.";}
  }
function showPosition(position)
  {
  x.innerHTML="Latitude: " + position.coords.latitude +
  "<br />Longitude: " + position.coords.longitude;
 }
相關文章
相關標籤/搜索