承接 siberfx/backpack-leafletjs 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

siberfx/backpack-leafletjs

最新稳定版本:6.1.3

Composer 安装命令:

composer require siberfx/backpack-leafletjs

包简介

Leafletjs lat lng fields for Laravel Backpack ^6.x

README 文档

README

Stars Forks Latest Version on Packagist

Installation

You can install the package via composer:

composer require siberfx/backpack-leafletjs

Usage


// config/leaflet.php file content, you can modify it by your own settings.
return [
    'model_name' => App\Models\Setting::class,

    'table_name' => 'settings',
    'lat_field' => 'lat',
    'lng_field' => 'lng',

    'mapbox' => [
        'access_token' => env('MAPS_MAPBOX_ACCESS_TOKEN', 'xxxxxxxxxxxxxxxxxxxxx'),
    ],
];

Publish files

php artisan vendor:publish --provider="Backpack\Leafletjs\LeafLetServiceProvider" --tag="migrations" #publish the migration file
php artisan vendor:publish --provider="Backpack\Leafletjs\LeafLetServiceProvider" --tag="config" #publish the config file
php artisan vendor:publish --provider="Backpack\Leafletjs\LeafLetServiceProvider" --tag="view_components" #publish the lang files

or

php artisan vendor:publish --provider="Backpack\Leafletjs\LeafLetServiceProvider" --tag="all" 

Add Leaflet fields to your model

You can override in which table are located your "lat, lng" fields and even the model you want to create the fields with the help of config/backpack/leaflet.php file and table_name field if its set already

$fillable = [
    'lat',
    'lng',
    ...
];

or

config('backpack.leaflet.lat_field'), // or 'lat'
config('backpack.leaflet.lng_field') // or 'lng'

Call it inside your controller like this or

// Add LeafletFields trait to your Crud Controller
use Backpack\Leafletjs\Http\Controllers\Admin\Traits\LeafletCrud;

// and call if your using App\Model\Settings model as your instance:
$this->setLeafletFields();

// to add default fields

or add in your Crud controller manually where you want to see it as shown below.


 $this->crud->addField([
        'name' => 'leafletMapId', // this is not a name of field in database.
        'type' => 'leaflet',
        'model' => config('backpack.leaflet.model_name'), // you can modify under config folder or override by your own for each model
        'options' => [
            'provider' => 'mapbox',  // default algolia map provider
            'marker_image' => null   // optional
        ],
        'hint' => '<em>You can also drag and adjust your mark by clicking</em>'
 ]);
        
 $this->crud->addField([
    'name' => 'lat',
    'type' => 'hidden',
    'attributes' => ['id' => 'leafletMapId-lat'],
    'tab' => 'General'
 ]);
        
 $this->crud->addField([
    'name' => 'lng',
    'type' => 'hidden',
    'attributes' => ['id' => 'leafletMapId-lng'],
    'tab' => 'General'
 ]);


or


$this->crud->addField([
        'name' => 'leafletMapId', // this is not a name of field in database.
        'type' => 'leaflet',
        'model' => config('backpack.leaflet.model_name'), // you can modify under config folder or override by your own for each model
        'options' => [
            'provider' => 'mapbox',  // default algolia map provider
            'marker_image' => null   // optional
        ],
        'autogenerate' => true, // if you dont want to create the fields in crud controller for lat and lng you specified, it generates himself.
   '    hint' => '<em>You can also drag and adjust your mark by clicking</em>'
 ]);

Security

If you discover any security related issues, please email info@siberfx.com instead of using the issue tracker.

Credits

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-02-22