Get Location using wifi or mobile network

Get Location using wifi or mobile network

BY 04 Mar 2015 Web Application Development

Currently i am creating an application for the samsung gear s smartwatch. My widget/app needs to get Location data everywhere (it’s a safety application). The basic GPS location works fine as you can see in my code below. The problem is that GPS only works outside, since my app is a safety app i need to get Location data everywhere. On phones you are able to use Wifi and mobile network to get a location. My question is is it possible to get a location using wifi or mobile network on a smartwatch? and if it’s possible how?
   
   

 function getBestGPSLocation(){  
        //GPS
        navigator.geolocation.getCurrentPosition(success, error, {maximumAge:60000, timeout:5000});
        //Wifi
        // I want wifi location here
        //Mobile Network
    }   
    function error(error) {
    // just some error codes they work either
    switch(error.code) {
        case error.PERMISSION_DENIED:
            console.log("permission denied");
            break;
        case error.POSITION_UNAVAILABLE:
              console.log("your position is unavailable");
            break;
        case error.TIMEOUT:
            console.log("a timeout occured");
            break;
        case error.UNKNOWN_ERROR:
            console.log("an unknow error occured");
            break;
        }
    }

    function success(position) {
    // this works i get all the data
       alert(position);
    }

 

Written by