Ionic Geolocation 需要花费太多时间才能获得位置

Zer*_*rok 5 android cordova ionic-framework

我正在测试一个 Ionic 3.4 应用程序,它曾经在浏览器中完美运行。安装一些 Cordova 插件(有些可能仍然丢失)后,我安装了最新的 Android SDK 和 4.0(这是我想要的 SDK 级别)。

制作了一个 JS 谷歌地图页面,它从我的数据库加载一些组件,在浏览器中工作得非常好。但是......在手机(小米5s,Android 6.0.1)中,它需要GPS才能工作,加载当前位置需要大约2-3分钟。毫不夸张地说:2-3分钟。

问题似乎出在这一行:

this.geolocation.getCurrentPosition().then((position) => {
Run Code Online (Sandbox Code Playgroud)

在那之后,它会穿过这条线并指向我的确切位置。这很好用,但不应该花那么多时间。

这是我的 package.json:

{
    "name": "MyApp",
    "version": "0.0.1",
    "author": "Ionic Framework",
    "homepage": "http://ionicframework.com/",
    "private": true,
    "scripts": {
        "clean": "ionic-app-scripts clean",
        "build": "ionic-app-scripts build",
        "ionic:build": "ionic-app-scripts build",
        "ionic:serve": "ionic-app-scripts serve"
    },
    "dependencies": {
        "@angular/common": "4.0.0",
        "@angular/compiler": "4.0.0",
        "@angular/compiler-cli": "4.0.0",
        "@angular/core": "4.0.0",
        "@angular/forms": "4.0.0",
        "@angular/http": "4.0.0",
        "@angular/platform-browser": "4.0.0",
        "@angular/platform-browser-dynamic": "4.0.0",
        "@ionic-native/core": "^3.6.0",
        "@ionic-native/geolocation": "^3.8.0",
        "@ionic-native/splash-screen": "^3.5.0",
        "@ionic-native/status-bar": "3.4.2",
        "@ionic/storage": "2.0.1",
        "cordova-android": "^6.2.3",
        "cordova-plugin-compat": "^1.0.0",
        "cordova-plugin-console": "^1.0.5",
        "cordova-plugin-device": "^1.1.4",
        "cordova-plugin-geolocation": "^2.4.3",
        "cordova-plugin-googlemaps": "~1.4.0",
        "cordova-plugin-splashscreen": "^4.0.3",
        "cordova-plugin-statusbar": "^2.2.1",
        "cordova-plugin-whitelist": "^1.3.1",
        "image-manipulation": "0.0.4",
        "ionic-angular": "3.0.1",
        "ionic-plugin-keyboard": "^2.2.1",
        "ionicons": "3.0.0",
        "parse": "^1.9.2",
        "rxjs": "5.1.1",
        "sw-toolbox": "3.4.0",
        "zone.js": "^0.8.4"
    },
    "devDependencies": {
        "@ionic/app-scripts": "^1.3.1",
        "@ionic/cli-plugin-cordova": "1.4.0",
        "@ionic/cli-plugin-ionic-angular": "1.3.1",
        "typescript": "~2.2.1"
    },
    "description": "An Ionic project",
    "cordova": {
        "plugins": {
            "cordova-plugin-whitelist": {},
            "cordova-plugin-geolocation": {},
            "cordova-plugin-console": {},
            "cordova-plugin-device": {},
            "cordova-plugin-googlemaps": {
                "API_KEY_FOR_ANDROID": "AIzaSyDFX_9vIksX3JMDVjDIRa5bxoioWCW_q4g",
                "API_KEY_FOR_IOS": "AIzaSyDFX_9vIksX3JMDVjDIRa5bxoioWCW_q4g"
            },
            "cordova-plugin-splashscreen": {},
            "cordova-plugin-statusbar": {},
            "ionic-plugin-keyboard": {}
        },
        "platforms": [
            "android"
        ]
    }
}
Run Code Online (Sandbox Code Playgroud)

这是怎么回事?

谢谢你!

编辑:好的,该片段在三星 S5 中运行良好,但在我的小米 mi5 中不起作用......知道吗?