stalkerrr / yii2-yandex-map
Yii2 的 Yandex 地图小部件
0.11
2017-10-25 12:18 UTC
Requires
- yiisoft/yii2: @dev
Requires (Dev)
- phpunit/phpunit: 4.*
This package is auto-updated.
Last update: 2024-09-29 03:58:07 UTC
README
现在支持标记和聚类。
安装
运行以下命令之一:
$ php composer.phar require stalkerrr/yii2-yandex-map "*"
或者将以下内容添加到您的 composer.json
文件的 require
部分:
"stalkerrr/yii2-yandex-map": "*"
to the `require` section of your `composer.json` file.
用法
如何调用?
// 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]]
]
]
);
动态创建聚类或集合
$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();
使用技术
- YandexMapApi - Yandex Maps 显示的 Api
作者
- David Khachatryan - 初始工作 - stalkerrr
许可证
本项目受 MIT 许可证许可 - 有关详细信息,请参阅 LICENSE.md 文件