Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

Got error in ionic JavaScript API multiple times on this page in ionic3?

I have included the google map in our app and I have shown the map via specific address but in my case code is executed but got the error above code.i will check the code I have include google-map only 1 time tell me how to fix this issue?

loadGoogleMaps(){
  if(typeof google == "undefined" || typeof google.maps){
    // this.initMap();
    this.lang = "25.058349,55";
    this.long = "55.135859";
    this.address = "DMCC, Jumeirah Lakes Tower, Opp Discovery Gardens,Sheik Zayed Road، Exit 29 - Dubai";

       window['mapInit'] = () => {
        this.initMap();

      }
      let script = document.createElement("script");
      script.id = "googleMaps";

      if(this.apiKey){
        script.src = 'http://maps.google.com/maps/api/js?key=' + this.apiKey + '&callback=mapInit';
      }
      document.body.appendChild(script); 
    }
  }

  initMap(){
     // let latLng;
     let map;
      let mapOptions;
      this.geolocation.getCurrentPosition().then((position) => {
        
        mapOptions = {
          zoom: 16,
          mapTypeId: google.maps.MapTypeId.ROADMAP
        }

       if(this.lang){
         mapOptions.center = new google.maps.LatLng(this.lang, this.long);

         map = new google.maps.Map(this.mapElement.nativeElement, mapOptions);      
          var marker = new google.maps.Marker({
            position: new google.maps.LatLng(this.lang, this.long)
          });

          var infowindow = new google.maps.InfoWindow({
            content: this.address
          });
          google.maps.event.addListener(map, 'click', function() {
            infowindow.close();
          });

        marker.addListener('click', function() {
          infowindow.close()
          infowindow.open(map, marker);
        });
        marker.setMap(map); 
       }
    })

Comments