定制 marshmallow/nova-map-box-field 二次开发

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

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

marshmallow/nova-map-box-field

Composer 安装命令:

composer require marshmallow/nova-map-box-field

包简介

A field for Laravel Nova 4 to create mapbox polygons and store them into your database. Awesome stuff really!

README 文档

README

alt text

Nova MapBox Field

Latest Version on Packagist Total Downloads

A field for Laravel Nova to create MapBox polygons and store them into your database. Awesome stuff really!

Installation

Install the package via Composer:

composer require marshmallow/nova-map-box-field

The package registers itself through Laravel's package auto-discovery, so the field's assets are served to Nova automatically.

Publish the config file

php artisan vendor:publish --provider="Marshmallow\MapBox\FieldServiceProvider"

Add your MapBox token

The field needs a public MapBox access token. Set it in your .env:

MAPBOX_PUBLIC_KEY=your-mapbox-public-token

Configuration

After publishing, the defaults live in config/nova-map-box-field.php. Every value is used to initialise a new MapBox field and can be overridden per field with the methods documented under Usage.

Key Default Description
mapbox_key env('MAPBOX_PUBLIC_KEY') Your public MapBox access token.
default.height 300 Map height in pixels.
default.zoom 8 Initial zoom level.
default.latitude 52.111221 Latitude the map is centered on.
default.longitude 4.647251 Longitude the map is centered on.
default.style mapbox://styles/mapbox/light-v10 MapBox style URL.
default.container map DOM container identifier for the map.
default.navigation_controls false Show MapBox navigation controls.
default.draw_controls false Show the polygon drawing controls.
default.polygon_preview.color #ff133b Fill color used when previewing polygons.
default.polygon_preview.opacity 0.5 Fill opacity used when previewing polygons.

Usage

Add the field to a Nova resource. By default the field is hidden from the index view.

use Marshmallow\MapBox\MapBox;

public function fields(NovaRequest $request)
{
    return [
        MapBox::make('Area', 'area'),
    ];
}

Customising the map

All map options can be overridden per field. The values default to your config file.

use Marshmallow\MapBox\MapBox;

MapBox::make('Area', 'area')
    ->height(400)
    ->defaultZoom(10)
    ->latitude(52.111221)
    ->longitude(4.647251)
    ->style('mapbox://styles/mapbox/streets-v11')
    ->navigationControls(true)
    ->drawControls(true)
    ->polygonPreviewColor('#ff133b')
    ->polygonPreviewOpacity(0.5);

Centering the map dynamically

Use setCenter() to derive the center from the resource. Return an [latitude, longitude] array, or a falsy value to keep the current center.

MapBox::make('Area', 'area')
    ->setCenter(function ($field) {
        return [52.111221, 4.647251];
    });

Adding markers

addMarker() pushes a marker onto the map. Return an [latitude, longitude] array, or a falsy value to add nothing. Call it multiple times to add multiple markers.

MapBox::make('Area', 'area')
    ->addMarker(fn ($field) => [52.111221, 4.647251])
    ->addMarker(fn ($field) => [51.924420, 4.477733]);

A default polygon

Draw a default polygon around a coordinate within a given range in kilometres.

MapBox::make('Area', 'area')
    ->defaultPolygon(latitude: 52.111221, longitude: 4.647251, range_in_km: 5);

Prefilling polygons

Use prefillWith() to render existing polygons on the map. The callback must return an array of Marshmallow\MapBox\Polygon objects; anything else throws an exception.

use Marshmallow\MapBox\MapBox;
use Marshmallow\MapBox\Polygon;

MapBox::make('Area', 'area')
    ->prefillWith(function ($field) {
        return [
            new Polygon(
                polygon: [[52.111221, 4.647251], [52.120000, 4.650000], [52.115000, 4.660000]],
                color: '#ff133b',
                opacity: 0.5,
            ),
        ];
    });

Credits

License

The MIT License. Please see the License File for more information.

marshmallow/nova-map-box-field 适用场景与选型建议

marshmallow/nova-map-box-field 是一款 基于 Vue 开发的 Composer 扩展包,目前已累计 2.47k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2022 年 08 月 26 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「nova」 「laravel」 「map box」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 marshmallow/nova-map-box-field 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 marshmallow/nova-map-box-field 我们能提供哪些服务?
定制开发 / 二次开发

基于 marshmallow/nova-map-box-field 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: Vue

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-08-26