科尔多瓦高级地理位置插件离子的问题

时间:2020-03-25 20:14:58

标签: cordova ionic-framework geolocation cordova-plugins

嗨,伙计们需要您的帮助,当我调用某些代码以获取来自cordova-advanced-geolocation-plugin的位置信息时,我在离子应用程序中遇到的怪异行为

这是我正在执行的代码

添加所需的插件

cordova plugin add https://github.com/esri/cordova-plugin-advanced-geolocation.git

包含对库的访问权限的变量

declare var AdvancedGeolocation: any;

插件的当前实现

private geoLocation() {
        AdvancedGeolocation.start(function(success) {
                console.log(success);
                try {
                    const jsonObject = JSON.parse(success);

                    if (jsonObject.provider && jsonObject.provider === 'gps' && jsonObject.latitude && jsonObject.longitude) {
                        this.latitud = jsonObject.latitude.toString();
                        this.longitud = jsonObject.longitude.toString();
                    }
                } catch (exc) {
                    console.log('Invalid JSON: ' + exc);
                }
            },
            function(error) {
                console.log('ERROR! ' + JSON.stringify(error));
            },
            {
                'minTime': 5000,         // Min time interval between updates (ms)
                'minDistance': 3,       // Min distance between updates (meters)
                'noWarn': true,         // Native location provider warnings
                'providers': 'gps',     // Return GPS, NETWORK and CELL locations
                'useCache': false,       // Return GPS and NETWORK cached locations
                'satelliteData': false, // Return of GPS satellite info
                'buffer': false,        // Buffer location data
                'bufferSize': 0,        // Max elements in buffer
                'signalStrength': false // Return cell signal strength data
            });
    } 

我尝试在ngOnInit()和ionViewWillEnter()中调用它,但没有更改。

问题是在执行start方法之后出现的,它停止了组件其余代码的执行,控制台没有显示任何错误,说实话我不知道在那里可能会发生什么,就像那段代码阻止它下面的每个执行。

谢谢。

0 个答案:

没有答案