PHP code example of goodappr / moonshine-yandex-maps

1. Go to this page and download the library: Download goodappr/moonshine-yandex-maps library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

goodappr / moonshine-yandex-maps example snippets


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

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'),
    ]);

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();

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(),
        ];
    }
}

$table->json('location')->nullable();
$table->json('delivery_zones')->nullable();
bash
php artisan vendor:publish --tag=moonshine-yandex-maps-config