2013-04-25 29 views

回答

1

您可以使用地理定位API來獲取當前位置。使用我上面所提到的API

http://mobile.tutsplus.com/tutorials/mobile-web-apps/html5-geolocation/

保存在變量中的位置:

var currentLocation; //this variable will store current location. 
    jQuery(window).ready(function(){ 
       jQuery("#btnInit").click(initiate_geolocation); 
      }); 
      function initiate_geolocation() { 
       //store current location 
       currentLocation = navigator.geolocation.getCurrentPosition(handle_geolocation_query); 
      } 
      function handle_geolocation_query(position){ 
       alert('Lat: ' + position.coords.latitude + ' ' + 
         'Lon: ' + position.coords.longitude); 
      } 
相關問題