rootlocal/yii2-yandexmaps

Yii2 Yandex Maps API

安装: 10

依赖: 0

建议者: 0

安全性: 0

星标: 0

关注者: 3

分支: 0

开放问题: 2

类型:yii2-extension

v1.0.2 2020-07-22 16:03 UTC

README

Latest Stable Version

安装

composer require rootlocal/yii2-yandexmaps

或添加

"rootlocal/yii2-yandexmaps": "~1.0",

到您的 composer.json 的 require 部分中。

示例用法配置 1

配置

<?php

return [
    
    // ...
    
    'components' => [
        
        // ...
    
        'assetManager' => [
            
            'bundles' => [
                \rootlocal\widgets\yandexmaps\ApiYandexMapAsset::class => [
                    'version' => '2.1',
                    'language' => 'ru-RU',
                    'apiKey' => 'MY_API_KEY'
                ],
            ],
            
            // ...
        ],
        
        // ...
    ]
];

视图

<?php

use yii\web\View;
use rootlocal\widgets\yandexmaps\YandexMapWidget;

/** @var View $this */
?>

<?= YandexMapWidget::widget([
        'content' => $this->render('yamapscontent'),
        'htmlOptions' => ['class' => 'yamap'],
        'options' => [
            'center' => [xx.xx, yy.yy],
            'zoom' => 16,
            'controls' => ['zoomControl'],
            'placemarks' => [
                [
                    'position' => [xx.xx, yy.yy],
                    'content' => [
                        'hintContent' => 'test',
                        'balloonContentHeader' => 'test',
                        'balloonContentBody' => 'test',
                        'balloonContentFooter' => 'test',
                    ],
                ],
            ],
        ]
    ]) ?>

示例用法配置 2

<?php

use yii\web\View;
use rootlocal\widgets\yandexmaps\YandexMapWidget;

/** @var View $this */
?>

<?= YandexMapWidget::widget([
        'apiKey' => 'MY_API_KEY',
        'language' => 'ru-RU',
        'content' => $this->render('yamapscontent'),
        'htmlOptions' => ['class' => 'yamap'],
        'options' => [
            'center' => [xx.xx, yy.yy],
            'zoom' => 16,
            'controls' => ['zoomControl'],
            'placemarks' => [
                [
                    'position' => [xx.xx, yy.yy],
                    'content' => [
                        'hintContent' => 'test',
                        'balloonContentHeader' => 'test',
                        'balloonContentBody' => 'test',
                        'balloonContentFooter' => 'test',
                    ],
                ],
            ],
        ]
    ]) ?>