使用手机's在后台模式下的地理定位

Using mobile phone's geolocation in background mode

本文关键字:模式 定位 后台 手机      更新时间:2023-09-26

我计划开发一个基于网络的基于位置的移动应用程序(主要专注于Android,但也可以在iOS上使用),它将使用智能手机的地理位置进行通知
我已经环顾四周了,我很确定我会使用PhoneGap/Cordova来实现(有一个非常好的插件,它可以实现后台地理位置更新),但为了确保这不是唯一的解决方案(除了本地应用程序),我想请你帮忙。

随着谷歌Chrome(适用于Android)最近获得了一些很酷的新功能,如推送通知功能或页面到主屏幕功能,你知道是否可以使用谷歌Chrome或至少在没有任何额外框架的情况下使用地理定位背景功能吗

是的。。。我知道最好的方法是使用本机应用程序实现。感谢您的任何提示:)

您可以使用html5:获取地理位置

<script>
var x = document.getElementById("demo");
function getLocation() {
    if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(showPosition);
    } else {
        x.innerHTML = "Geolocation is not supported by this browser.";
    }
}
function showPosition(position) {
    x.innerHTML = "Latitude: " + position.coords.latitude + 
    "<br>Longitude: " + position.coords.longitude; 
}
</script>