ttungbmt/yii2-leaflet-geocoder 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ttungbmt/yii2-leaflet-geocoder

Composer 安装命令:

composer require ttungbmt/yii2-leaflet-geocoder

包简介

Leaflet Interactive Maps Extension Library for Yii2.

README 文档

README

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

Yii 2 LeafletJs Plugin that adds support for address lookup to Leaflet with dropdown list capabilities and loading icon feedback. This Plugin works in conjunction with LeafLet library for Yii 2 framework.

Important The libraries used on this plugin have been modified from the original plugin source. So, if you wish to modify the plugin, remember that you cannot update it from its original source.

Installation

The preferred way to install this extension is through composer.

Either run

composer require ttungbmt/yii2-leaflet-geocoder "@dev"

or add

"ttungbmt/yii2-leaflet-geocoder" : "@dev"

to the require section of your application's composer.json file.

Usage

There are four services that you can use, even though we have implemented only three:

  • Nominatim
  • Bing
  • MapQuest
  • Google
  • HCMGIS
  • Mapbox
  • Here

Anybody will to help integrate more services, is very welcome :)

use dosamigos\leaflet\layers\TileLayer;
use ttungbmt\leaflet\Leaflet;
use dosamigos\leaflet\types\LatLng;
use ttungbmt\leaflet\geocoder\services\ServiceHCMGIS;
use ttungbmt\leaflet\geocoder\GeoCoder;

// lets use nominating service
$hcmgis = new ServiceHCMGIS();

// create geocoder plugin and attach the service
$geoCoderPlugin = new GeoCoder([
    'service' => $hcmgis,
    'clientOptions' => [
        // we could leave it to allocate a marker automatically
        // but I want to have some fun
        'defaultMarkGeocode' => false
    ],
    'clientEvents'  => [
        'markgeocode' => new JsExpression('function(e){ console.log(e) }')
    ]
]);

// add a marker to center
$marker = new Marker([
    'name' => 'geoMarker',
    'latLng' => $center,
    'clientOptions' => ['draggable' => true], // draggable marker
    'clientEvents' => [
        'dragend' => 'function(e){
            console.log(e.target._latlng.lat, e.target._latlng.lng);
        }'
    ]
]);

// configure the tile layer
$tileLayer = new TileLayer([
    'urlTemplate' => 'http://{s}.google.com/vt/lyrs={map}&x={x}&y={y}&z={z}',
    'clientOptions' => [
        'map' => 'm',
        'attribution' => ''© Google Maps',
        'subdomains' => ['mt0', 'mt1', 'mt2', 'mt3'],
    ]
]);

// initialize our leafLet component
$leaflet = new Leaflet([
    'name' => 'geoMap',
    'tileLayer' => $tileLayer,
    'center' => $center,
    'zoom' => 10,
]);

// add the marker
$leaflet->addLayer($marker);

// install the plugin
$leaflet->installPlugin($geoCoderPlugin);

// run the widget (you can also use dosamigos\leaflet\widgets\Map::widget([...]))
echo $leaflet->widget();

Testing

$ ./vendor/bin/phpunit

Contributing

Please see CONTRIBUTING for details.

Credits

License

The BSD License (BSD). Please see License File for more information.

2amigOS!
Web development has never been so fun!
www.2amigos.us

统计信息

  • 总下载量: 6
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-06-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固