Google Maps: ReferenceError: google is not defined.
See original GitHub issueHow i can solve my problem with google maps, i’ve inserted the google api link in index.html
and after run the app i’ve got an error.
My code snippets:
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
declare var google: any;
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
constructor(public navCtrl: NavController) {
}
ionViewDidLoad() {
let mapEle = document.getElementById('map');
let map = new google.maps.Map(mapEle, {
center: '-34.9290, 138.6010',
zoom: 16
});
let infoWindow = new google.maps.InfoWindow({
content: `<h5>IONIC</h5>`
});
let marker = new google.maps.Marker({
position: '-34.9290, 138.6010',
map: map,
title: 'title'
});
marker.addListener('click', () => {
infoWindow.open(map, marker);
});
google.maps.event.addListenerOnce(map, 'idle', () => {
mapEle.classList.add('show-map');
});
}
}
NB: Knowing that I followed a method in this example (conference app).
My system information:
Cordova CLI: 5.4.1
Gulp version: CLI version 3.9.0
Gulp local:
Ionic Framework Version: 2.0.0-rc.1
Ionic CLI Version: 2.1.1
Ionic App Lib Version: 2.1.1
Ionic App Scripts Version: 0.0.36
ios-deploy version: 1.8.6
ios-sim version: 5.0.6
OS: Mac OS X El Capitan
Node Version: v5.12.0
Xcode version: Xcode 8.0 Build version 8A218a
Issue Analytics
- State:
- Created 7 years ago
- Comments:7
Top Results From Across the Web
Google Maps API throws "Uncaught ReferenceError
google is not defined, google related stuff has not been loaded yet and we are using it that causes this error. In the...
Read more >Uncaught ReferenceError: google is not defined - MSDN
Usually this type of error is due to forgetting to reference a JavaScript library or trying to access a library object before the...
Read more >Google Maps API v3 - Uncaught ReferenceError - OutSystems
I'm trying to create a Google Map in a webscreen but I keep getting this error in Chrome's Javascript Console : "Uncaught ReferenceError:...
Read more >google is not defined - ionic v3.9.2, angular v5.2.11
Hello guys, i know this error is pretty common but i still have no idea which part did i do wrong. i already...
Read more >Google Maps API throws Uncaught ReferenceError ... - Edureka
When I try to load the page using AJAX, I get the error: Uncaught ReferenceError: google is not defined. This is the page...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Problem Solved.
Note: @inceptiveDipak
('-34.9290, 138.6010')
with (new google.maps.LatLng(43.071584, -89.380120)
)('-34.9290, 138.6010')
with (new google.maps.LatLng(43.071584, -89.380120)
)ionViewDidLoad
and call directly inAnd should it work perfectly 😄 .
Also make sure you have :
<script src="cordova.js"></script>`<script
src=“http://maps.google.com/maps/api/js?key=YOUR_API_KEY_HERE”></script>in your src/index.html file - above cordova.js
YOUR_API_KEY_HERE can be had from here