定制 2amigos/yii2-leaflet-markercluster-plugin 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

2amigos/yii2-leaflet-markercluster-plugin

最新稳定版本:1.0.0

Composer 安装命令:

composer require 2amigos/yii2-leaflet-markercluster-plugin

包简介

Yii2 LeafLet Plugin to provide beautiful, sophisticated, high performance marker clustering solution with smooth animations and lots of great features.

README 文档

README

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

Yii 2 LeafletJs Plugin to provide beautiful, sophisticated, high performance marker clustering solution with smooth animations and lots of great features. This Plugin works in conjunction with LeafLet library for Yii 2 framework.

Installation

The preferred way to install this extension is through composer.

Either run

composer require 2amigos/yii2-leaflet-markercluster-plugin:~1.0

or add

"2amigos/yii2-leaflet-markercluster-plugin" : "~1.0"

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

Usage

Using an external json url source:

// LeafLet initialization component
// ...

// create cluster plugin
$cluster = new dosamigos\leaflet\plugins\markercluster\MarkerCluster([
     'jsonUrl' =>  Yii::$app->controller->createUrl('site/json')
]);

// install to LeafLet component
$leafLet->plugins->install($cluster);

// done render widget
echo $leafLet->widget(['options' => ['style' => 'height: 400px']]);

The example action returning the markers:

public function actionJson()
{
    Yii::$app->getResponse()->format = Response::FORMAT_JSON;
    echo json_encode([
        "markers" =>  [
            ["lat"=>-37.8210922667, "lng"=>175.2209316333, "popup" => "2"],
            ["lat"=>-37.8210819833, "lng"=>175.2213903167, "popup" => "3"],

        ]
    ]);
}

Now, adding markers as we create them:

// LeafLet initialization component
// ...

// create cluster plugin
$cluster = new dosamigos\leaflet\plugins\markercluster\MarkerCluster([
     'jsonUrl' =>  Yii::$app->controller->createUrl('site/json')
]);

// sample location
$center = new dosamigos\leaflet\types\LatLng(['lat' => 51.508, 'lng' => -0.11]);

$marker1 = new dosamigos\leaflet\layers\Marker([
    'latLng' => $center,
    'popupContent' => 'Hey! I am a marker'
]);

$marker2 = new dosamigos\leaflet\layers\Marker([
     'latLng' => $center,
     'popupContent' => 'Hey! I am a second marker'
]);

// add them to the cluster plugin
$cluster
    ->addLayer($marker1)
    ->addLayer($marker2);

// install to LeafLet component
$leafLet->plugins->install($cluster);


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

统计信息

  • 总下载量: 5.44k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 0
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 21
  • Forks: 10
  • 开发语言: JavaScript

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2014-02-17