2amigos/yii2-leaflet-geosearch-plugin

此包已被弃用且不再维护。未建议替代包。

为 Leaflet 提供地址查找(又称地理编码/地理搜索)支持的 Yii2 Leaflet 插件。

安装次数: 25 230

依赖: 0

建议者: 0

安全: 0

星星: 1

关注者: 18

分支: 6

开放问题: 1

语言:JavaScript

类型:yii2-extension

1.0.5 2016-09-10 19:48 UTC

This package is auto-updated.

Last update: 2023-08-16 02:12:06 UTC


README

Latest Version Software License Build Status Coverage Status Quality Score Total Downloads

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)。有关更多信息,请参阅 许可证文件

2amigOS!

网络开发从未如此有趣!
www.2amigos.us