google map error - Uncaught ReferenceError: google is not defined - yeoman

后端 未结 2 1713
隐瞒了意图╮
隐瞒了意图╮ 2020-12-18 05:28

on the yeoman-ionic framework i\'ve tried to add google map to my app.the problem was that every time i ran grunt serve the index.html scripts got deleted. so i\'ve ran this

2条回答
  •  眼角桃花
    2020-12-18 06:10

    You must use Google Maps SDK Async Loader. It guarantees that angular-google-maps does not begin processing any directives until all of the Google Maps SDK is fully ready.

    Configure:

        .config(function(uiGmapGoogleMapApiProvider) {
        uiGmapGoogleMapApiProvider.configure({
            //    key: 'your api key',
            v: '3.20', //defaults to latest 3.X anyhow
            libraries: 'weather,geometry,visualization'
        });
    });
    

    When is Google Maps SDK ready?:

        .controller("someController", function($scope, uiGmapGoogleMapApi) {
        uiGmapGoogleMapApi.then(function(maps) {
         // write your code here
         // (google is defined)
        });
    });
    

    Also you can read this http://angular-ui.github.io/angular-google-maps/#!/api/GoogleMapApi

提交回复
热议问题