Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70440

Ionic4 - Problem with google maps

$
0
0

@JordanoBaluz wrote:

I’m new in Ionic and I have started a project using ionic with google maps, but a have some problems. My new code is with some bug i can’t fix or understanding.
This is my code:

ngOnInit(){
    this.geolocation.getCurrentPosition().then((resp)=>{
      this.position = new google.maps.LatLng(resp.coords.latitude, resp.coords.longitude);
    });
  }

  ngAfterContentInit() {
    this.map = new google.maps.Map(
      this.mapElement.nativeElement,
      {
        center: this.position,
        zoom: 13
      });
  }

  ionViewDidLoad() { 
    google.maps.event.trigger(this.map,'resize');
  }

The problem appear when i center the map, if i’m use the code above, then the map appear grey. But if i’m put the coordenates like, center: {lat: 0.000, lng: 0.000} . The map will appear with no problem, but i need to get the coordenates in real time. Someone can help me please?

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70440

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>