Ion frame – geographic location is not suitable for ion 3

I am using Ion 3 for location-based work. I can’t get the current location of latitude and longitude here. I mentioned the code I have available. It works well at the browser level, But it does not work properly in mobile devices.

Code

$ionic cordova plugin add cordova-plugin-geolocation --variable GEOLOCATION_USAGE_DESCRIPTION=" To locate you"
$npm install --save @ionic-native/geolocation
import {Geolocation} from'@ionic-native/geolocation';

constructor (private geolocation: Geolocation) {}

this.geolocation.getCurrentPosition().then((resp) => {
console.log( resp.coords.latitude)
console.log( resp.coords.longitude)
}).catch((error) => {
console.log('Error getting location', error);
});< /pre>
try this:

 import {Geolocation} from'@ionic-native/geolocation';
import {Platform} from'ionic-angular';

//Set the properties in this class
long : any; //longitude
lati: any; //latitude

constructor(private p latform: Platform, private geolocation: Geolocation) {
this.platform.ready().then(()=>{

//set options..
var options = {
timeout: 20000 //sorry I use this much milliseconds
}
//use the geolocation
this.geolocation.getCurrentPosition(options).then(data=>{< br /> this.long = data.coords.longitude;
this.lati = data.coords.latitude;
}).catch((err)=>{
console.log( "Error", err);
});
});
}

Let it in the constructor. Don’t forget to agree to the location privacy permission, and at the same time you Enable the location option on your Android device (although this is very possible).

I am using ionic 3 for location-based work. I can’t get the current location of latitude and longitude here . I mentioned the code I have available. It works well at the browser level, but does not work properly in mobile devices.

Code

< pre>$ionic cordova plugin add cordova-plugin-geolocation --variable GEOLOCATION_USAGE_DESCRIPTION="To locate you"
$npm install --save @ionic-native/geolocation

import {Geolocation} from '@ionic-native/geolocation';

constructor(private geolocation: Geolocation) {}

this.geolocation.getCurrentPo sition().then((resp) => {
console.log( resp.coords.latitude)
console.log( resp.coords.longitude)
}).catch(( error) => {
console.log('Error getting location', error);
});

Try this :

import {Geolocation} from'@ionic-native/geolocation';
import {Platform} from'ionic-angular';

//Set the properties in this class
long: any; //longitude
lati: any; //latitude

constructor(private platform: Platform, private geolocation: Geolocation) {
this.platform.ready().then(()=>{

//set options..
var options = {
timeout: 20000 //sorry I use this much milliseconds
}
//use the geolocation
this.geolocation.getCurrentPosition(options).then(data=>{
this .long = data.coords.longitude;
this.lati = data.coords.latitude;
}).catch((err)=>{
console.log("Error", err);
});
});
}

Let it in the constructor. Don’t forget to agree to the location privacy permission, Also enable location options on your Android device (although this is very possible).

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 3861 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.