承接 mirocow/yii2-yandex-maps 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mirocow/yii2-yandex-maps

Composer 安装命令:

composer require mirocow/yii2-yandex-maps

包简介

Yii 2 yandex map module

README 文档

README

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

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

mirocow\yandexmaps\Map

Map instance.

Usage

    $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.

Usage

Simple add widget to view:

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:

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:

Examples:

User form with yandex map:

<?php
$form = ActiveForm::begin([
            'options' => ['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' => [
                <<<JS
search.events.add("resultselect", function (result){

    // Remove old coordinates
    \$Maps['yandex_map'].geoObjects.each(function(obj){
        \$Maps['yandex_map'].geoObjects.remove(obj);
    });  

    // Add selected coordinates
    var index = result.get('index');
    var searchControl = \$Maps['yandex_map'].controls.get(1);
    searchControl.getResult(index).then(function(res) {
        var coordinates = res.geometry.getCoordinates();
        $('#coordinates').html('');
        $('#coordinates').append('<input type="hidden" name="User[coordinates][]" value="'+coordinates[0]+'">');
        $('#coordinates').append('<input type="hidden" name="User[coordinates][]" value="'+coordinates[1]+'">');
    });
    
});
JS

                                      ],
                                  ]
                );?>

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

                ?>

                <div id="coordinates"></div>
                
<?php ActiveForm::end(); ?>

统计信息

  • 总下载量: 23.32k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 23
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 23
  • Watchers: 6
  • Forks: 29
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-07-12