yii2-yandex-maps Yii2 Yandex Maps Components

Yii2 Yandex Maps Components

  1. Installation
  2. Components

Latest Stable Version Latest Unstable Version Total Downloads Daily Downloads License

Installation

The preferred way to install this extension is through composer.

Add repositor
    "repositories": [
        {
            "type": "git",
            "url": "https://github.com/mirocow/yii2-yandex-maps.git"
        }
    ]

and then

php composer.phar require --prefer-dist "mirocow/yii2-yandex-maps" "*"

or add

"mirocow/yii2-yandex-maps" : "*"

to the require section of your application's composer.json file.

For last Yii2 2.X version please use patch https://github.com/iamruslan/yii2-yandex-maps/commit/fee95f91b4b313424c5041101f57a6b49d0a7276

Components

mirocow\yandexmaps\Api

Application components which register scripts.

Usage

Attach component to application (e.g. edit config/main.php): `php 'components' => [

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

], `

mirocow\yandexmaps\Map

Map instance.

Usage

    $map = new YandexMap('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'])",  
            ],                    
        ]                
    );             
mirocow\yandexmaps\Canvas

This is widget which render html tag for your map.

Usage

Simple add widget to view: `php

use mirocow\yandexmaps\Canvas as YandexCanvas;

echo YandexCanvas::widget([

    'htmlOptions' => [
        'style' => 'height: 400px;',
    ],
    'map' => $map,
]);

### mirocow\yandexmaps\Clusterer ###

```js
    for (var i in map_point) {
    points[i] = new ymaps.GeoObject({
     geometry : {
      type: 'Point',
      coordinates : [map_point[i]['lat'],map_point[i]['lng']]
     },
     properties : {
      balloonContentBody : map_point[i]['body']
      // hintContent : 'подробнее'
     }
    },
    {
     iconImageHref: '/i/' + map_point[i]['spec']+'.png',
     iconImageSize: [29,29],
     balloonIconImageHref: '/i/' + map_point[i]['spec']+'.png',
     balloonIconImageSize: [29,29],
     hasBalloon: true
    });
   }

   var clusterer = new ymaps.Clusterer();
   clusterer.add(points);
   map.geoObjects.add(clusterer);
1 0
2 followers
0 downloads
Yii Version: 2.0
License: BSD-2-Clause
Category: User Interface
Tags: map, maps, yandex
Developed by: Mirocow
Created on: Oct 20, 2015
Last updated: 9 years ago

Related Extensions