forked from symfony/ux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature symfony#2350 [Map] Introduce `ux_map.google_maps.default_map_…
…id` configuration (Kocal) This PR was merged into the 2.x branch. Discussion ---------- [Map] Introduce `ux_map.google_maps.default_map_id` configuration | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes <!-- please update src/**/CHANGELOG.md files --> | Issues | Fix symfony#2306 <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT <!-- Replace this notice by a description of your feature/bugfix. This will help reviewers and should be a good start for the documentation. Additionally (see https://symfony.com/releases): - Always add tests and ensure they pass. - For new features, provide some code snippets to help understand usage. - Features and deprecations must be submitted against branch main. - Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry - Never break backward compatibility (see https://symfony.com/bc). --> With this modification, I can configure a default Google Maps `mapId`: ```yaml # 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`: ```php // 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)); ``` Commits ------- cbacecc [Map] Introduce `ux_map.google_maps.default_map_id` configuration
- Loading branch information
Showing
9 changed files
with
87 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,12 +17,20 @@ | |
use Symfony\UX\Map\Renderer\Dsn; | ||
use Symfony\UX\Map\Renderer\RendererFactoryInterface; | ||
use Symfony\UX\Map\Renderer\RendererInterface; | ||
use Symfony\UX\StimulusBundle\Helper\StimulusHelper; | ||
|
||
/** | ||
* @author Hugo Alliaume <[email protected]> | ||
*/ | ||
final class GoogleRendererFactory extends AbstractRendererFactory implements RendererFactoryInterface | ||
{ | ||
public function __construct( | ||
StimulusHelper $stimulus, | ||
private ?string $defaultMapId = null, | ||
) { | ||
parent::__construct($stimulus); | ||
} | ||
|
||
public function create(Dsn $dsn): RendererInterface | ||
{ | ||
if (!$this->supports($dsn)) { | ||
|
@@ -42,6 +50,7 @@ public function create(Dsn $dsn): RendererInterface | |
url: $dsn->getOption('url'), | ||
version: $dsn->getOption('version', 'weekly'), | ||
libraries: ['maps', 'marker', ...$dsn->getOption('libraries', [])], | ||
defaultMapId: $this->defaultMapId, | ||
); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters