定制 useful-web/yii2-leaflet-search 二次开发

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

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

useful-web/yii2-leaflet-search

Composer 安装命令:

composer require useful-web/yii2-leaflet-search

包简介

Leaflet search widget for Yii2

README 文档

README

Yii2 leaflet search plugin

Basic usage

First, include this scripts:

  <!-- leaflet library -->
  <script src="/assets/6268c434/leaflet.js"></script>
  <!-- https://github.com/perliedman/leaflet-control-geocoder-->
  <script src="/assets/961614a3/Control.Geocoder.js"></script>
  <!-- \usefulweb\yii2-leaflet-search\dist\leaflet-search.js -->
  <script src="/assets/c01748f9/leaflet-search.js"></script>

And then you can use this plugin

<?php
  use \usefulweb\LeafletSearch\LeafletSearch;
  use yii\bootstrap\ActiveForm;
?>
<?php $form = ActiveForm::begin([]); ?>
  <div class="row">
      <?php echo Html::textInput('search-longitude', null, [
        'id' => 'search-longitude',
        ]) ?>
  </div>
  <div class="row">
    <?php echo Html::textInput('search-latitude', null, [
      'id' => 'search-latitude',
      ]) ?>
  </div>
  <div class="row">
    <?php echo Html::textInput('search-radius', null, [
      'id' => 'search-radius',
      ]) ?>
  </div>
  <div class="row">
      <?php echo LeafletSearch::widget([
          // id of longitude field
          'longitude' => 'search-longitude',
          // id of latitude field
          'latitude' => 'search-latitude',
          // id of radius field: optional
          'radius' => 'search-radius',
          // htmloptions for map container
          'htmlOptions' => [
            'style' => 'width:900px;height:300px;'
          ],
          'options' => [
            'map' => [
              // leaflet map options, see http://leafletjs.com/reference.html#map-options
              'options' => [],
              // leaflet default view options, see http://leafletjs.com/reference.html#map-setview
              'defaultView' => [[55.7198,37.6989], 10],
              // default map zoom (used for panning to coordinates from field values)
              'defaultZoom' => 10,
            ],
            // leaflet-geocoder-control options, see https://github.com/perliedman/leaflet-control-geocoder#options
            'geocoder' => [
              'placeholder' => 'Search...',
              'radiusSize' => 100,
              'collapsed' => false,
              ]
            ],

        ]) ?>
  </div>
<?php ActiveForm::end(); ?>

Using AssetBundle

First, you need to extend \usefulweb\LeafletSearch\LeafletSearchAsset:

<?php
namespace \your\namespace\assets;

class LeafletSearchAsset extends \usefulweb\LeafletSearch\LeafletSearchAsset
{
  public $depends = [
    'path\to\LeafletAsset',
    'path\to\LeafletControlGeocoderAsset',
  ];
}
 ?>

in your php file add this lines

<?php
use \usefulweb\LeafletSearch\LeafletSearch;
use \your\namespace\assets\LeafletSearchAsset;

LeafletSearchAsset::register($this);
?>

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 1
  • 开发语言: TypeScript

其他信息

  • 授权协议: Unknown
  • 更新时间: 2015-07-08