2017 © Pedro Peláez
 

yii2-extension yii2-yandex-maps

Yii 2 yandex map module

image

mirocow/yii2-yandex-maps

Yii 2 yandex map module

  • Thursday, September 28, 2017
  • by Mirocow
  • Repository
  • 7 Watchers
  • 20 Stars
  • 2,853 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 29 Forks
  • 1 Open issues
  • 2 Versions
  • 14 % Grown

The README.md

Yii2 Yandex Maps Components

Latest Stable Version Latest Unstable Version Total Downloads Daily Downloads License, (*1)

Installation

The preferred way to install this extension is through composer., (*2)

Add repositor

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

and then, (*3)

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

or add, (*4)

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

to the require section of your application's composer.json file., (*5)


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

Components

mirocow\yandexmaps\Api

Application components which register scripts., (*7)

Usage, (*8)

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

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

mirocow\yandexmaps\Map

Map instance., (*10)

Usage, (*11)

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

mirocow\yandexmaps\Canvas

This is widget which render html tag for your map., (*12)

Usage, (*13)

Simple add widget to view:, (*14)


echo \mirocow\yandexmaps\Canvas::widget([ 'htmlOptions' => [ 'style' => 'height: 400px;', ], 'map' => $map, ]);

mirocow\yandexmaps\Controls

      'controls' => [
          // v 2.1
          'new ymaps.control.ZoomControl({options: {size: "small"}})',
          //'new ymaps.control.TrafficControl({options: {size: "small"}})',
          //'new ymaps.control.GeolocationControl({options: {size: "small"}})',
          'search' => 'new ymaps.control.SearchControl({options: {size: "small"}})',
          //'new ymaps.control.FullscreenControl({options: {size: "small"}})',
          //'new ymaps.control.RouteEditor({options: {size: "small"}})',
      ],

mirocow\yandexmaps\GeoObject

mirocow\yandexmaps\Placemark

    $placemark = new mirocow\yandexmaps\objects\Placemark([
            55.7372,
            37.6066
    ], [

    ], [
            'draggable' => true
      ]
    );

mirocow\yandexmaps\Polygon

TODO:, (*15)

mirocow\yandexmaps\Clusterer

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

mirocow\yandexmaps\Polyline

TODO:, (*16)

Examples:

User form with yandex map:

 ['class' => 'user-settings'],
            'fieldConfig' => [
                'options' => [
                    'tag' => false,
                ],
            ],
        ]);

        $map = new \mirocow\yandexmaps\Map('yandex_map', [
          'center' => [55.7372, 37.6066],
          'zoom' => 10,
          // Enable zoom with mouse scroll
          'behaviors' => ['default', 'scrollZoom'],
          'type' => "yandex#map",
          'controls' => [],
        ],
          [
              // Permit zoom only fro 9 to 11
              'minZoom' => 1,
              'maxZoom' => 11,
              'controls' => [
                  // v 2.1
                  'new ymaps.control.ZoomControl({options: {size: "small"}})',
                  //'new ymaps.control.TrafficControl({options: {size: "small"}})',
                  //'new ymaps.control.GeolocationControl({options: {size: "small"}})',
                  'search' => 'new ymaps.control.SearchControl({options: {size: "small"}})',
                  //'new ymaps.control.FullscreenControl({options: {size: "small"}})',
                  //'new ymaps.control.RouteEditor({options: {size: "small"}})',
              ],
              'behaviors' => [
                'scrollZoom' => 'disable',
              ],
              'objects' => [
                ');
        $('#coordinates').append('');
    });
    
});
JS

                                      ],
                                  ]
                );?>

                <?= \mirocow\yandexmaps\Canvas::widget([
                  'htmlOptions' => [
                    'style' => 'height: 400px;',
                  ],
                  'map' => $map,
                ]);

                ?>

                <div id="coordinates"></div>


The Versions

28/09 2017

dev-master

9999999-dev

Yii 2 yandex map module

  Sources   Download

MIT

The Requires

 

yii2 yii map yandex

21/05 2015

dev-yii2-beta

dev-yii2-beta

Yii 2 yandex map module

  Sources   Download

MIT

The Requires

 

yii2 yii map yandex