Skip to content

maximpn/yii2-yandex-maps

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Yii2 Yandex Maps Components


This repo is the fork of the yii2-yandex-maps by Mirocow


Components

katzz0\yandexmaps\Api

Application components which register scripts.

Usage

Attach component to application (e.g. edit config/main.php):

'components' => [
	'yandexMapsApi' => [
		'class' => 'mirocow\yandexmaps\Api',
	]
 ],

katzz0\yandexmaps\Map

Map instance.

Usage

use katzz0\yandexmaps\Map;

$map = new Map('yandex_map', [
        'center' => [55.7372, 37.6066],
        'zoom' => 10,
        // Enable zoom with mouse scroll
        'behaviors' => array('default', 'scrollZoom'),
        'type' => "yandex#map",
    ],
    [
        // Permit zoom only fro 9 to 11
        'minZoom' => 9,
        'maxZoom' => 11,
        'controls' => [
          "new ymaps.control.SmallZoomControl()",
          "new ymaps.control.TypeSelector(['yandex#map', 'yandex#satellite'])",
        ],
    ]
);

katzz0\yandexmaps\Canvas

This is widget which render html tag for your map.

Usage

Simple add widget to view:

use katzz0\yandexmaps\Canvas as YandexMaps;

<?= YandexMaps::widget([
    'htmlOptions' => [
        'style' => 'height: 600px;',
    ],
    'map' => new Map('yandex_map', [
        'center' => [55.7372, 37.6066],
        'zoom' => 17,
        'controls' => [Map::CONTROL_ZOOM],
        'behaviors' => [Map::BEHAVIOR_DRAG],
        'type' => "yandex#map",
    ],
    [
        'objects' => [new Placemark(new Point(55.7372, 37.6066), [], [
            'draggable' => true,
            'preset' => 'islands#dotIcon',
            'iconColor' => '#2E9BB9',
            'events' => [
                'dragend' => 'js:function (e) {
                    console.log(e.get(\'target\').geometry.getCoordinates());
                }'
            ]
        ])]
    ])
]) ?>

You can use also direct place label:

<?= YandexMaps::widget([
    'htmlOptions' => [
        'style' => 'height: 600px;',
    ],
    'map' => new Map(null, [
        'center' => 'London',
        'zoom' => 17,
        'controls' => [Map::CONTROL_ZOOM],
        'behaviors' => [Map::BEHAVIOR_DRAG],
        'type' => "yandex#map",
    ],
    [
        'objects' => [new Placemark(null, [], [
            'draggable' => true,
            'preset' => 'islands#dotIcon',
            'iconColor' => '#2E9BB9',
            'events' => [
                'dragend' => 'js:function (e) {
                    console.log(e.get(\'target\').geometry.getCoordinates());
                    }'
            ]
        ])]
    ])
]) ?>

About

yii2-yandex-maps

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%