地理定位插件被移除后,科尔多瓦地理位置仍然有效 [英] Cordova geolocation still works after geolocation plugin is removed

查看:280
本文介绍了地理定位插件被移除后,科尔多瓦地理位置仍然有效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Android上,科尔多瓦的地理位置插件一贯大约需要6秒固定的位置时的其他应用程序立即返回一个位置的大部分时间,几乎从来不2s以上。

On Android, Cordova's geolocation plugin consistently takes about 6s to fix a location when other apps return a location instantly most of the time and almost never take more than 2s.

我碰到这个帖子<少时href=\"http://stackoverflow.com/questions/23383750/phonegap-geolocation-sometimes-not-working-on-android\">Phonegap地理位置有时不工作在Android 并删除了地理位置插件,而按照指示:

I came across this post Phonegap geolocation sometimes not working on android and removed the geolocation plugin while following the instructions:

cordova plugin rm cordova-plugin-geolocation

要验证的插件被移除我跑了应用程序再次使用离子运行的Andr​​oid 期待下面的调用失败

To verify that the plugin was removed I ran the app again using ionic run android expecting the following call to fail

var posOptions = {enableHighAccuracy: false, timeout: 10000};

$cordovaGeolocation
    .getCurrentPosition(posOptions)
    .then(function (position) {
        return new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
    }, function() {
        $cordovaToast.showLongCenter('Could not get current location. Is GPS Enabled?');
    });

但它像以前一样工作完全吻合。所以,我添加和删除Android平台的思维插件可能会被缓存:

But it's working exactly as before. So I added and removed the android platform thinking the plugin might be cached:

cordova platform rm android
cordova platform add android
cordova plugin list

com.tiltshiftfocus.cordova.plugin.clearCache 1.0.5 "Clear Cache"
cordova-plugin-camera 2.1.0 "Camera"
cordova-plugin-crosswalk-webview 1.5.0 "Crosswalk WebView Engine"
cordova-plugin-device 1.1.0 "Device"
cordova-plugin-file 3.0.0 "File"
cordova-plugin-file-transfer 1.4.0 "File Transfer"
cordova-plugin-statusbar 2.0.0 "StatusBar"
cordova-plugin-whitelist 1.2.1 "Whitelist"
cordova-plugin-x-toast 2.4.0 "Toast"
ionic-plugin-keyboard 1.0.8 "Keyboard"
plugin.google.maps 1.3.9 "phonegap-googlemaps-plugin"

我也清除的WebView缓存以防万一

And I also cleared the webview cache just in case

$ionicPlatform.ready(function () {

    window.cache.clear();
    ...
}

但它仍然运行与之前完全相同。为什么我的应用程序仍然能够成功地获得 $ cordovaGeolocation.getCurrentPosition 的位置没有插件?难道使用的WebView地理定位服务,而不是插件?我怎么能告诉它使用的服务,因为我怀疑应用程序没有使用该插件开始,而这可能是缓慢的GPS定位的原因。

But it still runs exactly as before. Why is my app still able to successfully obtain a position from $cordovaGeolocation.getCurrentPosition without the plugin? Is it using the webview's geolocation service as opposed to the plugin? How can I tell which service it's using because I suspect the app wasn't using the plugin to begin with and that this is potentially the cause of the slow gps fix.

我做了一些文字和code更改应用程序,以查看是否正在反映的任何变化和新的文字和放大器; code没有露面。我甚至完全卸载从设备上的应用程序离子运行的Andr​​oid 前运行,但地理位置仍然有效。

I made some text and code changes to the app to see if any changes were being reflected and the new text & code did show up. I even completely uninstalled the app from the device before running ionic run android but the geolocation still works.

推荐答案

插件文件说

此API是基于W3C的Geolocation API规范,并仅执行上还没有提供实现设备

This API is based on the W3C Geolocation API Specification, and only executes on devices that don't already provide an implementation.

既然有这么多的我无法测试Android设备我只包括插件是安全的。

Since there are so many Android devices I can not test I just include the plugin to be safe.

对于6秒VS 2秒,这是很难评估的其他应用程序都没有看到他们的code做什么。它们可以使用缓存的位置或如

As for the 6 seconds vs 2 seconds, it's difficult to assess what other apps are doing without seeing their code. They may be using cached locations or such.

这篇关于地理定位插件被移除后,科尔多瓦地理位置仍然有效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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