Hi
I’m building a PWA with Google Maps Javascript API.
When loading I want to know the user location. (If the user answers Yes.)
As it is now user have to do a refresh after answer Yes… How to wait for the user to accept locationsharing?
Also, what to do if the user answers No?
ionViewDidLoad(){
this.loadMap();
//loading some wordpress posts
if(!(this.posts.length > 0)){
let loading = this.loadingCtrl.create();
loading.present();
this.wordpressService.getRecentPosts(this.categoryId)
.subscribe(data => {
for(let post of data){
post.excerpt.rendered = post.excerpt.rendered.split('<a')[0] + "</p>";
this.posts.push(post);
}
this.addMarker();
loading.dismiss();
});
}
}
loadMap(){
this.geolocation.getCurrentPosition().then((position) => {
this.currentPosition=position;
let latLng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
let mapOptions = {
center: latLng,
zoom: 10,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
this.map = new google.maps.Map(this.mapElement.nativeElement, mapOptions);
this.map.addListener('click', (e) => {
this.mapClick();
});
}, (err) => {
console.log( err);
});
}
addMarker(){
// adding markers to the map
}