stalkerrr/yii2-yandex-map

Yandex map widget for Yii2

0.11 2017-10-25 12:18 UTC

This package is auto-updated.

Last update: 2025-05-29 00:59:53 UTC


README

Supports Markers and Clusters now.

Install

Either run

$ php composer.phar require stalkerrr/yii2-yandex-map "*"

or add

"stalkerrr/yii2-yandex-map": "*"

to the `require` section of your composer.json file.

Usage

How to call?

	// add this in your view
	
	use stalkerrr\yandex_map\YandexMapWidget;
	use stalkerrr\yandex_map\YandexPreset;
	use stalkerrr\yandex_map\YandexMapCluster;
	
	
	//create preset object with params of geoMarker (like color, type and other)
	$testPreset = new YandexPreset();
	$testPreset->type = YandexPreset::TYPE_DOT;
    $testPreset->color = YandexPreset::COLOR_DARK_ORANGE;
    //$testPreset->icon = YandexPreset::ICON_MONEY;
    $testPreset->circle = true;
	
	//simple way calling
	$mapWidget = YandexMapWidget::widget(
		[
			'points' => [
        		['coord' => [53.21, 32.34], 'content' => [], 'opts' => ['preset' => $testPreset]],
        		['coord' => [54.21, 30.34]]
			]
        ]
    );

Creating clusters or collections dynamically

	$testPreset = new YandexPreset();
	$testPreset->type = YandexPreset::TYPE_DOT;
	$testPreset->color = YandexPreset::COLOR_DARK_ORANGE;
	$testPreset->circle = true;

    $widget = YandexMapWidget::begin(
        ['points' => [
            ['coord' => [53.21, 32.34], 'content' => [], 'opts' => ['preset' => $testPreset]],
            ['coord' => [54.21, 30.34]]]
        ]
    );
    $cluster = new YandexMapCluster();
    $cluster->preset = $testPreset;

    $testPreset->color=YandexPreset::COLOR_BLACK;
    $widget->addCluster(
        [
            ['coord' => [43.21, 31.34],'content' => [], 'opts' => ['preset' => $testPreset]],
            ['coord' => [45.31, 31.34]]
        ],
        $cluster
     );


	$widget->addCollection([['coord' => [32.25, 21.54]], ['coord' => [40.21, 39.14]]], $testPreset);
    
    YandexMapWidget::end();
	

Built With

Authors

  • David Khachatryan - Initial work - stalkerrr

License

This project is licensed under the MIT License - see the LICENSE.md file for details