How to ensure one method is executed before executing another?

I am reading in my current location using Geolocation correctly, & now want to render a Leaflet map which centers around those co-ordinates.

The problem that I’m facing is that both getLoc() & initMap() are being called in ngAfterViewInit().
Even though I’m calling getLoc() first, it looks as my longitude & latitude variables aren’t being populated before the map is initiated.

Can someone please tell me how I can ensure my current location is read in before the map is initiated, so I can use those co-ordinates to center the map?

Here is ngAfterViewInit():

ngAfterViewInit(): void {

Here is getLoc():

getLoc() {
        maximumAge: 1000, timeout: 5000,
        enableHighAccuracy: true
    ).then((resp) => { = resp.coords.latitude
      this.lng = resp.coords.longitude
    }, er => {
      alert('Can not retrieve Location')
    }).catch((error) => {
      alert('Error getting location - ' + JSON.stringify(error))

And here is initMap():

private initMap(): void {
    console.log( + " : " + this.lng); ='map', {
      center: [, this.lng],
      zoom: 3
    const tiles = L.tileLayer('https://{s}{z}/{x}/{y}.png', {
      maxZoom: 19,
      attribution: '&copy; <a href="">OpenStreetMap</a>'

Please read this post for background.

You have written getLoc as if it were a type B method, but the crucial condition that is italicized is not true. getLoc is really a type C, and if you rewrite it accordingly, your problem will melt away.