nkizza / yii2-map-pick
为Yii2提供的坐标选择小部件。
1.0.6
2016-10-22 01:07 UTC
Requires
- yiisoft/yii2: ~2.0.0
This package is not auto-updated.
Last update: 2024-09-28 19:58:15 UTC
README
为模型纬度、经度和缩放属性提供地图选择器。此小部件使用(Yandex.Maps)[http://maps.yandex.ru] API。一键填充三个重要的位置属性!需要jQuery。
安装
安装此扩展的首选方式是通过composer。运行 composer require nkizza/yii2-map-pick:~1.0
或将 nkizza/yii2-map_pick:~1.0
添加到您应用程序的composer.json文件的要求部分。
使用方法
小部件提供三个可用值:纬度、经度和缩放。字段的完整定义是
<?= MapPick::widget([
...
'attributes' => [ //key - must be a "zoom", "lat" or "lon"
'zoom' => [
'name'=>'MapsCoords[zoom]', //input name (may be custom)
'value'=>7, //initial value for input
]
],
]);?>
您可以仅定义所需的属性。请参考以下代码查看示例
<?= MapPick::widget([
'model'=>$model,
//html options for the container tag
'options'=>[
'style'=>'height:400px',
],
//model attributes
'attributes' => [
'lat', //latitude (your model must have the 'lat' field)
'lon'=>'longtitude', // your model has the 'longtitude' field, place it under the key 'lon')
'zoom' => [
'name'=>'MapsCoords[customzoom]', //custom input name for attribute (if needed)
'value'=>7, //initial value for input
]
],
//custom js callback, is optional
'callback' => 'function(lat, lon, zoom) {alert('Hello!');}',
//language identifier
'language' => 'en_US',
]);?>