yii2-google-maps-library icon indicating copy to clipboard operation
yii2-google-maps-library copied to clipboard

google is not defined

Open MichalNemec opened this issue 6 years ago • 3 comments

Hello, via composer installed this package.

When i copy paste "service" below in readme i get Uncaught ReferenceError: google is not defined.

Even when i have in view on top this: use dosamigos\google\maps\MapAsset; MapAsset::register($this);

MichalNemec avatar Feb 27 '18 13:02 MichalNemec

google is not defined on the javascript console? If that is the case, make is an issue with the registration of the assets not the extension library itself.

How do you render the file? Where is actually located the registration of the assets? At the top of what? The Layout? The partial view? The more info0rmation your provide the better. Thanks.

tonydspaniard avatar Mar 02 '18 12:03 tonydspaniard

In the case of renderAjax, only the first call the console says that google is not defined, from the second call on instead it works...

paskuale75 avatar Sep 04 '21 06:09 paskuale75

I think solved it, adding your asset to the main asset as a dependency.

class AppAsset extends AssetBundle
{
    public $basePath = '@webroot';
    public $baseUrl = '@web';
    public $css = [
        'css/site.css',
        'css/custom.css',
        'https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css',
        'https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback'

    ];
    public $js = [
        'js/jquery.mask.js',
    ];
    public $depends = [
        'dosamigos\google\maps\MapAsset'
    ];
}

paskuale75 avatar Sep 04 '21 07:09 paskuale75