kpebedko22/filament-yandex-map
Installation:
composer require kpebedko22/filament-yandex-map
php artisan vendor:publish --tag="filament-yandex-map-config"
Add API keys to .env:
YANDEX_MAP_API_KEY=your_api_key
YANDEX_MAP_SUGGEST_API_KEY=your_suggest_api_key
First Use Case: Add a map field to a Filament form/resource:
use Kpebedko22\FilamentYandexMap\Components\YandexMap;
use Kpebedko22\FilamentYandexMap\Enums\YandexMapMode;
YandexMap::make('location')
->mode(YandexMapMode::Placemark)
->required()
Where to Look First:
config/filament-yandex-map.php for default settingsresources/lang/vendor/filament-yandex-map for translations// In a Filament Form
public static function form(Form $form): Form
{
return $form
->schema([
YandexMap::make('coordinates')
->mode(YandexMapMode::Placemark)
->columnSpanFull(),
]);
}
// In a Filament Table
YandexMap::make('location')
->mode(YandexMapMode::Placemark)
->height('300px')
->disabled()
YandexMap::make('dynamic_map')
->mode(fn (CreateLocation $record) => $record->isPremium ? YandexMapMode::Route : YandexMapMode::Placemark)
->apiKey(fn () => config('services.yandex_map.api_key'))
YandexMap::make('required_location')
->mode(YandexMapMode::Placemark)
->rules(['required', 'yandex_map:required'])
YandexMap::make('custom_controls')
->mode(YandexMapMode::Placemark)
->deleteBtnParameters(
new ButtonData('Delete Marker'),
new ButtonOptions(float: ButtonFloat::Right)
)
->saveBtnParameters(
new ButtonData('Save Location'),
new ButtonOptions(float: ButtonFloat::Left)
)
API Key Management:
config('services.yandex_map.api_key') for consistencyTranslation Handling:
php artisan vendor:publish --tag="filament-yandex-map-translations"
resources/lang/en/filament-yandex-map.phpPerformance Optimization:
height (default: 600px) based on your layoutcolumnSpanFull() for full-width maps in formsTesting:
$this->mock(YandexMapService::class, function ($mock) {
$mock->shouldReceive('getGeocode')
->andReturn(['coordinates' => [55.75, 37.62]]);
});
API Key Requirements:
api_key and suggest_api_key are mandatory. Missing either will break the map.403 Forbidden errors if keys are invalid.Mode Configuration:
mode() is required. Forgetting this will throw a runtime error.Placemark, Route, Polygon, CircleCoordinate Validation:
[latitude, longitude] format. Reversing these will place markers in the ocean.dd($record->coordinates) to verify format.Translation Conflicts:
php artisan view:clear
CORS Issues:
https://yourdomain.com to Yandex API’s allowed domains.Console Errors:
YMAP_ERROR).API key invalid → Verify .env keys.Geocoder failed → Check suggest_api_key.Network Tab:
api-maps.yandex.ru for clues.Log Configuration:
config/filament-yandex-map.php:
'debug' => env('APP_DEBUG', false),
storage/logs/filament-yandex-map.log.Custom Map Options:
extraOptions():
->extraOptions([
'objectsDisableDefaultBehavior' => true,
'controls' => ['zoomControl', 'fullscreenControl'],
])
Event Handling:
->extraOptions([
'on' => [
'objectadd' => 'function (e) { console.log(e.get("geometry")); }',
],
])
Custom Styling:
resources/css/filament/app.css:
.filament-yandex-map-container {
border: 1px solid #e2e8f0;
border-radius: 0.5rem;
}
Server-Side Processing:
// app/Providers/AppServiceProvider.php
public function boot()
{
$this->app->extend(YandexMapService::class, function ($service) {
$service->setCustomLogic(function ($data) {
// Pre-process coordinates
return $data;
});
return $service;
});
}
Testing Components:
$this->filament()->withinForm(
fn (Form $form) => $form->fillForm([
'coordinates' => [55.75, 37.62],
])
);
How can I help you explore Laravel packages today?