aruis / cordova-plugin-baidumaplocation

Get device current Location from Baidu Map
https://www.npmjs.com/package/cordova-plugin-baidumaplocation
Apache License 2.0
139 stars 69 forks source link

插件定位之后,切换页面,切换两次之后就回调函数一直没有返回值,也没有报错 #86

Open naixin-coder opened 5 years ago

naixin-coder commented 5 years ago

`

ionic 环境如下

@ionic/app-scripts : 3.2.0
Cordova Platforms  : android 6.4.0 ios 4.5.5
Ionic Framework    : ionic-angular 3.9.2

代码如下

方法如下 baiduLocation() {

    return new Promise((resolve) => {
        console.log('进入定位')
        baidumap_location.getCurrentPosition(result => {
            console.log(result);
            this.address = result;
            resolve(result);
            // const { latitude, longitude } = result
            this.common.setStorage('result', result)
            // this.common.setStorage('longitude', longitude)
        }, async (error: any) => {
            const result = await this.common.getStorage('result')
            this.address = result;
            // const longitude = await this.common.getStorage('longitude')
            resolve(result);
            console.log(11111111, error);
            // this.common.showToast('定位失败');
        })
    })
}

`