地理定位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;
 }


posted @ 2017-04-07 14:59  sakura-sakura  阅读(171)  评论(0编辑  收藏  举报