@Pratikjaiswa15 wrote:
I am using ionic 5. Geolocation and geocoder plugins were working till yesterday but suddenly they have stopped working. I have tried clearing storage on mobile but the problem still persists.
I can’t get whats’s gone wrong. Thank you in advanceupdate I tried on other device and working fine on that device. But on my initial device, it is not working. What would be the problem? Mobile is realme 3 pro
Here is the code
getGeolocation(){ this.platform.ready().then(() =>{ this.geolocation.getCurrentPosition().then((resp) => { this.geoLatitude = resp.coords.latitude; this.geoLongitude = resp.coords.longitude; this.geoAccuracy = resp.coords.accuracy; this.getGeoencoder(this.geoLatitude,this.geoLongitude); }).catch((error) => { alert('Error getting location'+ JSON.stringify(error)); }); }).catch((error) => { alert(error)}) } //geocoder method to fetch address from coordinates passed as arguments getGeoencoder(latitude,longitude){ this.nativeGeocoder.reverseGeocode(latitude, longitude, this.geoencoderOptions) .then((result: NativeGeocoderResult[]) => { this.geoAddress = this.generateAddress(result[0]); }) .catch((error: any) => { alert('Error getting location'+ JSON.stringify(error)); }); } //Return Comma saperated address generateAddress(addressObj){ let obj = []; let address = ""; for (let key in addressObj) { obj.push(addressObj[key]); } obj.reverse(); for (let val in obj) { if(obj[val].length) address += obj[val]+', '; } return address.slice(0, -2); }
package.json
"@ionic-native/geolocation": "^5.21.6", "@ionic-native/native-geocoder": "^5.21.6",
Posts: 1
Participants: 1