kl83 / yii2-ymaps
Yii2 Yandex Maps 工具包
dev-master
2019-02-07 13:18 UTC
Requires
- yiisoft/yii2: ^2.0.0
- yiisoft/yii2-jui: ^2.0
This package is auto-updated.
Last update: 2024-09-08 07:39:05 UTC
README
小部件列表
- CoordsInput:在地图上选择坐标;
- StreetInput:具有指定城市街道名称的 jui 自动完成;
- MapWidget:显示 Yandex 地图和标记。
安装
安装此扩展的首选方式是通过 composer。
运行以下命令之一:
php composer.phar require kl83/yii2-ymaps @dev
或将以下内容添加到您的 composer.json 文件的 require 部分:
"kl83/yii2-ymaps": "@dev"
使用方法
CoordsInput
<?= $form->field($model, 'coords')->widget('kl83\ymaps\CoordsInput', [ 'options' => [], // Html-attributes of container 'ymapsClientOptions' => [], // Yandex map JS settings 'placemarkClientProperties' => [], // Placemark JS properties 'placemarkClientOptions' => [], // Placemark JS options ]) ?>
StreetInput
<?= $form->field($model, 'street')->widget('kl83\ymaps\StreetInput', [ 'options' => [], // Html-attributes 'city' => '', // Search streets in specified city ]) ?>
MapWidget
<?= MapWidget::widget([ 'mapState' => [ 'center' => [55.76, 37.64], 'zoom' => 16, ], 'placemarks' => [ [ [55.76, 37.64], [], // properties [], // options ], [ [55.76, 37.64], ], ], ]) ?>
交互性
CoordsInput
在地图上找到指定的地址,并将标记移动到该地址。
$('.widget').coordsInput('search', 'Some address');
StreetInput
获取或设置要搜索的城市。
$('.widget').streetInput('city'); // Get $('.widget').streetInput('city', 'Some city'); // Set
许可证
MIT 许可证