antonyz89/yii2-jquery-locationpicker
Composer 安装命令:
composer require antonyz89/yii2-jquery-locationpicker
包简介
jquery location picker widget for yii2
README 文档
README
The widget implement jquery-locationpicker-plugin
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require pigochu/yii2-jquery-locationpicker ">=0.2.0"
or add
"pigochu/yii2-jquery-locationpicker": ">=0.2.0"
to the require section of your composer.json file.
Basic Usage for Test
<?= \pigolab\locationpicker\LocationPickerWidget::widget(); ?>
Binding UI with the widget
This sample is transformed via http://logicify.github.io/jquery-locationpicker-plugin/#usage
<?php use yii\web\JsExpression; ?> Location: <input type="text" id="us2-address" style="width: 200px"/> <br> Radius: <input type="text" id="us2-radius"/> <br> Lat.: <input type="text" id="us2-lat"/> <br> Long.: <input type="text" id="us2-lon"/> <br> <?php echo \pigolab\locationpicker\LocationPickerWidget::widget([ 'key' => 'abcabcabcabc ...', // require , Put your google map api key 'options' => [ 'style' => 'width: 100%; height: 400px', // map canvas width and height ] , 'clientOptions' => [ 'location' => [ 'latitude' => 46.15242437752303 , 'longitude' => 2.7470703125, ], 'radius' => 300, 'addressFormat' => 'street_number', 'inputBinding' => [ 'latitudeInput' => new JsExpression("$('#us2-lat')"), 'longitudeInput' => new JsExpression("$('#us2-lon')"), 'radiusInput' => new JsExpression("$('#us2-radius')"), 'locationNameInput' => new JsExpression("$('#us2-address')") ] ] ]); ?>
CoordinatesPicker
CoordinatesPicker let you get coordinates in ActiveForm , In addition I implemented some features not in original jquery-locationpicker-plugin :
- enable/disable search box , search box will overlay on map
- enable/disable all googlemap's control
Example :
<?php echo $form->field($model, 'coordinates')->widget('\pigolab\locationpicker\CoordinatesPicker' , [ 'key' => 'abcabcabc...' , // require , Put your google map api key 'valueTemplate' => '{latitude},{longitude}' , // Optional , this is default result format 'options' => [ 'style' => 'width: 100%; height: 400px', // map canvas width and height ] , 'enableSearchBox' => true , // Optional , default is true 'searchBoxOptions' => [ // searchBox html attributes 'style' => 'width: 300px;', // Optional , default width and height defined in css coordinates-picker.css ], 'searchBoxPosition' => new JsExpression('google.maps.ControlPosition.TOP_LEFT'), // optional , default is TOP_LEFT 'mapOptions' => [ // google map options // visit https://developers.google.com/maps/documentation/javascript/controls for other options 'mapTypeControl' => true, // Enable Map Type Control 'mapTypeControlOptions' => [ 'style' => new JsExpression('google.maps.MapTypeControlStyle.HORIZONTAL_BAR'), 'position' => new JsExpression('google.maps.ControlPosition.TOP_LEFT'), ], 'streetViewControl' => true, // Enable Street View Control ], 'clientOptions' => [ // jquery-location-picker options 'radius' => 300, 'addressFormat' => 'street_number', ] ]); ?>
Get coordinates :
Default valueTemplate is '{latitude},{longtitude} , So we will get resulit like : '25.023308046766083,121.46041916878664'
We can convert it via explode() :
<?php list($latitude,$longitude) = explode(',' , $model->coordinates); ?>
Deprecated options : enableMapTypeControl
Since version 0.2.0 , don't use 'enableMapTypeControl' , I added 'mapOptions' for set googlemap options. You can enable/disable all controlls or set control's style , position now.
Example : enable rotateControl , streetViewControl , mapTypeControl and set style/position
<?php echo $form->field($model, 'coordinates')->widget('\pigolab\locationpicker\CoordinatesPicker' , [ 'clientOptions' => [ 'zoom' => 20 ], // rotateControl will display when zoom is 20 // .... other options ... 'mapOptions' => [ // set google map optinos 'rotateControl' => true, 'scaleControl' => false, 'streetViewControl' => true, 'mapTypeId' => new JsExpression('google.maps.MapTypeId.SATELLITE'), 'heading'=> 90, 'tilt' => 45 , 'mapTypeControl' => true, 'mapTypeControlOptions' => [ 'style' => new JsExpression('google.maps.MapTypeControlStyle.HORIZONTAL_BAR'), 'position' => new JsExpression('google.maps.ControlPosition.TOP_CENTER'), ] ] ]); ?>
Please visit GoogleMaps Full Control document : https://developers.google.com/maps/documentation/javascript/controls
Other DocumentS
antonyz89/yii2-jquery-locationpicker 适用场景与选型建议
antonyz89/yii2-jquery-locationpicker 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 196 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 04 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「extension」 「yii2」 「locationpicker」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 antonyz89/yii2-jquery-locationpicker 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 antonyz89/yii2-jquery-locationpicker 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 antonyz89/yii2-jquery-locationpicker 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
jquery location picker widget for yii2
A custom URL rule class for Yii 2 which allows to create translated URL rules
The Yii2 extension uses jQuery jquery.carousel-1.1.min.js and makes image carousel from php array of structure defined.
TYPO3 CMS extension to create gallery content element with preset crop ratios and pagination
UI Kit 3 Extension for Yii2
Adds more BBCode
统计信息
- 总下载量: 196
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-04-08