2amigos / yii2-google-maps-library

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

Setting unknown property: dosamigos\google\maps\MapAsset::options #27

Open bohdan-vorona opened 9 years ago

bohdan-vorona commented 9 years ago

An error after installation:

Unknown Property – yii\base\UnknownPropertyException Setting unknown property: dosamigos\google\maps\MapAsset::options

Necessary params to the array bundles (web.php) and to the file params.php was added.

error

gg2 ggg1

composer.json:

"minimum-stability": "stable",
"require": {
    "php": ">=5.4.0",
    "yiisoft/yii2": ">=2.0.4",
    "yiisoft/yii2-bootstrap": "*",
    "yiisoft/yii2-swiftmailer": "*",
    "guzzlehttp/promises": "^1.0",
    "psr/http-message": "^1.0",
    "guzzlehttp/psr7": "^1.0",
    "guzzlehttp/guzzle": "4.*",
    "2amigos/yii2-google-maps-library": "^0.1.2"
},
"require-dev": {
    "yiisoft/yii2-codeception": "*",
    "yiisoft/yii2-debug": "*",
    "yiisoft/yii2-gii": "*",
    "yiisoft/yii2-faker": "*"
}

Code:

    $coord = new LatLng(['lat' => 39.720089311812094, 'lng' => 2.91165944519042]);
    $map = new Map([
        'center' => $coord,
        'zoom' => 14,
        'width'=>300,
        'height'=>300,
    ]);
    var_dump($map->display());
janar commented 9 years ago

I removed "assetManager" part from the config and things started moving (rendering map).

bohdan-vorona commented 9 years ago

@janar assetManager is required for this library, isn't it?

bohdan-vorona commented 9 years ago

@janar can you show me your variant of config for this lib?

janar commented 9 years ago

Readme says to add that assets config, but I don't know is it needed. Somehow my app seems to work without it. Only added params values. Google maps JS file is added in footer without that.

Didn't do anything else than installing this library via composer and filled in originally assets config like in your code. That lead me to this error. After that I added params.php config like yours and removed assetsManager from main config- and i started to work. Hopefully I didn't forgot something to mention.

params.php :

<?php return [

'adminEmail' => 'admin@example.com',    
'googleMapsApiKey' => '*******',
'googleMapsLibraries' => '3.1.18',
'googleMapsLanguage' => 'en'

];

My main.php looks like this...

http://wstaw.org/m/2015/06/21/plasma-desktopvC3343.png

Composer part:

"require": {
    "2amigos/yii2-google-maps-library" : "*"

btw- using: http://www.yiiframework.com/doc-2.0/guide-tutorial-advanced-app.html

bohdan-vorona commented 9 years ago

@janar Thanks a lot, I'll try this approach.

bohdan-vorona commented 9 years ago

@janar Thank you again, it works in my case too.

shivanipatel commented 9 years ago

Where to write google map js?

janar commented 9 years ago

No JS needed to get demo working @ https://github.com/2amigos/yii2-google-maps-library#usage

shivanipatel commented 9 years ago

I am very new to PHP yii Framework. I have installed this extension via composer. And done all the steps which are written. But Not able to view anything. Can you help me?

bohdan-vorona commented 9 years ago

@shivanipatel did you register your API key here https://console.developers.google.com/?

shivanipatel commented 9 years ago

Yes

bohdan-vorona commented 9 years ago

@shivanipatel

    $coord = new LatLng(['lat' => 39.720089311812094, 'lng' => 2.91165944519042]);
    $map = new Map([
        'center' => $coord,
        'zoom' => 14,
        'width'=>300,
        'height'=>300,
    ]);
    var_dump($map->display());

What var_dump says in your case?

shivanipatel commented 9 years ago

string(33) " "

shivanipatel commented 9 years ago

@bohdan-vorona any solution you have?

bohdan-vorona commented 9 years ago

@shivanipatel unfortunately, no. Size is 33, but empty...

shivanipatel commented 9 years ago

@bohdan-vorona Can you review my piece of code please?

bohdan-vorona commented 9 years ago

@shivanipatel You should have this piece of code in your layout:

...
<?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage() ?>

Do you have? Yii inserts JS code for displaying the map in this place.

shivanipatel commented 9 years ago

@bohdan-vorona Yes...:) A big thanks to you... Thanks a lot.

bohdan-vorona commented 9 years ago

@shivanipatel ;-)