siberfx/backpack-leaflet-drawjs
Composer 安装命令:
composer require siberfx/backpack-leaflet-drawjs
包简介
LeafletDrawjs for Laravel Backpack ^6.x
关键字:
README 文档
README
Leaflet Drawing Polygon field and storing as json for Laravel Backpack ^6.x
[](https://packagist.org/packages/siberfx/backpack-leaflet-drawjs) ## InstallationYou can install the package via composer:
composer require siberfx/backpack-leaflet-drawjs
Usage
// config/leaflet.php file content, you can modify it by your own settings. return [ 'mapbox' => [ 'access_token' => env('MAPS_MAPBOX_ACCESS_TOKEN', 'xxxxxxxxxxxxxxxxxxxxx'), ], ];
backpack usage example
CRUD::addField([ 'name' => 'coordinates', 'label' => 'Poligon coordinates', 'type' => 'leaflet-draw', 'options' => [ 'provider' => 'mapbox', 'marker_image' => null ], ]);
the stored data structure example;
{"type": "Feature", "geometry": {"type": "Polygon", "coordinates": [[[30.59967, 36.832371], [30.617523, 36.899391], [30.669708, 36.904882], [30.702667, 36.91696], [30.768585, 36.910372], [30.809784, 36.878522], [30.838623, 36.853252], [30.775452, 36.848857], [30.730133, 36.856549], [30.697174, 36.878522], [30.662842, 36.885113], [30.59967, 36.832371]]]}, "properties": []}
Publish files
php artisan vendor:publish --provider="Backpack\LeafletDrawjs\LeafLetDrawServiceProvider" --tag="all"
Add Leaflet drawing polygon as json and store as json
you will have to need a migration with json or text type to store the data, as in the example below;
public function up() { Schema::create('polygons', function (Blueprint $table) { $table->id(); $table->json('geojson'); // Store GeoJSON data $table->timestamps(); }); }
the model should be like;
namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; class Polygon extends Model { use HasFactory; protected $fillable = ['geojson']; // Optionally, if you want to decode the GeoJSON automatically public function getGeojsonAttribute($value) { return json_decode($value); } }
the controller example should be like;
namespace App\Http\Controllers; use Illuminate\Http\Request; use App\Models\Polygon; class PolygonController extends Controller { public function store(Request $request) { // Validate the incoming data (optional) $request->validate([ 'polygon' => 'required|array' ]); // Store the polygon data as GeoJSON or serialized data $polygon = new Polygon(); $polygon->geojson = json_encode($request->polygon); // Save GeoJSON $polygon->save(); return response()->json(['message' => 'Polygon saved successfully']); } }
the route example;
Route::post('/store-polygon', [PolygonController::class, 'store'])->name('store-polygon');
Call it inside your controller like this or
or add in your Crud controller manually where you want to see it as shown below.
$this->crud->addField([ 'label' => 'Location', 'name' => 'location', 'type' => 'leaflet-draw', 'options' => [ 'provider' => 'mapbox', 'marker_image' => null ], 'tab' => 'General' '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
- [Selim Gormus](https://github.com/siberfx)
siberfx/backpack-leaflet-drawjs 适用场景与选型建议
siberfx/backpack-leaflet-drawjs 是一款 基于 Blade 开发的 Composer 扩展包,目前已累计 3 次下载、GitHub Stars 达 2, 最近一次更新时间为 2024 年 10 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「mapbox」 「backpack」 「openstreetmaps」 「laravel 9.x」 「leafjs」 「laravel 10.x」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 siberfx/backpack-leaflet-drawjs 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 siberfx/backpack-leaflet-drawjs 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 siberfx/backpack-leaflet-drawjs 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
More information available at https://pear.php.net/package/Services_OpenStreetMap
Show geo marker on a mapbox map
Show geo shape on a mapbox map with drawing capabilities
Generate a Yandex,Google,MapBox,Bing,CartoDB,HERE,MapQuest static map with Static Map Maker
Extended summernote fields for laravel backpack
Maps integration for Neos CMS. Stadiamaps, Protomaps, Openstreetmaps or GoogleMaps. Live preview. Multiple addresses.
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 40
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-10-06
