2amigos / yii2-google-maps-library

Google Maps API library for Yii2
https://2amigos.us
BSD 3-Clause "New" or "Revised" License
106 stars 79 forks source link

google is not defined #101

Open MichalNemec opened 6 years ago

MichalNemec commented 6 years ago

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);

tonydspaniard commented 6 years ago

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.

paskuale75 commented 3 years ago

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 commented 3 years ago

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'
    ];
}