I am getting (lat,long) coordinates in phonegap geolocation without using internet or GPS ?

我是研究僧i 提交于 2019-12-12 12:15:08

问题


When i tried out a sample program in phonegap geolocation. I am getting the latitude and longitude of my current location without internet or GPS in my samsung pop. I don't know how it is getting the coordinates, altitude and timestamp of the current location when the wifi and gps in my device is DISABLED. Kindly help me..

   <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org    /TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
        <title>My Locator</title>
        <script type="text/javascript" charset="utf-8" src="../plugins/phonegap-1.1.0.js"></script>
        <script type="text/javascript" charset="utf-8">
            document.addEventListener("deviceready", onDeviceReady, false);
            function onDeviceReady() {
                navigator.geolocation.getCurrentPosition(onSuccess,Error);
            }
        function onSuccess(position) {
                var element = document.getElementById('geolocation');
            element.innerHTML = 'Latitude: ' + position.coords.latitude 
                + '<br />' + 'Longitude: ' + position.coords.longitude 
                + '<br />' + 'Accuracy: ' + position.coords.accuracy 
                + '<br />' + 'Timestamp: ' + new Date(position.timestamp)  + '<br />';

            }
        function onError(error) {
                alert('code: ' + error.code + '\n' + 'message: ' + error.message + '\n');
            }

        </script>
    </head>
    <body>
        <p id="geolocation">
            Finding geolocation...
        </p>
    </body>
</html>

回答1:


"Common sources of location information include Global Positioning System (GPS) and location inferred from network signals such as IP address, RFID, WiFi and Bluetooth MAC addresses, and GSM/CDMA cell IDs."

http://docs.phonegap.com/en/1.7.0/cordova_geolocation_geolocation.md.html#Geolocation




回答2:


You are getting the coordinates from web browser's GeoLocation API.



来源:https://stackoverflow.com/questions/10444279/i-am-getting-lat-long-coordinates-in-phonegap-geolocation-without-using-intern

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!