1. 程式人生 > >JS新API標準 地理定位(navigator.geolocation

JS新API標準 地理定位(navigator.geolocation

targe article n) long smo enable type details ref

<script type="text/javascript">
    var options = {
        enableHighAccuracy:false,
        timeout:8000,
        maximumAge:1000
    }
    var long = 0;
    var lat = 0;
    navigator.geolocation.getCurrentPosition(onSuccess, onError, options);

    function onSuccess(position){
    var long = position.coords.longitude;
    
var lat = position.coords.latitude; alert(long+=>+lat); console.log(position); } function onError(error) { console.log(error); } </script>

JS新API標準 地理定位

JS新API標準 地理定位(navigator.geolocation