goodappr/moonshine-yandex-maps 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

goodappr/moonshine-yandex-maps

最新稳定版本:v1.0.1

Composer 安装命令:

composer require goodappr/moonshine-yandex-maps

包简介

Yandex Maps and Polygons fields for MoonShine 4.x - point markers and drawable polygons

README 文档

README

Пакет полей для MoonShine 4.x — работа с картами и полигонами через Yandex Maps API.

Cover

Возможности

  • YandexMap — точки с метками, балуны, кастомный контент
  • YandexMapPolygon — рисование полигонов, зоны доставки, районы

Требования

Установка

composer require goodappr/moonshine-yandex-maps

Конфигурация

Опубликуйте конфиг и задайте API-ключ:

php artisan vendor:publish --tag=moonshine-yandex-maps-config

В .env:

YANDEX_MAPS_API_KEY=your_yandex_maps_api_key

Либо добавьте в config/services.php:

'yandex' => [
    'maps_api_key' => env('YANDEX_MAPS_API_KEY', ''),
],

Использование

YandexMap — точки на карте

use MoonShine\YandexMaps\Fields\YandexMap;
use MoonShine\UI\Fields\Text;
use MoonShine\UI\Fields\Textarea;
use MoonShine\UI\Fields\Select;
use MoonShine\UI\Fields\Color;
use MoonShine\UI\Fields\Image;

YandexMap::make('Местоположение', 'location')
    ->coordinates([55.751574, 37.573856])
    ->zoom(12)
    ->mapHeight('400px')
    ->indexDisplayFields(['address', 'phone', 'email'])
    ->indexShowAddressCopy(true)
    ->balloonContent([
        'title' => 'model.name',
        'address' => 'model.address',
        'phone' => 'model.phone',
    ])
    ->placemarkProperties([
        'hintContent' => 'Кликните для просмотра',
        'iconCaption' => 'Филиал',
    ])
    ->placemarkOptions([
        'preset' => Select::make('Тип иконки', 'icon_type')
            ->options([
                'islands#blueHomeIcon' => 'Дом',
                'islands#redRestaurantIcon' => 'Ресторан',
            ])
            ->default('islands#blueHomeIcon'),
        'iconColor' => Color::make('Цвет', 'icon_color')->default('#3B82F6'),
        'iconImageHref' => Image::make('Кастомная иконка', 'iconImageHref')
            ->dir('icons')
            ->allowedExtensions(['png', 'svg', 'webp']),
        'draggable' => true,
    ])
    ->customBalloonFields([
        Text::make('Заголовок балуна', 'title')->default('Объект'),
        Textarea::make('Описание', 'description'),
    ]);

YandexMap — форма, карта и метка YandexMap — настройки балуна и иконки

Данные сохраняются в JSON: lat, lng, coordinates, balloon_data, placemark_options, placemark_properties.

YandexMapPolygon — полигоны

use MoonShine\YandexMaps\Fields\YandexMapPolygon;

YandexMapPolygon::make('Зоны доставки', 'delivery_zones')
    ->mapHeight('300px')
    ->allowMultiplePolygons()
    ->allowEditExisting()
    ->allowImportExport()
    ->defaultPolygonColor('#3B82F6')
    ->defaultPolygonOpacity(0.3)
    ->polygonColors(['#3B82F6', '#10B981', '#F59E0B', '#EF4444'])
    ->showMiniMapOnIndex();

YandexMapPolygon — рисование полигонов

Подключение assets для Layout

Для копирования адреса по клику и корректной отправки длинных данных полигонов добавьте трейт в ваш Layout:

namespace App\MoonShine\Layouts;

use MoonShine\YandexMaps\Traits\WithYandexMapsAssets;
use MoonShine\Laravel\Layouts\AppLayout;

class MoonShineLayout extends AppLayout
{
    use WithYandexMapsAssets;

    protected function assets(): array
    {
        return [
            ...parent::assets(),
            ...$this->getYandexMapsAssets(),
        ];
    }
}

Структура данных

YandexMap (location)

{
  "lat": 55.751574,
  "lng": 37.573856,
  "coordinates": [55.751574, 37.573856],
  "balloon_data": { "title": "...", "description": "..." },
  "placemark_options": { "preset": "...", "iconImageHref": "..." },
  "placemark_properties": { "hintContent": "...", "iconCaption": "..." }
}

YandexMapPolygon (GeoJSON-like)

[
  {
    "type": "Polygon",
    "coordinates": [[[lng, lat], [lng, lat], ...]],
    "style": { "fillColor": "#3B82F6", "strokeColor": "#1D4ED8" },
    "data": { "name": "Зона 1" }
  }
]

Миграции

Для хранения:

$table->json('location')->nullable();
$table->json('delivery_zones')->nullable();

Лицензия

MIT

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固