msvdev / yii2-widget-mappicker
Yii2 地图小部件可以帮助您简化表单中地理坐标的输入。支持谷歌和雅虎地图服务。
1.0.1
2018-04-05 08:24 UTC
Requires
- yiisoft/yii2: >=2.0.4
This package is auto-updated.
Last update: 2024-09-28 17:18:00 UTC
README
此小部件可以帮助您简化表单中地理坐标的输入。支持谷歌和雅虎地图服务。
安装
安装此扩展的首选方式是通过composer。
$ php composer.phar require msvdev/yii2-widget-mappicker "*"
或者
"msvdev/yii2-widget-mappicker": "*"
添加以下内容到您的 composer.json
文件的 require
部分。
用法
###谷歌地图的最小示例
echo $form->field($model, 'coordinatesAttribute')->widget(\msvdev\widgets\mappicker\MapInput::className(), ['apiKey' => 'google_api_key']);
雅虎地图的最小示例
echo $form->field($model, 'coordinatesAttribute')->widget(\msvdev\widgets\mappicker\MapInput::className(), ['service' => 'yandex']);
示例设置
use \msvdev\widgets\mappicker\MapInput; echo $form->field($model, 'coordinatesAttribute')->widget( MapInput::className(), [ 'language' => 'en-Us', // map language, default is the same as in the app 'service' => 'google', // map service provider, "google" or "yandex", default "google" 'apiKey' => '', // required google maps 'coordinatesDelimiter' => '@', // attribute coordinate string delimiter, default "@" (lat@lng) 'mapWidth' => '800px', // width map container, default "500px" 'mapHeight' => '500px', // height map container, default "500px" 'mapZoom' => '14', // map zoom value, default "10" 'mapCenter' => [55.753338, 37.622861], // coordinates center map with an empty attribute, default Moscow ] );