symfony / ux

Symfony UX initiative: a JavaScript ecosystem for Symfony
https://ux.symfony.com/
MIT License
856 stars 315 forks source link

[Map] Introduce `ux_map.google_maps.default_map_id` configuration #2350

Closed Kocal closed 1 week ago

Kocal commented 2 weeks ago
Q A
Bug fix? no
New feature? yes
Issues Fix #2306
License MIT

With this modification, I can configure a default Google Maps mapId:

# config/packages/ux_map.yaml
ux_map:
    # https://symfony.com/bundles/ux-map/current/index.html#available-renderers
    renderer: '%env(resolve:default::UX_MAP_DSN)%'
    google_maps:
        default_map_id: abcdefgh123456789

without having to manually pass the mapId when creating a Map:

// use default mapId
$map = (new Map());
    ->center(new Point(48.8566, 2.3522))
    ->zoom(6);

// use default mapId
$map2 = (clone $map)
    ->options(new GoogleOptions());

// use custom mapId
$map3 = (clone $map)
    ->options(new GoogleOptions(mapId: 'foobar));