@7wins wrote:
Loading never stop, whereas gmpas native is ready.
here my code .
lokasi.ts
timport { Component } from '@angular/core'; import { IonicPage, NavController, NavParams, Platform,LoadingController } from 'ionic-angular'; import { GoogleMaps, GoogleMap,GoogleMapsEvent,Marker,MarkerOptions,GoogleMapOptions } from'@ionic-native/google-maps'; import { Geolocation } from'@ionic-native/geolocation'; /** * Generated class for the LokasiPage page. * * See https://ionicframework.com/docs/components/#navigation for more info on * Ionic pages and navigation. */ @IonicPage() @Component({ selector: 'page-lokasi', templateUrl: 'lokasi.html', }) export class LokasiPage { map:GoogleMap; loading:any; lat=0; long=0; constructor(public navCtrl: NavController, public navParams: NavParams, public platfrom:Platform, public geolocation: Geolocation,public loader:LoadingController) { this.showLoading(); } ionViewDidLoad() { this.platfrom.ready().then(()=>{ this.loadMap(); this.dismissLoading(); }) console.log('ionViewDidLoad LokasiPage'); } showLoading(){ this.loading= this.loader.create({ content:'Menunggu map' }); this.loading.present(); } dismissLoading(){ if(this.loading){ this.loading.dismiss(); this.loading= null; } } loadMap(){ this.geolocation.getCurrentPosition({enableHighAccuracy:true,timeout: 20000, maximumAge: 10000}).then((resp)=>{ this.lat=resp.coords.latitude this.long=resp.coords.longitude let mapOptions: GoogleMapOptions = { controls:{ 'compass':true, 'myLocationButton':true, 'myLocation':true, }, camera: { target: { lat: this.lat, lng: this.long }, zoom: 18, tilt: 30 } }; this.map=GoogleMaps.create('map',mapOptions); }).catch((error)=>{ console.log('error',error); }); //wait the maps this.map.one(GoogleMapsEvent.MAP_READY).then(()=>{ console.log('map ready') }) } }please help, thanks a lot.
Posts: 1
Participants: 1