@symfony/ux-google-map 2.36.1 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/map_controller.d.ts +2 -12
- package/dist/map_controller.js +18 -59
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ npm add @symfony/ux-google-map@2.23.0
|
|
|
19
19
|
|
|
20
20
|
## Resources
|
|
21
21
|
|
|
22
|
-
- [Documentation](https://github.com/symfony/ux/tree/
|
|
22
|
+
- [Documentation](https://github.com/symfony/ux/tree/3.x/src/Map/src/Bridge/Google)
|
|
23
23
|
- [Report issues](https://github.com/symfony/ux/issues) and
|
|
24
24
|
[send Pull Requests](https://github.com/symfony/ux/pulls)
|
|
25
25
|
in the [main Symfony UX repository](https://github.com/symfony/ux)
|
package/dist/map_controller.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { APIOptions } from "@googlemaps/js-api-loader";
|
|
2
2
|
import { Controller } from "@hotwired/stimulus";
|
|
3
3
|
type Point = {
|
|
4
4
|
lat: number;
|
|
@@ -42,23 +42,18 @@ type MarkerDefinition<BridgeMarkerOptions, BridgeInfoWindowOptions> = WithIdenti
|
|
|
42
42
|
title: string | null;
|
|
43
43
|
infoWindow?: Omit<InfoWindowDefinition<BridgeInfoWindowOptions>, 'position'>;
|
|
44
44
|
icon?: Icon;
|
|
45
|
-
rawOptions?: BridgeMarkerOptions;
|
|
46
45
|
bridgeOptions?: BridgeMarkerOptions;
|
|
47
46
|
extra: ExtraData;
|
|
48
47
|
}>;
|
|
49
48
|
type PolygonDefinition<BridgePolygonOptions, BridgeInfoWindowOptions> = WithIdentifier<{
|
|
50
49
|
infoWindow?: Omit<InfoWindowDefinition<BridgeInfoWindowOptions>, 'position'>;
|
|
51
50
|
points: Array<Point> | Array<Array<Point>>;
|
|
52
|
-
title: string | null;
|
|
53
|
-
rawOptions?: BridgePolygonOptions;
|
|
54
51
|
bridgeOptions?: BridgePolygonOptions;
|
|
55
52
|
extra: ExtraData;
|
|
56
53
|
}>;
|
|
57
54
|
type PolylineDefinition<BridgePolylineOptions, BridgeInfoWindowOptions> = WithIdentifier<{
|
|
58
55
|
infoWindow?: Omit<InfoWindowDefinition<BridgeInfoWindowOptions>, 'position'>;
|
|
59
56
|
points: Array<Point>;
|
|
60
|
-
title: string | null;
|
|
61
|
-
rawOptions?: BridgePolylineOptions;
|
|
62
57
|
bridgeOptions?: BridgePolylineOptions;
|
|
63
58
|
extra: ExtraData;
|
|
64
59
|
}>;
|
|
@@ -66,8 +61,6 @@ type CircleDefinition<BridgeCircleOptions, BridgeInfoWindowOptions> = WithIdenti
|
|
|
66
61
|
infoWindow?: Omit<InfoWindowDefinition<BridgeInfoWindowOptions>, 'position'>;
|
|
67
62
|
center: Point;
|
|
68
63
|
radius: number;
|
|
69
|
-
title: string | null;
|
|
70
|
-
rawOptions?: BridgeCircleOptions;
|
|
71
64
|
bridgeOptions?: BridgeCircleOptions;
|
|
72
65
|
extra: ExtraData;
|
|
73
66
|
}>;
|
|
@@ -75,8 +68,6 @@ type RectangleDefinition<BridgeRectangleOptions, BridgeInfoWindowOptions> = With
|
|
|
75
68
|
infoWindow?: Omit<InfoWindowDefinition<BridgeInfoWindowOptions>, 'position'>;
|
|
76
69
|
southWest: Point;
|
|
77
70
|
northEast: Point;
|
|
78
|
-
title: string | null;
|
|
79
|
-
rawOptions?: BridgeRectangleOptions;
|
|
80
71
|
bridgeOptions?: BridgeRectangleOptions;
|
|
81
72
|
extra: ExtraData;
|
|
82
73
|
}>;
|
|
@@ -86,7 +77,6 @@ type InfoWindowDefinition<BridgeInfoWindowOptions> = {
|
|
|
86
77
|
position: Point;
|
|
87
78
|
opened: boolean;
|
|
88
79
|
autoClose: boolean;
|
|
89
|
-
rawOptions?: BridgeInfoWindowOptions;
|
|
90
80
|
bridgeOptions?: BridgeInfoWindowOptions;
|
|
91
81
|
extra: ExtraData;
|
|
92
82
|
};
|
|
@@ -216,7 +206,7 @@ declare abstract class export_default$1<MapOptions, BridgeMapOptions, BridgeMap,
|
|
|
216
206
|
}
|
|
217
207
|
type MapOptions = Pick<google.maps.MapOptions, 'mapId' | 'gestureHandling' | 'backgroundColor' | 'disableDoubleClickZoom' | 'zoomControl' | 'zoomControlOptions' | 'mapTypeControl' | 'mapTypeControlOptions' | 'streetViewControl' | 'streetViewControlOptions' | 'fullscreenControl' | 'fullscreenControlOptions'>;
|
|
218
208
|
declare class export_default extends export_default$1<MapOptions, google.maps.MapOptions, google.maps.Map, google.maps.marker.AdvancedMarkerElementOptions, google.maps.marker.AdvancedMarkerElement, google.maps.InfoWindowOptions, google.maps.InfoWindow, google.maps.PolygonOptions, google.maps.Polygon, google.maps.PolylineOptions, google.maps.Polyline, google.maps.CircleOptions, google.maps.Circle, google.maps.RectangleOptions, google.maps.Rectangle> {
|
|
219
|
-
providerOptionsValue: Pick<
|
|
209
|
+
providerOptionsValue: Pick<APIOptions, 'key' | 'v' | 'language' | 'region' | 'libraries' | 'authReferrerPolicy' | 'mapIds' | 'channel' | 'solutionChannel'>;
|
|
220
210
|
map: google.maps.Map;
|
|
221
211
|
connect(): Promise<void>;
|
|
222
212
|
centerValueChanged(): void;
|
package/dist/map_controller.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { importLibrary, setOptions } from "@googlemaps/js-api-loader";
|
|
2
2
|
import { Controller } from "@hotwired/stimulus";
|
|
3
3
|
const IconTypes = {
|
|
4
4
|
Url: "url",
|
|
@@ -104,7 +104,6 @@ var _Class = class extends Controller {
|
|
|
104
104
|
const eventAfter = `${type}:after-create`;
|
|
105
105
|
return ({ definition }) => {
|
|
106
106
|
this.dispatchEvent(eventBefore, { definition });
|
|
107
|
-
if (typeof definition.rawOptions !== "undefined") console.warn(`[Symfony UX Map] The event "${eventBefore}" added a deprecated "rawOptions" property to the definition, it will be removed in a next major version, replace it with "bridgeOptions" instead.`, definition);
|
|
108
107
|
const drawing = factory({ definition });
|
|
109
108
|
this.dispatchEvent(eventAfter, {
|
|
110
109
|
[type]: drawing,
|
|
@@ -143,7 +142,6 @@ _Class.values = {
|
|
|
143
142
|
options: Object,
|
|
144
143
|
extra: Object
|
|
145
144
|
};
|
|
146
|
-
let _google;
|
|
147
145
|
let _loading = false;
|
|
148
146
|
let _loaded = false;
|
|
149
147
|
let _onLoadedCallbacks = [];
|
|
@@ -160,26 +158,10 @@ var map_controller_default = class extends _Class {
|
|
|
160
158
|
return;
|
|
161
159
|
}
|
|
162
160
|
_loading = true;
|
|
163
|
-
_google = { maps: {} };
|
|
164
161
|
let { libraries = [], ...loaderOptions } = this.providerOptionsValue;
|
|
165
|
-
|
|
162
|
+
setOptions(loaderOptions);
|
|
166
163
|
libraries = ["core", ...libraries.filter((library) => library !== "core")];
|
|
167
|
-
|
|
168
|
-
if (typeof libraryImplementation !== "object" || libraryImplementation === null) return;
|
|
169
|
-
const library = libraries[index];
|
|
170
|
-
if ([
|
|
171
|
-
"marker",
|
|
172
|
-
"places",
|
|
173
|
-
"geometry",
|
|
174
|
-
"journeySharing",
|
|
175
|
-
"drawing",
|
|
176
|
-
"visualization"
|
|
177
|
-
].includes(library)) _google.maps[library] = libraryImplementation;
|
|
178
|
-
else _google.maps = {
|
|
179
|
-
..._google.maps,
|
|
180
|
-
...libraryImplementation
|
|
181
|
-
};
|
|
182
|
-
});
|
|
164
|
+
await Promise.all(libraries.map((library) => importLibrary(library)));
|
|
183
165
|
_loading = false;
|
|
184
166
|
_loaded = true;
|
|
185
167
|
onLoaded();
|
|
@@ -201,7 +183,7 @@ var map_controller_default = class extends _Class {
|
|
|
201
183
|
if (this.map && this.hasMaxZoomValue && this.maxZoomValue) this.map.setOptions({ maxZoom: this.maxZoomValue });
|
|
202
184
|
}
|
|
203
185
|
dispatchEvent(name, payload = {}) {
|
|
204
|
-
payload.google =
|
|
186
|
+
payload.google = google;
|
|
205
187
|
this.dispatch(name, {
|
|
206
188
|
prefix: "ux:map",
|
|
207
189
|
detail: payload
|
|
@@ -213,7 +195,7 @@ var map_controller_default = class extends _Class {
|
|
|
213
195
|
options.mapTypeControl = typeof options.mapTypeControlOptions !== "undefined";
|
|
214
196
|
options.streetViewControl = typeof options.streetViewControlOptions !== "undefined";
|
|
215
197
|
options.fullscreenControl = typeof options.fullscreenControlOptions !== "undefined";
|
|
216
|
-
return new
|
|
198
|
+
return new google.maps.Map(this.element, {
|
|
217
199
|
center,
|
|
218
200
|
zoom,
|
|
219
201
|
minZoom,
|
|
@@ -223,12 +205,11 @@ var map_controller_default = class extends _Class {
|
|
|
223
205
|
});
|
|
224
206
|
}
|
|
225
207
|
doCreateMarker({ definition }) {
|
|
226
|
-
const { "@id": _id, position, title, infoWindow, icon,
|
|
227
|
-
const marker = new
|
|
208
|
+
const { "@id": _id, position, title, infoWindow, icon, bridgeOptions = {} } = definition;
|
|
209
|
+
const marker = new google.maps.marker.AdvancedMarkerElement({
|
|
228
210
|
position,
|
|
229
211
|
title,
|
|
230
212
|
map: this.map,
|
|
231
|
-
...rawOptions,
|
|
232
213
|
...bridgeOptions
|
|
233
214
|
});
|
|
234
215
|
if (infoWindow) this.createInfoWindow({
|
|
@@ -237,7 +218,6 @@ var map_controller_default = class extends _Class {
|
|
|
237
218
|
});
|
|
238
219
|
if (icon) {
|
|
239
220
|
if (Object.prototype.hasOwnProperty.call(bridgeOptions, "content")) console.warn("[Symfony UX Map] Defining \"bridgeOptions.content\" for a marker with a custom icon is not supported and will be ignored.");
|
|
240
|
-
else if (Object.prototype.hasOwnProperty.call(rawOptions, "content")) console.warn("[Symfony UX Map] Defining \"rawOptions.content\" for a marker with a custom icon is not supported and will be ignored.");
|
|
241
221
|
this.doCreateIcon({
|
|
242
222
|
definition: icon,
|
|
243
223
|
element: marker
|
|
@@ -249,17 +229,12 @@ var map_controller_default = class extends _Class {
|
|
|
249
229
|
marker.map = null;
|
|
250
230
|
}
|
|
251
231
|
doCreatePolygon({ definition }) {
|
|
252
|
-
const { "@id": _id, points,
|
|
253
|
-
const polygon = new
|
|
232
|
+
const { "@id": _id, points, infoWindow, bridgeOptions = {} } = definition;
|
|
233
|
+
const polygon = new google.maps.Polygon({
|
|
254
234
|
paths: points,
|
|
255
235
|
map: this.map,
|
|
256
|
-
...rawOptions,
|
|
257
236
|
...bridgeOptions
|
|
258
237
|
});
|
|
259
|
-
/**
|
|
260
|
-
* @deprecated since Symfony UX Map 2.29, will be removed in 3.0
|
|
261
|
-
*/
|
|
262
|
-
if (title) polygon.set("title", title);
|
|
263
238
|
if (infoWindow) this.createInfoWindow({
|
|
264
239
|
definition: infoWindow,
|
|
265
240
|
element: polygon
|
|
@@ -270,17 +245,12 @@ var map_controller_default = class extends _Class {
|
|
|
270
245
|
polygon.setMap(null);
|
|
271
246
|
}
|
|
272
247
|
doCreatePolyline({ definition }) {
|
|
273
|
-
const { "@id": _id, points,
|
|
274
|
-
const polyline = new
|
|
248
|
+
const { "@id": _id, points, infoWindow, bridgeOptions = {} } = definition;
|
|
249
|
+
const polyline = new google.maps.Polyline({
|
|
275
250
|
path: points,
|
|
276
251
|
map: this.map,
|
|
277
|
-
...rawOptions,
|
|
278
252
|
...bridgeOptions
|
|
279
253
|
});
|
|
280
|
-
/**
|
|
281
|
-
* @deprecated since Symfony UX Map 2.29, will be removed in 3.0
|
|
282
|
-
*/
|
|
283
|
-
if (title) polyline.set("title", title);
|
|
284
254
|
if (infoWindow) this.createInfoWindow({
|
|
285
255
|
definition: infoWindow,
|
|
286
256
|
element: polyline
|
|
@@ -291,18 +261,13 @@ var map_controller_default = class extends _Class {
|
|
|
291
261
|
polyline.setMap(null);
|
|
292
262
|
}
|
|
293
263
|
doCreateCircle({ definition }) {
|
|
294
|
-
const { "@id": _id, center, radius,
|
|
295
|
-
const circle = new
|
|
264
|
+
const { "@id": _id, center, radius, infoWindow, bridgeOptions = {} } = definition;
|
|
265
|
+
const circle = new google.maps.Circle({
|
|
296
266
|
center,
|
|
297
267
|
radius,
|
|
298
268
|
map: this.map,
|
|
299
|
-
...rawOptions,
|
|
300
269
|
...bridgeOptions
|
|
301
270
|
});
|
|
302
|
-
/**
|
|
303
|
-
* @deprecated since Symfony UX Map 2.29, will be removed in 3.0
|
|
304
|
-
*/
|
|
305
|
-
if (title) circle.set("title", title);
|
|
306
271
|
if (infoWindow) this.createInfoWindow({
|
|
307
272
|
definition: infoWindow,
|
|
308
273
|
element: circle
|
|
@@ -313,17 +278,12 @@ var map_controller_default = class extends _Class {
|
|
|
313
278
|
circle.setMap(null);
|
|
314
279
|
}
|
|
315
280
|
doCreateRectangle({ definition }) {
|
|
316
|
-
const { northEast, southWest,
|
|
317
|
-
const rectangle = new
|
|
318
|
-
bounds: new
|
|
281
|
+
const { northEast, southWest, infoWindow, bridgeOptions = {} } = definition;
|
|
282
|
+
const rectangle = new google.maps.Rectangle({
|
|
283
|
+
bounds: new google.maps.LatLngBounds(southWest, northEast),
|
|
319
284
|
map: this.map,
|
|
320
|
-
...rawOptions,
|
|
321
285
|
...bridgeOptions
|
|
322
286
|
});
|
|
323
|
-
/**
|
|
324
|
-
* @deprecated since Symfony UX Map 2.29, will be removed in 3.0
|
|
325
|
-
*/
|
|
326
|
-
if (title) rectangle.set("title", title);
|
|
327
287
|
if (infoWindow) this.createInfoWindow({
|
|
328
288
|
definition: infoWindow,
|
|
329
289
|
element: rectangle
|
|
@@ -334,7 +294,7 @@ var map_controller_default = class extends _Class {
|
|
|
334
294
|
rectangle.setMap(null);
|
|
335
295
|
}
|
|
336
296
|
doCreateInfoWindow({ definition, element }) {
|
|
337
|
-
const { headerContent, content, opened, autoClose,
|
|
297
|
+
const { headerContent, content, opened, autoClose, bridgeOptions = {} } = definition;
|
|
338
298
|
let position = null;
|
|
339
299
|
if (element instanceof google.maps.Circle) position = element.getCenter();
|
|
340
300
|
else if (element instanceof google.maps.Rectangle) position = element.getBounds()?.getCenter() || null;
|
|
@@ -343,10 +303,9 @@ var map_controller_default = class extends _Class {
|
|
|
343
303
|
headerContent: this.createTextOrElement(headerContent),
|
|
344
304
|
content: this.createTextOrElement(content),
|
|
345
305
|
position,
|
|
346
|
-
...rawOptions,
|
|
347
306
|
...bridgeOptions
|
|
348
307
|
};
|
|
349
|
-
const infoWindow = new
|
|
308
|
+
const infoWindow = new google.maps.InfoWindow(infoWindowOptions);
|
|
350
309
|
element.addListener("click", (event) => {
|
|
351
310
|
if (autoClose) this.closeInfoWindowsExcept(infoWindow);
|
|
352
311
|
if (infoWindowOptions.position === null) infoWindow.setPosition(event.latLng);
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@symfony/ux-google-map",
|
|
3
3
|
"description": "GoogleMaps bridge for Symfony UX Map, integrate interactive maps in your Symfony applications",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "
|
|
5
|
+
"version": "3.1.0",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"symfony-ux",
|
|
8
8
|
"google-maps",
|
|
@@ -27,12 +27,12 @@
|
|
|
27
27
|
},
|
|
28
28
|
"importmap": {
|
|
29
29
|
"@hotwired/stimulus": "^3.0.0",
|
|
30
|
-
"@googlemaps/js-api-loader": "^
|
|
30
|
+
"@googlemaps/js-api-loader": "^2.0.0",
|
|
31
31
|
"@symfony/ux-google-map": "path:%PACKAGE%/dist/map_controller.js"
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"@googlemaps/js-api-loader": "^
|
|
35
|
+
"@googlemaps/js-api-loader": "^2.0.0",
|
|
36
36
|
"@hotwired/stimulus": "^3.0.0"
|
|
37
37
|
},
|
|
38
38
|
"peerDependenciesMeta": {
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@googlemaps/js-api-loader": "^
|
|
44
|
+
"@googlemaps/js-api-loader": "^2.0.0",
|
|
45
45
|
"@hotwired/stimulus": "^3.0.0",
|
|
46
46
|
"@testing-library/dom": "^10.4.0",
|
|
47
47
|
"@testing-library/jest-dom": "^6.6.3",
|