定制 chiiya/nova-leaflet-field 二次开发

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

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

chiiya/nova-leaflet-field

Composer 安装命令:

composer require chiiya/nova-leaflet-field

包简介

Leaflet map field for Laravel Nova

README 文档

README

Nova Leaflet Field

🗺️ Leaflet map field with geo-coding search for Laravel Nova



Index

> Installation ..................................................................... 
> Usage ............................................................................ 

Installation

composer require chiiya/nova-leaflet-field
# Publish marker icon assets
php artisan vendor:publish --provider="Chiiya\NovaLeafletField\FieldServiceProvider"

Usage

To use the leaflet field, simply specify a label name:

LeafletField::make(__('Geo-Location'))

The field will only be displayed on detail and form views. It will attempt to look for latitude and longitude fields on the associated model to set the initial marker on the map, but you may customize this if your field names are different:

LeafletField::make(__('Geo-Location'))
    ->latitudeField('lat')
    ->longitudeField('lng')

The default tile and search provider for Leaflet is OpenStreetMaps. You may configure any search provider supported by leaflet-geosearch:

LeafletField::make(__('Geo-Location'))
    ->searchProvider(SearchProvider::GOOGLE)
    ->searchProviderKey('api-key')
    ->searchProviderOptions(['language' => 'de', 'region' => 'de'])

For customizing the tiles, provide a tile URL:

LeafletField::make(__('Geo-Location'))
    ->tileUrl('https://{s}.tile.osm.org/{z}/{x}/{y}.png')

There are a number of options to customize the map behaviour:

LeafletField::make(__('Geo-Location'))
    // Make the map marker draggable
    ->draggable()
    // Customize the geo-search search label
    ->searchLabel(__('Enter address'))
    // Default map zoom
    ->zoom(12)
    // Customize default latitude & longitude
    ->defaultCoordinates(0.0, 0.0)

Validation

When marking the field as required, the field will additionally validate that coordinates other than the default ones have been selected. If you wish to disable this behaviour, call the following method:

LeafletField::make(__('Geo-Location'))
    ->allowDefaultCoordinates()

You may also customize the error message shown when default coordinates were selected:

LeafletField::make(__('Geo-Location'))
    ->errorMessage(__('Please select a valid location'))

Address Fields Population

When using the Google search provider, you may use the data from the selected location to populate other fields on your model:

LeafletField::make(__('Geo-Location'))
    ->searchProvider(SearchProvider::GOOGLE)
    ->searchProviderKey('api-key')
    ->populateAddress()
    ->populatePostalCode('zip')
    ->populateCity()
    ->populateCountry()

The field will attempt to look for other inputs on the page with the default (address, postal_code, city, country) or custom names, and fill them with the values received from the Google Geocoding API. For the address, you may specify a custom format:

LeafletField::make(__('Geo-Location'))
    ->searchProvider(SearchProvider::GOOGLE)
    ->searchProviderKey('api-key')
    ->populateAddress()
    // Defaults to '{street_name} {street_number}'
    ->populatedAddressFormat('{street_number}, {street_name}')

This will only work when using the Google search provider.

chiiya/nova-leaflet-field 适用场景与选型建议

chiiya/nova-leaflet-field 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.02k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2021 年 07 月 22 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-07-22