2amigos / yii2-leaflet-geosearch-plugin
此包已被弃用且不再维护。未建议替代包。
为 Leaflet 提供地址查找(又称地理编码/地理搜索)支持的 Yii2 Leaflet 插件。
1.0.5
2016-09-10 19:48 UTC
Requires
Requires (Dev)
- phpunit/phpunit: 4.*
README
Yii 2 LeafletJs 插件,为 Leaflet 添加地址查找(又称地理编码/地理搜索)支持。此插件与 LeafLet 库结合使用于 Yii 2 框架。
安装
安装此扩展的首选方式是通过 composer。
运行以下命令:
composer require 2amigos/yii2-leaflet-geosearch-plugin:~1.0
或添加以下代码到您的应用程序的 composer.json
文件的 require 部分:
"2amigos/yii2-leaflet-geosearch-plugin" : "~1.0"
to the require section of your application's composer.json
file.
使用方法
use dosamigos\leaflet\layers\TileLayer;
use dosamigos\leaflet\LeafLet;
use dosamigos\leaflet\types\LatLng;
use dosamigos\leaflet\plugins\geosearch\GeoSearch;
$center = new LatLng(['lat' => 39.67442740076734, 'lng' => 2.9347229003906246]);
$geoSearchPlugin = new GeoSearch([
'service' => GeoSearch::SERVICE_OPENSTREETMAP,
// uncomment following block to define custom labels
/*
'clientOptions' => [
'searchLabel' => 'enter address here',
'notFoundMessage' => 'no address found',
],
*/
]);
$tileLayer = new TileLayer([
'urlTemplate' => 'https://a.tile.openstreetmap.org/{z}/{x}/{y}.png',
'clientOptions' => [
'attribution' => 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors',
'subdomains' => '1234'
]
]);
$leafLet = new LeafLet([
'name' => 'geoMap',
'tileLayer' => $tileLayer,
'center' => $center,
'zoom' => 10,
'clientEvents' => [
// setting up one of the geo search events for fun
'geosearch_showlocation' => 'function(e){
console.log(e.target);
}'
]
]);
// add the plugin
$leafLet->installPlugin($geoSearchPlugin);
// run the widget (you can also use dosamigos\leaflet\widgets\Map::widget([...]))
echo $leafLet->widget();
贡献
请参阅 CONTRIBUTING 获取详细信息。
感谢
许可证
BSD 许可证(BSD)。有关更多信息,请参阅 许可证文件。
网络开发从未如此有趣!
www.2amigos.us