I need help to assign position to a map… i’m new on ionic…
This is my code:
loadMap() {
Environment.setEnv({
// api key for server
'API_KEY_FOR_BROWSER_RELEASE': 'my key',
// api key for local development
'API_KEY_FOR_BROWSER_DEBUG': 'my key'
});
this.geolocation.getCurrentPosition().then((resp) => {
this.geoInfo.resp=JSON.stringify(resp);
console.log('Latitude: ',resp.coords.latitude); // i see right value
console.log('Longitude: ',resp.coords.longitude); // i see right value
this.lat = (resp.coords.latitude);
this.lng =(resp.coords.longitude);
console.log('Lat1: ',this.lat); // i see right value
console.log('Lng1: ',this.lng); // i see right value
}).catch((error) => {
console.log('Error getting location', error);
this.geoInfo.resp='Error getting location';
});
console.log('Lat2: ',this.lat); // i see undefined value
console.log('Lng2: ',this.lng); // i see undefined value
this.map = GoogleMaps.create('map_canvas', {
camera: {
target: {
lat: this.lat, // wrong value..
lng: this.lng
},
zoom: 18,
tilt: 30
}
});
}
how can i assign right values for target ?
thanks for help
MM