Skip to content

Commit 3248cb5

Browse files
committed
mend
1 parent d4c98c0 commit 3248cb5

File tree

6 files changed

+47
-165
lines changed

6 files changed

+47
-165
lines changed

src/Map/config/services.php

+21-21
Original file line numberDiff line numberDiff line change
@@ -25,36 +25,36 @@
2525
return static function (ContainerConfigurator $container): void {
2626
$container->services()
2727
->set('ux_map.renderers', Renderers::class)
28-
->factory([service('ux_map.renderer_factory'), 'fromStrings'])
29-
->args([
30-
abstract_arg('renderers configuration'),
31-
])
28+
->factory([service('ux_map.renderer_factory'), 'fromStrings'])
29+
->args([
30+
abstract_arg('renderers configuration'),
31+
])
3232

3333
->set('.ux_map.ux_icons.renderer', UxIconRenderer::class)
34-
->args([
35-
service('.ux_icons.icon_renderer')->nullOnInvalid(),
36-
])
34+
->args([
35+
service('.ux_icons.icon_renderer')->nullOnInvalid(),
36+
])
3737

3838
->set('ux_map.renderer_factory.abstract', AbstractRendererFactory::class)
39-
->abstract()
40-
->args([
41-
service('stimulus.helper'),
42-
service('.ux_map.ux_icons.renderer')->nullOnInvalid(),
43-
])
39+
->abstract()
40+
->args([
41+
service('stimulus.helper'),
42+
service('.ux_map.ux_icons.renderer')->nullOnInvalid(),
43+
])
4444

4545
->set('ux_map.renderer_factory', Renderer::class)
46-
->args([
47-
tagged_iterator('ux_map.renderer_factory'),
48-
])
46+
->args([
47+
tagged_iterator('ux_map.renderer_factory'),
48+
])
4949

5050
->set('ux_map.twig_extension', MapExtension::class)
51-
->tag('twig.extension')
51+
->tag('twig.extension')
5252

5353
->set('ux_map.twig_runtime', MapRuntime::class)
54-
->args([
55-
service('ux_map.renderers'),
56-
])
57-
->tag('twig.runtime')
58-
->tag('ux.twig_component.twig_renderer', ['key' => 'ux:map'])
54+
->args([
55+
service('ux_map.renderers'),
56+
])
57+
->tag('twig.runtime')
58+
->tag('ux.twig_component.twig_renderer', ['key' => 'ux:map'])
5959
;
6060
};

src/Map/doc/index.rst

+12-28
Original file line numberDiff line numberDiff line change
@@ -135,35 +135,19 @@ You can add markers to a map using the ``addMarker()`` method::
135135
Add Marker icons
136136
~~~~~~~~~~~~~~~~
137137

138-
It is possible to add icon to Marker::
139-
138+
.. versionadded:: 2.24
139+
``Marker`` icon customizatisation is available since UX Map 2.24.
140+
When returning a Map, it's quite common to want to customize ``Marker`` icon. It is possible thanks to ``icon`` parameter and ``Icon`` class::
141+
// It can be a UX Icon (requires `symfony/ux-icons`)
142+
$icon = Icon::fromUxIcon('fa:map-marker');
143+
// Or an URL pointing to an image
144+
$icon = Icon::fromUrl('https://example.com/marker.png');
145+
// Or a plain SVG content
146+
$icon = Icon::fromInlineSVG('<svg>(...)</svg>');
140147
new Marker(
141-
position: new Point(45.7640, 4.8357),
142-
title: 'Lyon',
143-
infoWindow: new InfoWindow(
144-
headerContent: '<b>Lyon</b>',
145-
content: 'The French town in the historic Rhône-Alpes region, located at the junction of the Rhône and Saône rivers.'
146-
),
147-
icon: Icon::fromInlineSvg(
148-
svg: '<svg>....</svg>'
149-
)
150-
))
151-
152-
You can add image icon (type 'url')::
153-
154-
Icon::fromUrl(
155-
url: 'https://my-image.png',
156-
width: 24, // default
157-
height: 24, // default
158-
)
159-
160-
or SVG icon (type 'html')::
161-
162-
Icon::fromInlineSvg(
163-
svg: '<svg>...</svg>',
164-
width: 36,
165-
height: 36,
166-
)
148+
// ...
149+
icon: $icon
150+
))
167151

168152
Remove elements from Map
169153
~~~~~~~~~~~~~~~~~~~~~~~~

src/Map/src/Icon/Icon.php

+7-3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
*/
2121
class Icon
2222
{
23+
public const TYPE_URL = "url";
24+
public const TYPE_INLINE_SVG = "inline-svg";
25+
public const TYPE_UX_ICON = "ux-icon";
26+
2327
private function __construct(
2428
public string $content,
2529
public string $type,
@@ -42,7 +46,7 @@ public static function fromUrl(string $url, int $width = 24, int $height = 24):
4246
{
4347
return new Url(
4448
content: $url,
45-
type: 'url',
49+
type: self::TYPE_URL,
4650
width: $width,
4751
height: $height
4852
);
@@ -52,7 +56,7 @@ public static function fromInlineSVG(string $html, int $width = 24, int $height
5256
{
5357
return new InlineSvg(
5458
content: $html,
55-
type: 'inline-svg',
59+
type: self::TYPE_INLINE_SVG,
5660
width: $width,
5761
height: $height
5862
);
@@ -62,7 +66,7 @@ public static function fromUxIcon(string $name, int $width = 24, int $height = 2
6266
{
6367
return new UxIcon(
6468
content: $name,
65-
type: 'ux-icon',
69+
type: self::TYPE_UX_ICON,
6670
width: $width,
6771
height: $height
6872
);

src/Map/src/Icon/Icon.php.orig

-90
This file was deleted.

src/Map/src/Icon/Icon.php.rej

-16
This file was deleted.

src/Map/src/UXMapBundle.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ public function configure(DefinitionConfigurator $definition): void
4343
$rootNode = $definition->rootNode();
4444
$rootNode
4545
->children()
46-
->scalarNode('renderer')->defaultNull()->end()
47-
->arrayNode('google_maps')
48-
->addDefaultsIfNotSet()
49-
->children()
50-
->scalarNode('default_map_id')->defaultNull()->end()
51-
->end()
52-
->end()
46+
->scalarNode('renderer')->defaultNull()->end()
47+
->arrayNode('google_maps')
48+
->addDefaultsIfNotSet()
49+
->children()
50+
->scalarNode('default_map_id')->defaultNull()->end()
51+
->end()
52+
->end()
5353
->end()
5454
;
5555
}

0 commit comments

Comments
 (0)