Geolocation service once called during runtime, it takes very long to respond normally, however whenever I go to some other tab or minimize and reopen the window, the geolocation responds way faster

import { Geolocation } from ‘@ionic-native/geolocation/ngx’;
imported this library and then called this following function:

async loadMapJS(i: number) {
this.geolocation.getCurrentPosition().then((resp) => {
const latLng = new google.maps.LatLng(resp.coords.latitude, resp.coords.longitude);
const mapOptions = {
center: latLng,
zoom: 15,
mapTypeId: google.maps.MapTypeId.ROADMAP

 // this.getAddressFromCoordsJS(resp.coords.latitude, resp.coords.longitude); = new google.maps.Map(this.mapElement.nativeElement, mapOptions);
  let marker =  new google.maps.Marker();
  // This line gets the coordinates of the clicked location
  google.maps.event.addListener(, 'click', this.func = (event) => {
    marker = new google.maps.Marker({
      position: {lat: , lng: event.latLng.lng()},
      title: 'Your teaching location set here',
      snippet: 'Click on map to change location',
    this.classesArray[i].locationLatitude =;
    this.classesArray[i].locationLongitude = event.latLng.lng();
}).catch((error) => {
  console.log('Error getting location', error);


If I call this function in constructor, it works immediately. But if I call this from button during runtime, geolocation takes too long, maybe few minutes to fireup. But if I go to some other tab and come back or minimize and reopen, it hits almost immediately. Can you suggest something for this?