如何在JavaScript中打开或关闭GPS用户设备?此代码无效。 [英] How to find user device is GPS on or off in javascript? This code is not working.

查看:65
本文介绍了如何在JavaScript中打开或关闭GPS用户设备?此代码无效。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<pre>// Function to get location
    function getLocation() {
        navigator.geolocation.getCurrentPosition(function (pos) {
            var lat = pos.coords.latitude;
            var lng = pos.coords.longitude;
            if (lat == null) {
                navigator.notification.alert("GPS not activated!", null, "GPS", "Ok");
            }
            else {
                navigator.notification.alert("Latitude: " + lat + " , Longitude: " + lng, null, "GPS", "Ok");
            }
        });
    }</pre>





我的尝试:



如何在JavaScript中打开或关闭用户设备?

如何解决此问题。



What I have tried:

How to find user device is GPS on or off in javascript?
how to i resolve this.

推荐答案

您已在Javascript论坛中发布此内容;请不要多发同一个问题。
You already posted this in the Javascript forum; please do not multi-post the same question.


这篇关于如何在JavaScript中打开或关闭GPS用户设备?此代码无效。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆