|
|
|
|
@@ -11,9 +11,11 @@
|
|
|
|
|
|
|
|
|
|
namespace Symfony\UX\Map\Bridge\Google\Tests;
|
|
|
|
|
|
|
|
|
|
use Symfony\UX\Icons\IconRendererInterface;
|
|
|
|
|
use Symfony\UX\Map\Bridge\Google\GoogleOptions;
|
|
|
|
|
use Symfony\UX\Map\Bridge\Google\Renderer\GoogleRenderer;
|
|
|
|
|
use Symfony\UX\Map\Icon\Icon;
|
|
|
|
|
use Symfony\UX\Map\Icon\UxIconRenderer;
|
|
|
|
|
use Symfony\UX\Map\InfoWindow;
|
|
|
|
|
use Symfony\UX\Map\Map;
|
|
|
|
|
use Symfony\UX\Map\Marker;
|
|
|
|
|
@@ -31,31 +33,31 @@ class GoogleRendererTest extends RendererTestCase
|
|
|
|
|
->center(new Point(48.8566, 2.3522))
|
|
|
|
|
->zoom(12);
|
|
|
|
|
$marker1 = new Marker(position: new Point(48.8566, 2.3522), title: 'Paris', id: 'marker1');
|
|
|
|
|
$marker2 = new Marker(position: new Point(48.8566, 2.3522), title: 'Lyon', infoWindow: new InfoWindow(content: 'Lyon'), id: 'marker2', icon: Icon::svg(html: '<svg></svg>'));
|
|
|
|
|
$marker2 = new Marker(position: new Point(48.8566, 2.3522), title: 'Lyon', infoWindow: new InfoWindow(content: 'Lyon'), id: 'marker2');
|
|
|
|
|
$marker3 = new Marker(position: new Point(45.8566, 2.3522), title: 'Dijon', id: 'marker3');
|
|
|
|
|
|
|
|
|
|
yield 'simple map, with minimum options' => [
|
|
|
|
|
'expected_render' => '<div data-controller="symfony--ux-google-map--map" data-symfony--ux-google-map--map-provider-options-value="{"apiKey":"api_key"}" data-symfony--ux-google-map--map-center-value="{"lat":48.8566,"lng":2.3522}" data-symfony--ux-google-map--map-zoom-value="12" data-symfony--ux-google-map--map-fit-bounds-to-markers-value="false" data-symfony--ux-google-map--map-options-value="{"mapId":null,"gestureHandling":"auto","backgroundColor":null,"disableDoubleClickZoom":false,"zoomControlOptions":{"position":22},"mapTypeControlOptions":{"mapTypeIds":[],"position":14,"style":0},"streetViewControlOptions":{"position":22},"fullscreenControlOptions":{"position":20},"@provider":"google"}" data-symfony--ux-google-map--map-markers-value="[]" data-symfony--ux-google-map--map-polygons-value="[]" data-symfony--ux-google-map--map-polylines-value="[]"></div>',
|
|
|
|
|
'renderer' => new GoogleRenderer(new StimulusHelper(null), apiKey: 'api_key'),
|
|
|
|
|
'renderer' => new GoogleRenderer(new StimulusHelper(null), new UxIconRenderer(null), apiKey: 'api_key'),
|
|
|
|
|
'map' => $map,
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
yield 'with every options' => [
|
|
|
|
|
'expected_render' => '<div data-controller="symfony--ux-google-map--map" data-symfony--ux-google-map--map-provider-options-value="{"id":"gmap","language":"fr","region":"FR","nonce":"abcd","retries":10,"url":"https:\/\/maps.googleapis.com\/maps\/api\/js","version":"quarterly","apiKey":"api_key"}" data-symfony--ux-google-map--map-center-value="{"lat":48.8566,"lng":2.3522}" data-symfony--ux-google-map--map-zoom-value="12" data-symfony--ux-google-map--map-fit-bounds-to-markers-value="false" data-symfony--ux-google-map--map-options-value="{"mapId":null,"gestureHandling":"auto","backgroundColor":null,"disableDoubleClickZoom":false,"zoomControlOptions":{"position":22},"mapTypeControlOptions":{"mapTypeIds":[],"position":14,"style":0},"streetViewControlOptions":{"position":22},"fullscreenControlOptions":{"position":20},"@provider":"google"}" data-symfony--ux-google-map--map-markers-value="[]" data-symfony--ux-google-map--map-polygons-value="[]" data-symfony--ux-google-map--map-polylines-value="[]"></div>',
|
|
|
|
|
'renderer' => new GoogleRenderer(new StimulusHelper(null), apiKey: 'api_key', id: 'gmap', language: 'fr', region: 'FR', nonce: 'abcd', retries: 10, url: 'https://maps.googleapis.com/maps/api/js', version: 'quarterly'),
|
|
|
|
|
'renderer' => new GoogleRenderer(new StimulusHelper(null), new UxIconRenderer(null), apiKey: 'api_key', id: 'gmap', language: 'fr', region: 'FR', nonce: 'abcd', retries: 10, url: 'https://maps.googleapis.com/maps/api/js', version: 'quarterly'),
|
|
|
|
|
'map' => $map,
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
yield 'with custom attributes' => [
|
|
|
|
|
'expected_render' => '<div data-controller="my-custom-controller symfony--ux-google-map--map" data-symfony--ux-google-map--map-provider-options-value="{"apiKey":"api_key"}" data-symfony--ux-google-map--map-center-value="{"lat":48.8566,"lng":2.3522}" data-symfony--ux-google-map--map-zoom-value="12" data-symfony--ux-google-map--map-fit-bounds-to-markers-value="false" data-symfony--ux-google-map--map-options-value="{"mapId":null,"gestureHandling":"auto","backgroundColor":null,"disableDoubleClickZoom":false,"zoomControlOptions":{"position":22},"mapTypeControlOptions":{"mapTypeIds":[],"position":14,"style":0},"streetViewControlOptions":{"position":22},"fullscreenControlOptions":{"position":20},"@provider":"google"}" data-symfony--ux-google-map--map-markers-value="[]" data-symfony--ux-google-map--map-polygons-value="[]" data-symfony--ux-google-map--map-polylines-value="[]" class="map"></div>',
|
|
|
|
|
'renderer' => new GoogleRenderer(new StimulusHelper(null), apiKey: 'api_key'),
|
|
|
|
|
'renderer' => new GoogleRenderer(new StimulusHelper(null), new UxIconRenderer(null), apiKey: 'api_key'),
|
|
|
|
|
'map' => $map,
|
|
|
|
|
'attributes' => ['data-controller' => 'my-custom-controller', 'class' => 'map'],
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
yield 'with markers and infoWindows' => [
|
|
|
|
|
'expected_render' => '<div data-controller="symfony--ux-google-map--map" data-symfony--ux-google-map--map-provider-options-value="{"apiKey":"api_key"}" data-symfony--ux-google-map--map-center-value="{"lat":48.8566,"lng":2.3522}" data-symfony--ux-google-map--map-zoom-value="12" data-symfony--ux-google-map--map-fit-bounds-to-markers-value="false" data-symfony--ux-google-map--map-options-value="{"mapId":null,"gestureHandling":"auto","backgroundColor":null,"disableDoubleClickZoom":false,"zoomControlOptions":{"position":22},"mapTypeControlOptions":{"mapTypeIds":[],"position":14,"style":0},"streetViewControlOptions":{"position":22},"fullscreenControlOptions":{"position":20},"@provider":"google"}" data-symfony--ux-google-map--map-markers-value="[{"position":{"lat":48.8566,"lng":2.3522},"title":"Paris","infoWindow":null,"icon":null,"extra":[],"id":"marker1","@id":"872feba9ebf3905d"},{"position":{"lat":48.8566,"lng":2.3522},"title":"Lyon","infoWindow":{"headerContent":null,"content":"Lyon","position":null,"opened":false,"autoClose":true,"extra":[]},"icon":null,"extra":[],"id":null,"@id":"bce206d73dc5c164"}]" data-symfony--ux-google-map--map-polygons-value="[]" data-symfony--ux-google-map--map-polylines-value="[]"></div>',
|
|
|
|
|
'renderer' => new GoogleRenderer(new StimulusHelper(null), apiKey: 'api_key'),
|
|
|
|
|
'renderer' => new GoogleRenderer(new StimulusHelper(null), new UxIconRenderer(null), apiKey: 'api_key'),
|
|
|
|
|
'map' => (new Map())
|
|
|
|
|
->center(new Point(48.8566, 2.3522))
|
|
|
|
|
->zoom(12)
|
|
|
|
|
@@ -65,7 +67,7 @@ class GoogleRendererTest extends RendererTestCase
|
|
|
|
|
|
|
|
|
|
yield 'with all markers removed' => [
|
|
|
|
|
'expected_render' => '<div data-controller="symfony--ux-google-map--map" data-symfony--ux-google-map--map-provider-options-value="{"apiKey":"api_key"}" data-symfony--ux-google-map--map-center-value="{"lat":48.8566,"lng":2.3522}" data-symfony--ux-google-map--map-zoom-value="12" data-symfony--ux-google-map--map-fit-bounds-to-markers-value="false" data-symfony--ux-google-map--map-options-value="{"mapId":null,"gestureHandling":"auto","backgroundColor":null,"disableDoubleClickZoom":false,"zoomControlOptions":{"position":22},"mapTypeControlOptions":{"mapTypeIds":[],"position":14,"style":0},"streetViewControlOptions":{"position":22},"fullscreenControlOptions":{"position":20},"@provider":"google"}" data-symfony--ux-google-map--map-markers-value="[]" data-symfony--ux-google-map--map-polygons-value="[]" data-symfony--ux-google-map--map-polylines-value="[]"></div>',
|
|
|
|
|
'renderer' => new GoogleRenderer(new StimulusHelper(null), apiKey: 'api_key'),
|
|
|
|
|
'renderer' => new GoogleRenderer(new StimulusHelper(null), new UxIconRenderer(null), apiKey: 'api_key'),
|
|
|
|
|
'map' => (new Map())
|
|
|
|
|
->center(new Point(48.8566, 2.3522))
|
|
|
|
|
->zoom(12)
|
|
|
|
|
@@ -76,8 +78,8 @@ class GoogleRendererTest extends RendererTestCase
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
yield 'with marker remove and new ones added' => [
|
|
|
|
|
'expected_render' => '<div data-controller="symfony--ux-google-map--map" data-symfony--ux-google-map--map-provider-options-value="{"apiKey":"api_key"}" data-symfony--ux-google-map--map-center-value="{"lat":48.8566,"lng":2.3522}" data-symfony--ux-google-map--map-zoom-value="12" data-symfony--ux-google-map--map-fit-bounds-to-markers-value="false" data-symfony--ux-google-map--map-options-value="{"mapId":null,"gestureHandling":"auto","backgroundColor":null,"disableDoubleClickZoom":false,"zoomControlOptions":{"position":22},"mapTypeControlOptions":{"mapTypeIds":[],"position":14,"style":0},"streetViewControlOptions":{"position":22},"fullscreenControlOptions":{"position":20},"@provider":"google"}" data-symfony--ux-google-map--map-markers-value="[{"position":{"lat":48.8566,"lng":2.3522},"title":"Paris","infoWindow":null,"icon":null,"extra":[],"id":"marker1","@id":"872feba9ebf3905d"},{"position":{"lat":48.8566,"lng":2.3522},"title":"Lyon","infoWindow":{"headerContent":null,"content":"Lyon","position":null,"opened":false,"autoClose":true,"extra":[]},"icon":{"content":"<svg><\/svg>","type":"inline-svg","width":24,"height":24},"extra":[],"id":"marker2","@id":"414a0455a0c33cf0"}]" data-symfony--ux-google-map--map-polygons-value="[]" data-symfony--ux-google-map--map-polylines-value="[]"></div>',
|
|
|
|
|
'renderer' => new GoogleRenderer(new StimulusHelper(null), apiKey: 'api_key'),
|
|
|
|
|
'expected_render' => '<div data-controller="symfony--ux-google-map--map" data-symfony--ux-google-map--map-provider-options-value="{"apiKey":"api_key"}" data-symfony--ux-google-map--map-center-value="{"lat":48.8566,"lng":2.3522}" data-symfony--ux-google-map--map-zoom-value="12" data-symfony--ux-google-map--map-fit-bounds-to-markers-value="false" data-symfony--ux-google-map--map-options-value="{"mapId":null,"gestureHandling":"auto","backgroundColor":null,"disableDoubleClickZoom":false,"zoomControlOptions":{"position":22},"mapTypeControlOptions":{"mapTypeIds":[],"position":14,"style":0},"streetViewControlOptions":{"position":22},"fullscreenControlOptions":{"position":20},"@provider":"google"}" data-symfony--ux-google-map--map-markers-value="[{"position":{"lat":48.8566,"lng":2.3522},"title":"Paris","infoWindow":null,"icon":null,"extra":[],"id":"marker1","@id":"872feba9ebf3905d"},{"position":{"lat":48.8566,"lng":2.3522},"title":"Lyon","infoWindow":{"headerContent":null,"content":"Lyon","position":null,"opened":false,"autoClose":true,"extra":[]},"icon":null,"extra":[],"id":"marker2","@id":"6028bf5e41f644ab"}]" data-symfony--ux-google-map--map-polygons-value="[]" data-symfony--ux-google-map--map-polylines-value="[]"></div>',
|
|
|
|
|
'renderer' => new GoogleRenderer(new StimulusHelper(null), new UxIconRenderer(null), apiKey: 'api_key'),
|
|
|
|
|
'map' => (new Map())
|
|
|
|
|
->center(new Point(48.8566, 2.3522))
|
|
|
|
|
->zoom(12)
|
|
|
|
|
@@ -89,7 +91,7 @@ class GoogleRendererTest extends RendererTestCase
|
|
|
|
|
|
|
|
|
|
yield 'with polygons and infoWindows' => [
|
|
|
|
|
'expected_render' => '<div data-controller="symfony--ux-google-map--map" data-symfony--ux-google-map--map-provider-options-value="{"apiKey":"api_key"}" data-symfony--ux-google-map--map-center-value="{"lat":48.8566,"lng":2.3522}" data-symfony--ux-google-map--map-zoom-value="12" data-symfony--ux-google-map--map-fit-bounds-to-markers-value="false" data-symfony--ux-google-map--map-options-value="{"mapId":null,"gestureHandling":"auto","backgroundColor":null,"disableDoubleClickZoom":false,"zoomControlOptions":{"position":22},"mapTypeControlOptions":{"mapTypeIds":[],"position":14,"style":0},"streetViewControlOptions":{"position":22},"fullscreenControlOptions":{"position":20},"@provider":"google"}" data-symfony--ux-google-map--map-markers-value="[]" data-symfony--ux-google-map--map-polygons-value="[{"points":[{"lat":48.8566,"lng":2.3522},{"lat":48.8566,"lng":2.3522},{"lat":48.8566,"lng":2.3522}],"title":null,"infoWindow":null,"extra":[],"id":null,"@id":"7cdd432ea54d0ce9"},{"points":[{"lat":1.1,"lng":2.2},{"lat":3.3,"lng":4.4},{"lat":5.5,"lng":6.6}],"title":null,"infoWindow":{"headerContent":null,"content":"Polygon","position":null,"opened":false,"autoClose":true,"extra":[]},"extra":[],"id":null,"@id":"9074e0a9ead08c1e"}]" data-symfony--ux-google-map--map-polylines-value="[]"></div>',
|
|
|
|
|
'renderer' => new GoogleRenderer(new StimulusHelper(null), apiKey: 'api_key'),
|
|
|
|
|
'renderer' => new GoogleRenderer(new StimulusHelper(null), new UxIconRenderer(null), apiKey: 'api_key'),
|
|
|
|
|
'map' => (new Map())
|
|
|
|
|
->center(new Point(48.8566, 2.3522))
|
|
|
|
|
->zoom(12)
|
|
|
|
|
@@ -99,7 +101,7 @@ class GoogleRendererTest extends RendererTestCase
|
|
|
|
|
|
|
|
|
|
yield 'with polylines and infoWindows' => [
|
|
|
|
|
'expected_render' => '<div data-controller="symfony--ux-google-map--map" data-symfony--ux-google-map--map-provider-options-value="{"apiKey":"api_key"}" data-symfony--ux-google-map--map-center-value="{"lat":48.8566,"lng":2.3522}" data-symfony--ux-google-map--map-zoom-value="12" data-symfony--ux-google-map--map-fit-bounds-to-markers-value="false" data-symfony--ux-google-map--map-options-value="{"mapId":null,"gestureHandling":"auto","backgroundColor":null,"disableDoubleClickZoom":false,"zoomControlOptions":{"position":22},"mapTypeControlOptions":{"mapTypeIds":[],"position":14,"style":0},"streetViewControlOptions":{"position":22},"fullscreenControlOptions":{"position":20},"@provider":"google"}" data-symfony--ux-google-map--map-markers-value="[]" data-symfony--ux-google-map--map-polygons-value="[]" data-symfony--ux-google-map--map-polylines-value="[{"points":[{"lat":48.8566,"lng":2.3522},{"lat":48.8566,"lng":2.3522},{"lat":48.8566,"lng":2.3522}],"title":null,"infoWindow":null,"extra":[],"id":null,"@id":"7cdd432ea54d0ce9"},{"points":[{"lat":1.1,"lng":2.2},{"lat":3.3,"lng":4.4},{"lat":5.5,"lng":6.6}],"title":null,"infoWindow":{"headerContent":null,"content":"Polygon","position":null,"opened":false,"autoClose":true,"extra":[]},"extra":[],"id":null,"@id":"9074e0a9ead08c1e"}]"></div>',
|
|
|
|
|
'renderer' => new GoogleRenderer(new StimulusHelper(null), apiKey: 'api_key'),
|
|
|
|
|
'renderer' => new GoogleRenderer(new StimulusHelper(null), new UxIconRenderer(null), apiKey: 'api_key'),
|
|
|
|
|
'map' => (new Map())
|
|
|
|
|
->center(new Point(48.8566, 2.3522))
|
|
|
|
|
->zoom(12)
|
|
|
|
|
@@ -109,7 +111,7 @@ class GoogleRendererTest extends RendererTestCase
|
|
|
|
|
|
|
|
|
|
yield 'with controls enabled' => [
|
|
|
|
|
'expected_render' => '<div data-controller="symfony--ux-google-map--map" data-symfony--ux-google-map--map-provider-options-value="{"apiKey":"api_key"}" data-symfony--ux-google-map--map-center-value="{"lat":48.8566,"lng":2.3522}" data-symfony--ux-google-map--map-zoom-value="12" data-symfony--ux-google-map--map-fit-bounds-to-markers-value="false" data-symfony--ux-google-map--map-options-value="{"mapId":null,"gestureHandling":"auto","backgroundColor":null,"disableDoubleClickZoom":false,"zoomControlOptions":{"position":22},"mapTypeControlOptions":{"mapTypeIds":[],"position":14,"style":0},"streetViewControlOptions":{"position":22},"fullscreenControlOptions":{"position":20},"@provider":"google"}" data-symfony--ux-google-map--map-markers-value="[]" data-symfony--ux-google-map--map-polygons-value="[]" data-symfony--ux-google-map--map-polylines-value="[]"></div>',
|
|
|
|
|
'renderer' => new GoogleRenderer(new StimulusHelper(null), apiKey: 'api_key'),
|
|
|
|
|
'renderer' => new GoogleRenderer(new StimulusHelper(null), new UxIconRenderer(null), apiKey: 'api_key'),
|
|
|
|
|
'map' => (new Map())
|
|
|
|
|
->center(new Point(48.8566, 2.3522))
|
|
|
|
|
->zoom(12)
|
|
|
|
|
@@ -123,7 +125,7 @@ class GoogleRendererTest extends RendererTestCase
|
|
|
|
|
|
|
|
|
|
yield 'without controls enabled' => [
|
|
|
|
|
'expected_render' => '<div data-controller="symfony--ux-google-map--map" data-symfony--ux-google-map--map-provider-options-value="{"apiKey":"api_key"}" data-symfony--ux-google-map--map-center-value="{"lat":48.8566,"lng":2.3522}" data-symfony--ux-google-map--map-zoom-value="12" data-symfony--ux-google-map--map-fit-bounds-to-markers-value="false" data-symfony--ux-google-map--map-options-value="{"mapId":null,"gestureHandling":"auto","backgroundColor":null,"disableDoubleClickZoom":false,"@provider":"google"}" data-symfony--ux-google-map--map-markers-value="[]" data-symfony--ux-google-map--map-polygons-value="[]" data-symfony--ux-google-map--map-polylines-value="[]"></div>',
|
|
|
|
|
'renderer' => new GoogleRenderer(new StimulusHelper(null), apiKey: 'api_key'),
|
|
|
|
|
'renderer' => new GoogleRenderer(new StimulusHelper(null), new UxIconRenderer(null), apiKey: 'api_key'),
|
|
|
|
|
'map' => (new Map())
|
|
|
|
|
->center(new Point(48.8566, 2.3522))
|
|
|
|
|
->zoom(12)
|
|
|
|
|
@@ -136,27 +138,49 @@ class GoogleRendererTest extends RendererTestCase
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
yield 'with default map id' => [
|
|
|
|
|
'expected_renderer' => '<div data-controller="symfony--ux-google-map--map" data-symfony--ux-google-map--map-provider-options-value="{"apiKey":"my_api_key"}" data-symfony--ux-google-map--map-center-value="{"lat":48.8566,"lng":2.3522}" data-symfony--ux-google-map--map-zoom-value="12" data-symfony--ux-google-map--map-fit-bounds-to-markers-value="false" data-symfony--ux-google-map--map-options-value="{"mapId":"DefaultMapId","gestureHandling":"auto","backgroundColor":null,"disableDoubleClickZoom":false,"zoomControlOptions":{"position":22},"mapTypeControlOptions":{"mapTypeIds":[],"position":14,"style":0},"streetViewControlOptions":{"position":22},"fullscreenControlOptions":{"position":20},"@provider":"google"}" data-symfony--ux-google-map--map-markers-value="[]" data-symfony--ux-google-map--map-polygons-value="[]" data-symfony--ux-google-map--map-polylines-value="[]"></div>',
|
|
|
|
|
'renderer' => new GoogleRenderer(new StimulusHelper(null), 'my_api_key', defaultMapId: 'DefaultMapId'),
|
|
|
|
|
'expected_render' => '<div data-controller="symfony--ux-google-map--map" data-symfony--ux-google-map--map-provider-options-value="{"apiKey":"my_api_key"}" data-symfony--ux-google-map--map-center-value="{"lat":48.8566,"lng":2.3522}" data-symfony--ux-google-map--map-zoom-value="12" data-symfony--ux-google-map--map-fit-bounds-to-markers-value="false" data-symfony--ux-google-map--map-options-value="{"mapId":"DefaultMapId","gestureHandling":"auto","backgroundColor":null,"disableDoubleClickZoom":false,"zoomControlOptions":{"position":22},"mapTypeControlOptions":{"mapTypeIds":[],"position":14,"style":0},"streetViewControlOptions":{"position":22},"fullscreenControlOptions":{"position":20},"@provider":"google"}" data-symfony--ux-google-map--map-markers-value="[]" data-symfony--ux-google-map--map-polygons-value="[]" data-symfony--ux-google-map--map-polylines-value="[]"></div>',
|
|
|
|
|
'renderer' => new GoogleRenderer(new StimulusHelper(null), new UxIconRenderer(null), 'my_api_key', defaultMapId: 'DefaultMapId'),
|
|
|
|
|
'map' => (new Map())
|
|
|
|
|
->center(new Point(48.8566, 2.3522))
|
|
|
|
|
->zoom(12),
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
yield 'with default map id, when passing options (except the "mapId")' => [
|
|
|
|
|
'expected_renderer' => '<div data-controller="symfony--ux-google-map--map" data-symfony--ux-google-map--map-provider-options-value="{"apiKey":"my_api_key"}" data-symfony--ux-google-map--map-center-value="{"lat":48.8566,"lng":2.3522}" data-symfony--ux-google-map--map-zoom-value="12" data-symfony--ux-google-map--map-fit-bounds-to-markers-value="false" data-symfony--ux-google-map--map-options-value="{"mapId":"DefaultMapId","gestureHandling":"auto","backgroundColor":null,"disableDoubleClickZoom":false,"zoomControlOptions":{"position":22},"mapTypeControlOptions":{"mapTypeIds":[],"position":14,"style":0},"streetViewControlOptions":{"position":22},"fullscreenControlOptions":{"position":20},"@provider":"google"}" data-symfony--ux-google-map--map-markers-value="[]" data-symfony--ux-google-map--map-polygons-value="[]" data-symfony--ux-google-map--map-polylines-value="[]"></div>',
|
|
|
|
|
'renderer' => new GoogleRenderer(new StimulusHelper(null), 'my_api_key', defaultMapId: 'DefaultMapId'),
|
|
|
|
|
'expected_render' => '<div data-controller="symfony--ux-google-map--map" data-symfony--ux-google-map--map-provider-options-value="{"apiKey":"my_api_key"}" data-symfony--ux-google-map--map-center-value="{"lat":48.8566,"lng":2.3522}" data-symfony--ux-google-map--map-zoom-value="12" data-symfony--ux-google-map--map-fit-bounds-to-markers-value="false" data-symfony--ux-google-map--map-options-value="{"mapId":"DefaultMapId","gestureHandling":"auto","backgroundColor":null,"disableDoubleClickZoom":false,"zoomControlOptions":{"position":22},"mapTypeControlOptions":{"mapTypeIds":[],"position":14,"style":0},"streetViewControlOptions":{"position":22},"fullscreenControlOptions":{"position":20},"@provider":"google"}" data-symfony--ux-google-map--map-markers-value="[]" data-symfony--ux-google-map--map-polygons-value="[]" data-symfony--ux-google-map--map-polylines-value="[]"></div>',
|
|
|
|
|
'renderer' => new GoogleRenderer(new StimulusHelper(null), new UxIconRenderer(null), 'my_api_key', defaultMapId: 'DefaultMapId'),
|
|
|
|
|
'map' => (new Map())
|
|
|
|
|
->center(new Point(48.8566, 2.3522))
|
|
|
|
|
->zoom(12)
|
|
|
|
|
->options(new GoogleOptions()),
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
yield 'with default map id overridden by option "mapId"' => [
|
|
|
|
|
'expected_renderer' => '<div data-controller="symfony--ux-google-map--map" data-symfony--ux-google-map--map-provider-options-value="{"apiKey":"my_api_key"}" data-symfony--ux-google-map--map-center-value="{"lat":48.8566,"lng":2.3522}" data-symfony--ux-google-map--map-zoom-value="12" data-symfony--ux-google-map--map-fit-bounds-to-markers-value="false" data-symfony--ux-google-map--map-options-value="{"mapId":"CustomMapId","gestureHandling":"auto","backgroundColor":null,"disableDoubleClickZoom":false,"zoomControlOptions":{"position":22},"mapTypeControlOptions":{"mapTypeIds":[],"position":14,"style":0},"streetViewControlOptions":{"position":22},"fullscreenControlOptions":{"position":20},"@provider":"google"}" data-symfony--ux-google-map--map-markers-value="[]" data-symfony--ux-google-map--map-polygons-value="[]" data-symfony--ux-google-map--map-polylines-value="[]"></div>',
|
|
|
|
|
'renderer' => new GoogleRenderer(new StimulusHelper(null), 'my_api_key', defaultMapId: 'DefaultMapId'),
|
|
|
|
|
'expected_render' => '<div data-controller="symfony--ux-google-map--map" data-symfony--ux-google-map--map-provider-options-value="{"apiKey":"my_api_key"}" data-symfony--ux-google-map--map-center-value="{"lat":48.8566,"lng":2.3522}" data-symfony--ux-google-map--map-zoom-value="12" data-symfony--ux-google-map--map-fit-bounds-to-markers-value="false" data-symfony--ux-google-map--map-options-value="{"mapId":"CustomMapId","gestureHandling":"auto","backgroundColor":null,"disableDoubleClickZoom":false,"zoomControlOptions":{"position":22},"mapTypeControlOptions":{"mapTypeIds":[],"position":14,"style":0},"streetViewControlOptions":{"position":22},"fullscreenControlOptions":{"position":20},"@provider":"google"}" data-symfony--ux-google-map--map-markers-value="[]" data-symfony--ux-google-map--map-polygons-value="[]" data-symfony--ux-google-map--map-polylines-value="[]"></div>',
|
|
|
|
|
'renderer' => new GoogleRenderer(new StimulusHelper(null), new UxIconRenderer(null), 'my_api_key', defaultMapId: 'DefaultMapId'),
|
|
|
|
|
'map' => (new Map())
|
|
|
|
|
->center(new Point(48.8566, 2.3522))
|
|
|
|
|
->zoom(12)
|
|
|
|
|
->options(new GoogleOptions(mapId: 'CustomMapId')),
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
yield 'markers with icons' => [
|
|
|
|
|
'expected_render' => '<div data-controller="symfony--ux-google-map--map" data-symfony--ux-google-map--map-provider-options-value="{"apiKey":"my_api_key"}" data-symfony--ux-google-map--map-center-value="{"lat":48.8566,"lng":2.3522}" data-symfony--ux-google-map--map-zoom-value="12" data-symfony--ux-google-map--map-fit-bounds-to-markers-value="false" data-symfony--ux-google-map--map-options-value="{"mapId":null,"gestureHandling":"auto","backgroundColor":null,"disableDoubleClickZoom":false,"zoomControlOptions":{"position":22},"mapTypeControlOptions":{"mapTypeIds":[],"position":14,"style":0},"streetViewControlOptions":{"position":22},"fullscreenControlOptions":{"position":20},"@provider":"google"}" data-symfony--ux-google-map--map-markers-value="[{"position":{"lat":48.8566,"lng":2.3522},"title":"Paris","infoWindow":null,"icon":{"type":"url","width":32,"height":32,"url":"https:\/\/cdn.jsdelivr.net\/npm\/bootstrap-icons@1.11.3\/icons\/geo-alt.svg"},"extra":[],"id":null,"@id":"217fa57668ad8e64"},{"position":{"lat":45.764,"lng":4.8357},"title":"Lyon","infoWindow":null,"icon":{"type":"ux-icon","width":32,"height":32,"name":"fa:map-marker","_generated_html":"<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"24\" height=\"24\">...<\/svg>"},"extra":[],"id":null,"@id":"255b208136900fc0"},{"position":{"lat":45.8566,"lng":2.3522},"title":"Dijon","infoWindow":null,"icon":{"type":"svg","width":24,"height":24,"html":"<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"24\" height=\"24\">...<\/svg>"},"extra":[],"id":null,"@id":"1a410e92214f770c"}]" data-symfony--ux-google-map--map-polygons-value="[]" data-symfony--ux-google-map--map-polylines-value="[]"></div>',
|
|
|
|
|
'renderer' => new GoogleRenderer(
|
|
|
|
|
new StimulusHelper(null),
|
|
|
|
|
new UxIconRenderer(new class implements IconRendererInterface {
|
|
|
|
|
public function renderIcon(string $name, array $attributes = []): string
|
|
|
|
|
{
|
|
|
|
|
return '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24">...</svg>';
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
'my_api_key'
|
|
|
|
|
),
|
|
|
|
|
'map' => (new Map())
|
|
|
|
|
->center(new Point(48.8566, 2.3522))
|
|
|
|
|
->zoom(12)
|
|
|
|
|
->addMarker(new Marker(position: new Point(48.8566, 2.3522), title: 'Paris', icon: Icon::url('https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/icons/geo-alt.svg')->width(32)->height(32)))
|
|
|
|
|
->addMarker(new Marker(position: new Point(45.7640, 4.8357), title: 'Lyon', icon: Icon::ux('fa:map-marker')->width(32)->height(32)))
|
|
|
|
|
->addMarker(new Marker(position: new Point(45.8566, 2.3522), title: 'Dijon', icon: Icon::svg('<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24">...</svg>'))),
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|