@pacem/pacem 1.0.0-abel
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/LICENSE +191 -0
- package/NOTICE +4 -0
- package/dist/browser/pacem-2d.js +2755 -0
- package/dist/browser/pacem-2d.js.map +6 -0
- package/dist/browser/pacem-2d.min.js +7 -0
- package/dist/browser/pacem-2d.min.js.map +6 -0
- package/dist/browser/pacem-3d.js +7723 -0
- package/dist/browser/pacem-3d.js.map +6 -0
- package/dist/browser/pacem-3d.min.js +7 -0
- package/dist/browser/pacem-3d.min.js.map +6 -0
- package/dist/browser/pacem-charts.js +1628 -0
- package/dist/browser/pacem-charts.js.map +6 -0
- package/dist/browser/pacem-charts.min.js +7 -0
- package/dist/browser/pacem-charts.min.js.map +6 -0
- package/dist/browser/pacem-cms.js +2220 -0
- package/dist/browser/pacem-cms.js.map +6 -0
- package/dist/browser/pacem-cms.min.js +7 -0
- package/dist/browser/pacem-cms.min.js.map +6 -0
- package/dist/browser/pacem-core.js +9104 -0
- package/dist/browser/pacem-core.js.map +6 -0
- package/dist/browser/pacem-core.min.js +7 -0
- package/dist/browser/pacem-core.min.js.map +6 -0
- package/dist/browser/pacem-foundation.js +2138 -0
- package/dist/browser/pacem-foundation.js.map +6 -0
- package/dist/browser/pacem-foundation.min.js +7 -0
- package/dist/browser/pacem-foundation.min.js.map +6 -0
- package/dist/browser/pacem-fx.js +870 -0
- package/dist/browser/pacem-fx.js.map +6 -0
- package/dist/browser/pacem-fx.min.js +7 -0
- package/dist/browser/pacem-fx.min.js.map +6 -0
- package/dist/browser/pacem-logging.js +175 -0
- package/dist/browser/pacem-logging.js.map +6 -0
- package/dist/browser/pacem-logging.min.js +7 -0
- package/dist/browser/pacem-logging.min.js.map +6 -0
- package/dist/browser/pacem-maps.js +3642 -0
- package/dist/browser/pacem-maps.js.map +6 -0
- package/dist/browser/pacem-maps.min.js +7 -0
- package/dist/browser/pacem-maps.min.js.map +6 -0
- package/dist/browser/pacem-media.js +284 -0
- package/dist/browser/pacem-media.js.map +6 -0
- package/dist/browser/pacem-media.min.js +7 -0
- package/dist/browser/pacem-media.min.js.map +6 -0
- package/dist/browser/pacem-networking.js +434 -0
- package/dist/browser/pacem-networking.js.map +6 -0
- package/dist/browser/pacem-networking.min.js +7 -0
- package/dist/browser/pacem-networking.min.js.map +6 -0
- package/dist/browser/pacem-numerical.js +2627 -0
- package/dist/browser/pacem-numerical.js.map +6 -0
- package/dist/browser/pacem-numerical.min.js +7 -0
- package/dist/browser/pacem-numerical.min.js.map +6 -0
- package/dist/browser/pacem-plus.js +2373 -0
- package/dist/browser/pacem-plus.js.map +6 -0
- package/dist/browser/pacem-plus.min.js +7 -0
- package/dist/browser/pacem-plus.min.js.map +6 -0
- package/dist/browser/pacem-scaffolding.js +10435 -0
- package/dist/browser/pacem-scaffolding.js.map +6 -0
- package/dist/browser/pacem-scaffolding.min.js +7 -0
- package/dist/browser/pacem-scaffolding.min.js.map +6 -0
- package/dist/browser/pacem-ui.js +6348 -0
- package/dist/browser/pacem-ui.js.map +6 -0
- package/dist/browser/pacem-ui.min.js +7 -0
- package/dist/browser/pacem-ui.min.js.map +6 -0
- package/dist/bundle/pacem.min.mjs +997 -0
- package/dist/bundle/pacem.mjs +47067 -0
- package/dist/bundle/pacem.mjs.map +12 -0
- package/dist/typings/index.d.ts +9757 -0
- package/package.json +130 -0
|
@@ -0,0 +1,3642 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @pacem/pacem v1.0.0-abel (https://js.pacem.it)
|
|
3
|
+
* Copyright 2026 Pacem (https://pacem.it)
|
|
4
|
+
* Licensed under Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
(function (pacemFoundation, pacemCore) {
|
|
7
|
+
'use strict';
|
|
8
|
+
|
|
9
|
+
var __decorate$5 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
10
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
11
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
12
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
13
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
14
|
+
};
|
|
15
|
+
const EMPTY_LATLNG = { lat: Number.NaN, lng: Number.NaN };
|
|
16
|
+
class LatLng {
|
|
17
|
+
static get Empty() {
|
|
18
|
+
return EMPTY_LATLNG;
|
|
19
|
+
}
|
|
20
|
+
static isEmpty(l) {
|
|
21
|
+
return l === EMPTY_LATLNG || (isNaN(l.lat) && isNaN(l.lng));
|
|
22
|
+
}
|
|
23
|
+
static isLatLng(obj) {
|
|
24
|
+
return 'lat' in obj && typeof obj.lat === 'number'
|
|
25
|
+
&& 'lng' in obj && typeof obj.lng == 'number';
|
|
26
|
+
}
|
|
27
|
+
static translate(start, delta) {
|
|
28
|
+
// TODO: handle 'EDGE' cases!
|
|
29
|
+
return { lat: start.lat + delta.lat, lng: start.lng + delta.lng };
|
|
30
|
+
}
|
|
31
|
+
static equals(a, b) {
|
|
32
|
+
return a === b || (a.lat === b.lat && a.lng === b.lng);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const EMPTY_LATLNG_BOUNDS = { ne: LatLng.Empty, sw: LatLng.Empty };
|
|
36
|
+
class LatLngBounds {
|
|
37
|
+
static get Empty() {
|
|
38
|
+
return EMPTY_LATLNG_BOUNDS;
|
|
39
|
+
}
|
|
40
|
+
static isEmpty(bnds) {
|
|
41
|
+
return bnds === EMPTY_LATLNG_BOUNDS || (LatLng.isEmpty(bnds.ne) && LatLng.isEmpty(bnds.sw));
|
|
42
|
+
}
|
|
43
|
+
static isPoint(bnds) {
|
|
44
|
+
return !this.isEmpty(bnds) && (bnds.ne === bnds.sw || (bnds.ne.lat === bnds.sw.lat && bnds.ne.lng === bnds.sw.lng));
|
|
45
|
+
}
|
|
46
|
+
static isLatLngBounds(obj) {
|
|
47
|
+
return typeof obj === 'object'
|
|
48
|
+
&& 'ne' in obj && LatLng.isLatLng(obj.ne)
|
|
49
|
+
&& 'sw' in obj && LatLng.isLatLng(obj.sw);
|
|
50
|
+
}
|
|
51
|
+
static union(a, b) {
|
|
52
|
+
if (LatLngBounds.isEmpty(a)) {
|
|
53
|
+
if (LatLngBounds.isLatLngBounds(b)) {
|
|
54
|
+
return b;
|
|
55
|
+
}
|
|
56
|
+
return { ne: b, sw: b };
|
|
57
|
+
}
|
|
58
|
+
if (LatLngBounds.isLatLngBounds(b)) {
|
|
59
|
+
if (LatLngBounds.isEmpty(b)) {
|
|
60
|
+
return a;
|
|
61
|
+
}
|
|
62
|
+
// TODO: handle 'EDGE' cases!
|
|
63
|
+
const north = Math.max(a.ne.lat, b.ne.lat), east = Math.max(a.ne.lng, b.ne.lng), south = Math.min(a.sw.lat, b.sw.lat), west = Math.min(a.sw.lng, b.sw.lng);
|
|
64
|
+
return { ne: { lat: north, lng: east }, sw: { lat: south, lng: west } };
|
|
65
|
+
}
|
|
66
|
+
if (LatLng.isLatLng(b)) {
|
|
67
|
+
if (LatLng.isEmpty(b)) {
|
|
68
|
+
return a;
|
|
69
|
+
}
|
|
70
|
+
const north = Math.max(a.ne.lat, b.lat), east = Math.max(a.ne.lng, b.lng), south = Math.min(a.sw.lat, b.lat), west = Math.min(a.sw.lng, b.lng);
|
|
71
|
+
return { ne: { lat: north, lng: east }, sw: { lat: south, lng: west } };
|
|
72
|
+
}
|
|
73
|
+
return a;
|
|
74
|
+
}
|
|
75
|
+
static equals(a, b) {
|
|
76
|
+
return a === b || (LatLng.equals(a.ne, b.ne) && LatLng.equals(a.sw, b.sw));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const MapProjectionConsts = {
|
|
80
|
+
SIZE: 256, // fast for computation
|
|
81
|
+
RAD: Math.PI / 180,
|
|
82
|
+
DEG: 180 / Math.PI,
|
|
83
|
+
SIN_LIMIT: 1 - 1E-15,
|
|
84
|
+
EARTH_RADIUS: 6_378_137,
|
|
85
|
+
};
|
|
86
|
+
const _MapConsts = {
|
|
87
|
+
TRANSFORMERS_NS: 'maps',
|
|
88
|
+
//DEFAULT_COORDS: { lat: 44.714188025077984, lng: 10.296516444873811 }
|
|
89
|
+
};
|
|
90
|
+
class MapProjection {
|
|
91
|
+
constructor(_pixelSize, _bounds, _normalizedSize = MapProjectionConsts.SIZE) {
|
|
92
|
+
this._pixelSize = _pixelSize;
|
|
93
|
+
this._bounds = _bounds;
|
|
94
|
+
this._normalizedSize = _normalizedSize;
|
|
95
|
+
const hSize = _normalizedSize / 2;
|
|
96
|
+
this.#center = { x: hSize, y: hSize };
|
|
97
|
+
this.#sizerad = _normalizedSize / 360.0;
|
|
98
|
+
this.#sizedeg = hSize / Math.PI;
|
|
99
|
+
this.#bottomLeft = this._latLngToWorldNormalizedPoint(_bounds.sw);
|
|
100
|
+
this.#topRight = this._latLngToWorldNormalizedPoint(_bounds.ne);
|
|
101
|
+
}
|
|
102
|
+
#center;
|
|
103
|
+
#bottomLeft;
|
|
104
|
+
#topRight;
|
|
105
|
+
#sizerad;
|
|
106
|
+
#sizedeg;
|
|
107
|
+
_latLngToWorldNormalizedPoint(latLng) {
|
|
108
|
+
const x = this.#center.x + latLng.lng * this.#sizedeg;
|
|
109
|
+
const latRad = latLng.lat * MapProjectionConsts.RAD;
|
|
110
|
+
const limit = MapProjectionConsts.SIN_LIMIT;
|
|
111
|
+
const sin = Math.sin(latRad).clamp(-limit, limit);
|
|
112
|
+
const y = this.#center.y + .5 * Math.log((1 + sin) / (1 - sin)) * (-this.#sizerad);
|
|
113
|
+
return { x, y };
|
|
114
|
+
}
|
|
115
|
+
_worldNormalizedPointToLatLng(point) {
|
|
116
|
+
const lat = MapProjectionConsts.DEG * (2 * Math.atan(Math.exp((point.y - this.#center.y) / -this.#sizerad)) - Math.PI / 2);
|
|
117
|
+
const lng = (point.x - this.#center.x) / this.#sizedeg;
|
|
118
|
+
return { lat, lng };
|
|
119
|
+
}
|
|
120
|
+
_latLngToPoint(latLng) {
|
|
121
|
+
const topRight = this.#topRight, bottomLeft = this.#bottomLeft, deltaLat = -topRight.y + bottomLeft.y, deltaLng = topRight.x - bottomLeft.x, target = this._latLngToWorldNormalizedPoint(latLng);
|
|
122
|
+
const { width, height } = this._pixelSize;
|
|
123
|
+
const x = (target.x - bottomLeft.x) * (width / deltaLng);
|
|
124
|
+
const y = (target.y - topRight.y) * (height / deltaLat);
|
|
125
|
+
return { x, y };
|
|
126
|
+
}
|
|
127
|
+
_pointToLatLng(point) {
|
|
128
|
+
const topRight = this.#topRight, bottomLeft = this.#bottomLeft, deltaLat = -topRight.y + bottomLeft.y, deltaLng = topRight.x - bottomLeft.x;
|
|
129
|
+
const { width, height } = this._pixelSize;
|
|
130
|
+
// to normalized x
|
|
131
|
+
const x = point.x / (width / deltaLng) + this.#bottomLeft.x;
|
|
132
|
+
// to normalized y
|
|
133
|
+
const y = point.y / (height / deltaLat) + this.#topRight.y;
|
|
134
|
+
return this._worldNormalizedPointToLatLng({ x, y });
|
|
135
|
+
}
|
|
136
|
+
static _haversine(from, to) {
|
|
137
|
+
const degToRad = MapProjectionConsts.RAD, lambda1 = from.lng * degToRad, lambda2 = to.lng * degToRad, phi1 = from.lat * degToRad, phi2 = to.lat * degToRad;
|
|
138
|
+
return 2 * Math.asin(Math.sqrt(Math.pow(Math.sin((phi1 - phi2) / 2), 2) + Math.cos(phi1) * Math.cos(phi2) * Math.pow(Math.sin((lambda1 - lambda2) / 2), 2)));
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Computes a new LatLng by moving from a start position by a distance vector
|
|
142
|
+
* expressed in meters along north (dNorth) and east (dEast), on a spherical Earth.
|
|
143
|
+
* @param dEast Distance 'right' in meters.
|
|
144
|
+
* @param dNorth Distance 'up' in meters.
|
|
145
|
+
* @param start Start position.
|
|
146
|
+
* @param radius Planet radius in meters.
|
|
147
|
+
*/
|
|
148
|
+
static _offsetByMeters(start, dNorth, dEast, radius) {
|
|
149
|
+
const { RAD: deg2Rad, DEG: rad2Deg } = MapProjectionConsts;
|
|
150
|
+
// convert start lat/lng to radians
|
|
151
|
+
const lat1 = start.lat * deg2Rad;
|
|
152
|
+
const lng1 = start.lng * deg2Rad;
|
|
153
|
+
// angular distance in radians
|
|
154
|
+
const dLat = dNorth / radius;
|
|
155
|
+
const dLng = dEast / (radius * Math.cos(lat1));
|
|
156
|
+
const lat2 = lat1 + dLat;
|
|
157
|
+
const lng2 = lng1 + dLng;
|
|
158
|
+
return {
|
|
159
|
+
lat: lat2 * rad2Deg,
|
|
160
|
+
lng: lng2 * rad2Deg
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Returns the position obtained by moving a geographic point by the specified amount (in meters) north and east.
|
|
165
|
+
* @param start Starting position.
|
|
166
|
+
* @param north Distance 'north' in meters.
|
|
167
|
+
* @param east Distance 'east' in meters.
|
|
168
|
+
* @param r Planet radius in meters (default is Earth's radius).
|
|
169
|
+
* @returns New position after moving north and east by the specified distances.
|
|
170
|
+
*/
|
|
171
|
+
static offsetBy(start, north, east, r = MapProjectionConsts.EARTH_RADIUS) {
|
|
172
|
+
return MapProjection._offsetByMeters(start, north, east, r);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Distance in meters between two locations.
|
|
176
|
+
* @param from First location.
|
|
177
|
+
* @param to Second location.
|
|
178
|
+
*/
|
|
179
|
+
static distanceBetween(from, to, r = MapProjectionConsts.EARTH_RADIUS) {
|
|
180
|
+
return MapProjection._haversine(from, to) * r;
|
|
181
|
+
}
|
|
182
|
+
static latLngToPoint(latLng, bounds, size) {
|
|
183
|
+
return new MapProjection(size, bounds)._latLngToPoint(latLng);
|
|
184
|
+
}
|
|
185
|
+
static pointToLatLng(point, size, bounds) {
|
|
186
|
+
return new MapProjection(size, bounds)._pointToLatLng(point);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
__decorate$5([
|
|
190
|
+
pacemCore.Transformer(_MapConsts.TRANSFORMERS_NS + ".")
|
|
191
|
+
], MapProjection, "offsetBy", null);
|
|
192
|
+
__decorate$5([
|
|
193
|
+
pacemCore.Transformer(_MapConsts.TRANSFORMERS_NS + ".")
|
|
194
|
+
], MapProjection, "distanceBetween", null);
|
|
195
|
+
__decorate$5([
|
|
196
|
+
pacemCore.Transformer(_MapConsts.TRANSFORMERS_NS + ".")
|
|
197
|
+
], MapProjection, "latLngToPoint", null);
|
|
198
|
+
__decorate$5([
|
|
199
|
+
pacemCore.Transformer(_MapConsts.TRANSFORMERS_NS + ".")
|
|
200
|
+
], MapProjection, "pointToLatLng", null);
|
|
201
|
+
// }
|
|
202
|
+
|
|
203
|
+
var types = /*#__PURE__*/Object.freeze({
|
|
204
|
+
__proto__: null,
|
|
205
|
+
LatLng: LatLng,
|
|
206
|
+
LatLngBounds: LatLngBounds,
|
|
207
|
+
MapProjection: MapProjection
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
var __decorate$4 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
211
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
212
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
213
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
214
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
215
|
+
};
|
|
216
|
+
// namespace Pacem.Components.Maps {
|
|
217
|
+
var MapType;
|
|
218
|
+
(function (MapType) {
|
|
219
|
+
MapType["ROAD"] = "road";
|
|
220
|
+
MapType["SATELLITE"] = "satellite";
|
|
221
|
+
MapType["HYBRID"] = "hybrid";
|
|
222
|
+
MapType["TERRAIN"] = "terrain";
|
|
223
|
+
MapType["HIGH_CONTRAST"] = "high_contrast";
|
|
224
|
+
})(MapType || (MapType = {}));
|
|
225
|
+
var MapColorScheme;
|
|
226
|
+
(function (MapColorScheme) {
|
|
227
|
+
MapColorScheme["LIGHT"] = "light";
|
|
228
|
+
MapColorScheme["DARK"] = "dark";
|
|
229
|
+
MapColorScheme["SYSTEM"] = "system";
|
|
230
|
+
})(MapColorScheme || (MapColorScheme = {}));
|
|
231
|
+
const MapConstsInternal = {
|
|
232
|
+
MAP_SELECTOR: pacemCore.P + '-map',
|
|
233
|
+
MARKER_SELECTOR: pacemCore.P + '-map-marker',
|
|
234
|
+
POLYLINE_SELECTOR: pacemCore.P + '-map-polyline',
|
|
235
|
+
CIRCLE_SELECTOR: pacemCore.P + '-map-circle',
|
|
236
|
+
POLYGON_SELECTOR: pacemCore.P + '-map-polygon',
|
|
237
|
+
LAYER_SELECTOR: pacemCore.P + '-map-layer',
|
|
238
|
+
OVERLAY_IMAGE_SELECTOR: pacemCore.P + '-map-overlay-image',
|
|
239
|
+
GEOCODER_SELECTOR: pacemCore.P + '-map-geocode',
|
|
240
|
+
DEFAULT_COORDS: { lat: 44.714188025077984, lng: 10.296516444873811 }
|
|
241
|
+
};
|
|
242
|
+
const MapConsts = {
|
|
243
|
+
DEFAULT_COORDS: MapConstsInternal.DEFAULT_COORDS
|
|
244
|
+
};
|
|
245
|
+
/** @deprecated */
|
|
246
|
+
function isLatLng(obj) {
|
|
247
|
+
return LatLng.isLatLng(obj);
|
|
248
|
+
}
|
|
249
|
+
/** @deprecated */
|
|
250
|
+
function isLatLngBounds(obj) {
|
|
251
|
+
return LatLngBounds.isLatLngBounds(obj);
|
|
252
|
+
}
|
|
253
|
+
const DEFAULT_MAPTARGET_KEY = 'defaultMapTarget';
|
|
254
|
+
const LatLngConverter = {
|
|
255
|
+
convert: attr => {
|
|
256
|
+
const arr = /^\s*([+\-\d\.]+)\s*,?\s*([+\-\d\.]+)\s*$/.exec(attr);
|
|
257
|
+
if (arr && arr.length > 2) {
|
|
258
|
+
return { lat: parseFloat(arr[1]), lng: parseFloat(arr[2]) };
|
|
259
|
+
}
|
|
260
|
+
return JSON.parse(attr);
|
|
261
|
+
},
|
|
262
|
+
convertBack: prop => JSON.stringify(prop)
|
|
263
|
+
};
|
|
264
|
+
const LatLngBoundsConverter = {
|
|
265
|
+
convert: attr => {
|
|
266
|
+
const arr = /^\s*([+\-\d\.]+)\s*,?\s*([+\-\d\.]+)\s*,?\s*([+\-\d\.]+)\s*,?\s*([+\-\d\.]+)\s*$/.exec(attr);
|
|
267
|
+
if (arr && arr.length > 4) {
|
|
268
|
+
return {
|
|
269
|
+
sw: { lat: parseFloat(arr[3]), lng: parseFloat(arr[4]) },
|
|
270
|
+
ne: { lat: parseFloat(arr[1]), lng: parseFloat(arr[2]) }
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
return JSON.parse(attr);
|
|
274
|
+
},
|
|
275
|
+
convertBack: prop => JSON.stringify(prop)
|
|
276
|
+
};
|
|
277
|
+
class MapUtils {
|
|
278
|
+
static parseCoords(input) {
|
|
279
|
+
if (input && !isNaN(input['lat']) && !isNaN(input['lng']))
|
|
280
|
+
return [input['lat'], input['lng']];
|
|
281
|
+
else if (pacemCore.Utils.isArray(input) && input.length > 1)
|
|
282
|
+
return [input[0], input[1]];
|
|
283
|
+
else if (/^\s*(\+|-)?[\d]+(.[\d]+)?\s*,\s*(\+|-)?[\d]+(.[\d]+)?\s*$/.test(input)) {
|
|
284
|
+
var splitted = input.split(',');
|
|
285
|
+
return [parseFloat(splitted[0]), parseFloat(splitted[1])];
|
|
286
|
+
}
|
|
287
|
+
return [MapConstsInternal.DEFAULT_COORDS.lat, MapConstsInternal.DEFAULT_COORDS.lng];
|
|
288
|
+
}
|
|
289
|
+
static expandBounds(bnds, latLng) {
|
|
290
|
+
if (latLng) {
|
|
291
|
+
if (!Array.isArray(latLng)) {
|
|
292
|
+
latLng = [latLng.lat, latLng.lng];
|
|
293
|
+
}
|
|
294
|
+
bnds.push(latLng);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
static isContentEmpty(element) {
|
|
298
|
+
return element.children.length == 0;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
class MapRelevantElement extends pacemCore.PacemEventTarget {
|
|
302
|
+
get map() {
|
|
303
|
+
return this['_map'] = this['_map'] || pacemCore.CustomElementUtils.findAncestorOfType(this, PacemMapElement);
|
|
304
|
+
}
|
|
305
|
+
propertyChangedCallback(name, old, val, first) {
|
|
306
|
+
super.propertyChangedCallback(name, old, val, first);
|
|
307
|
+
if (!first && name === 'hide') {
|
|
308
|
+
const map = this.map;
|
|
309
|
+
map?.adapter?.fitBounds(map, true);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
viewActivatedCallback() {
|
|
313
|
+
super.viewActivatedCallback();
|
|
314
|
+
this.map && this.map.register(this);
|
|
315
|
+
}
|
|
316
|
+
disconnectedCallback() {
|
|
317
|
+
this.map && this.map.unregister(this);
|
|
318
|
+
super.disconnectedCallback();
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
__decorate$4([
|
|
322
|
+
pacemCore.Watch({ converter: pacemCore.PropertyConverters.Boolean })
|
|
323
|
+
], MapRelevantElement.prototype, "hide", void 0);
|
|
324
|
+
__decorate$4([
|
|
325
|
+
pacemCore.Watch({ converter: pacemCore.PropertyConverters.Boolean })
|
|
326
|
+
], MapRelevantElement.prototype, "inactive", void 0);
|
|
327
|
+
class MapEvent extends pacemCore.CustomTypedEvent {
|
|
328
|
+
constructor(type, args) {
|
|
329
|
+
super(type, args);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
let PacemMapGeocodeElement = class PacemMapGeocodeElement extends pacemCore.PacemEventTarget {
|
|
333
|
+
constructor() {
|
|
334
|
+
super(...arguments);
|
|
335
|
+
this.debounce = 1000;
|
|
336
|
+
this.#fetching = false;
|
|
337
|
+
}
|
|
338
|
+
#fetching;
|
|
339
|
+
#handle;
|
|
340
|
+
#promise;
|
|
341
|
+
get fetching() {
|
|
342
|
+
return this.#fetching;
|
|
343
|
+
}
|
|
344
|
+
_guards() {
|
|
345
|
+
// if nothing changed return the current results
|
|
346
|
+
const results = this.results;
|
|
347
|
+
if (!pacemCore.Utils.isNullOrEmpty(results)) {
|
|
348
|
+
const result = results[0];
|
|
349
|
+
if (!pacemCore.Utils.isNull(this.position) && LatLng.equals(this.position, result.position) && this.search === result.fullAddress) {
|
|
350
|
+
return Promise.resolve(results);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
// if adapter is not available then return an empty array
|
|
354
|
+
const adapter = this.adapter;
|
|
355
|
+
if (pacemCore.Utils.isNull(adapter) || adapter.disabled || !adapter.active) {
|
|
356
|
+
return Promise.resolve([]);
|
|
357
|
+
}
|
|
358
|
+
// ok to fetch for new results
|
|
359
|
+
return null;
|
|
360
|
+
}
|
|
361
|
+
propertyChangedCallback(name, old, val, first) {
|
|
362
|
+
super.propertyChangedCallback(name, old, val, first);
|
|
363
|
+
switch (name) {
|
|
364
|
+
case 'search':
|
|
365
|
+
this.geocode(val);
|
|
366
|
+
break;
|
|
367
|
+
case 'position':
|
|
368
|
+
this.reverseGeocode(val);
|
|
369
|
+
break;
|
|
370
|
+
case 'results':
|
|
371
|
+
if (pacemCore.Utils.isNullOrEmpty(val)) {
|
|
372
|
+
this.search = '';
|
|
373
|
+
this.position = null;
|
|
374
|
+
}
|
|
375
|
+
else {
|
|
376
|
+
const r = val[0];
|
|
377
|
+
this.search = r.fullAddress;
|
|
378
|
+
this.position = r.position;
|
|
379
|
+
}
|
|
380
|
+
break;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
_broadcastFetchingUpdate(f) {
|
|
384
|
+
if (f !== this.#fetching) {
|
|
385
|
+
this.#fetching = f;
|
|
386
|
+
this.dispatchEvent(new pacemCore.PropertyChangeEvent({ propertyName: 'fetching', oldValue: !f, currentValue: f }));
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
_fetch(wrapper) {
|
|
390
|
+
const { promise, search, position, key } = wrapper;
|
|
391
|
+
const current = this.#promise;
|
|
392
|
+
// check for equivalence
|
|
393
|
+
if (!pacemCore.Utils.isNull(current)
|
|
394
|
+
&& LatLng.equals(current.position, position)
|
|
395
|
+
&& (current.search || '') === (search || '')) {
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
// update scope vars
|
|
399
|
+
this.#promise = { key, promise, position, search };
|
|
400
|
+
// green light
|
|
401
|
+
this._broadcastFetchingUpdate(true);
|
|
402
|
+
promise.then(r => {
|
|
403
|
+
if (key === this.#promise.key) {
|
|
404
|
+
this._broadcastFetchingUpdate(false);
|
|
405
|
+
this._successCallback(r);
|
|
406
|
+
}
|
|
407
|
+
}, e => this._errorCallback(e));
|
|
408
|
+
}
|
|
409
|
+
_debounce(callback, debounce = this.debounce) {
|
|
410
|
+
if (this.#handle) {
|
|
411
|
+
clearTimeout(this.#handle);
|
|
412
|
+
}
|
|
413
|
+
this.#handle = window.setTimeout(() => {
|
|
414
|
+
callback();
|
|
415
|
+
}, debounce || 0);
|
|
416
|
+
}
|
|
417
|
+
reverseGeocode(position = this.position, maxResults = this.maxResults) {
|
|
418
|
+
if (this.disabled) {
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
this._debounce(() => {
|
|
422
|
+
const promise = this._guards() ?? this.adapter.reverseGeocode(position, maxResults || 1);
|
|
423
|
+
this._fetch({ promise, position, key: pacemCore.Utils.uniqueCode() });
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
geocode(search = this.search, maxResults = this.maxResults) {
|
|
427
|
+
if (this.disabled) {
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
this._debounce(() => {
|
|
431
|
+
const promise = this._guards() ?? this.adapter.geocode(search, maxResults || 10);
|
|
432
|
+
this._fetch({ promise, search, position: LatLng.Empty, key: pacemCore.Utils.uniqueCode() });
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
_successCallback(r) {
|
|
436
|
+
const any = !pacemCore.Utils.isNullOrEmpty(r);
|
|
437
|
+
if (any || !pacemCore.Utils.isNullOrEmpty(this.results)) {
|
|
438
|
+
// change observable property if any result found
|
|
439
|
+
// OR if an empty set should replace a non-empty one.
|
|
440
|
+
if (r !== this.results) {
|
|
441
|
+
this.results = r;
|
|
442
|
+
if (any) {
|
|
443
|
+
// fire 'success' event only in case of non-empty set.
|
|
444
|
+
this.dispatchEvent(new CustomEvent('success', { detail: r, bubbles: false, cancelable: false }));
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
_errorCallback(e) {
|
|
450
|
+
if (!pacemCore.Utils.isNullOrEmpty(this.results)) {
|
|
451
|
+
this.results = [];
|
|
452
|
+
}
|
|
453
|
+
this.dispatchEvent(new CustomEvent('error', { detail: e, bubbles: false, cancelable: false }));
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
__decorate$4([
|
|
457
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.Element })
|
|
458
|
+
], PacemMapGeocodeElement.prototype, "adapter", void 0);
|
|
459
|
+
__decorate$4([
|
|
460
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.Number })
|
|
461
|
+
], PacemMapGeocodeElement.prototype, "maxResults", void 0);
|
|
462
|
+
__decorate$4([
|
|
463
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.Number })
|
|
464
|
+
], PacemMapGeocodeElement.prototype, "debounce", void 0);
|
|
465
|
+
__decorate$4([
|
|
466
|
+
pacemCore.Watch({ emit: true, converter: pacemCore.PropertyConverters.Json })
|
|
467
|
+
], PacemMapGeocodeElement.prototype, "results", void 0);
|
|
468
|
+
__decorate$4([
|
|
469
|
+
pacemCore.Watch({ emit: true, converter: pacemCore.PropertyConverters.String })
|
|
470
|
+
], PacemMapGeocodeElement.prototype, "search", void 0);
|
|
471
|
+
__decorate$4([
|
|
472
|
+
pacemCore.Watch({ emit: true, converter: LatLngConverter })
|
|
473
|
+
], PacemMapGeocodeElement.prototype, "position", void 0);
|
|
474
|
+
PacemMapGeocodeElement = __decorate$4([
|
|
475
|
+
pacemCore.CustomElement({ tagName: MapConstsInternal.GEOCODER_SELECTOR })
|
|
476
|
+
], PacemMapGeocodeElement);
|
|
477
|
+
//#endregion
|
|
478
|
+
class PacemMapAdapterElement extends pacemCore.PacemEventTarget {
|
|
479
|
+
constructor() {
|
|
480
|
+
super(...arguments);
|
|
481
|
+
this.active = true;
|
|
482
|
+
this.#maps = new Map();
|
|
483
|
+
this.#markers = new WeakMap();
|
|
484
|
+
this.#shapes = new WeakMap();
|
|
485
|
+
this.#layers = new WeakMap();
|
|
486
|
+
this.#overlays = new WeakMap();
|
|
487
|
+
}
|
|
488
|
+
propertyChangedCallback(name, old, val, first) {
|
|
489
|
+
super.propertyChangedCallback(name, old, val, first);
|
|
490
|
+
if (!first) {
|
|
491
|
+
this.active = !this.disabled && this.isActive();
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
#maps;
|
|
495
|
+
#markers;
|
|
496
|
+
#shapes;
|
|
497
|
+
#layers;
|
|
498
|
+
#overlays;
|
|
499
|
+
get layerAdapters() {
|
|
500
|
+
return this.#layers;
|
|
501
|
+
}
|
|
502
|
+
get overlayAdapters() {
|
|
503
|
+
return this.#overlays;
|
|
504
|
+
}
|
|
505
|
+
get markerAdapters() {
|
|
506
|
+
return this.#markers;
|
|
507
|
+
}
|
|
508
|
+
get shapeAdapters() {
|
|
509
|
+
return this.#shapes;
|
|
510
|
+
}
|
|
511
|
+
hasMap(map) {
|
|
512
|
+
return this.#maps.has(map);
|
|
513
|
+
}
|
|
514
|
+
enrolledMaps() {
|
|
515
|
+
return this.#maps.keys();
|
|
516
|
+
}
|
|
517
|
+
tryGetMap(map) {
|
|
518
|
+
const maps = this.#maps;
|
|
519
|
+
if (maps.has(map)) {
|
|
520
|
+
return maps.get(map);
|
|
521
|
+
}
|
|
522
|
+
return null;
|
|
523
|
+
}
|
|
524
|
+
getMap(map) {
|
|
525
|
+
const retval = this.tryGetMap(map);
|
|
526
|
+
return retval?.map;
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* Initializes the map and returns its corresponding DOM element.
|
|
530
|
+
* @param map {PacemMapElement} Container for the map
|
|
531
|
+
*/
|
|
532
|
+
async initialize(map) {
|
|
533
|
+
const maps = this.#maps;
|
|
534
|
+
if (!maps.has(map)) {
|
|
535
|
+
const retval = await this.init(map);
|
|
536
|
+
maps.set(map, retval);
|
|
537
|
+
// initialize layer adapter
|
|
538
|
+
const layers = this.#layers;
|
|
539
|
+
if (!layers.has(map)) {
|
|
540
|
+
layers.set(map, this.buildLayerAdapterFor(map));
|
|
541
|
+
}
|
|
542
|
+
// initialize overlay adapter
|
|
543
|
+
const overlays = this.#overlays;
|
|
544
|
+
if (!overlays.has(map)) {
|
|
545
|
+
overlays.set(map, this.buildOverlayAdapterFor(map));
|
|
546
|
+
}
|
|
547
|
+
// initialize marker adapter
|
|
548
|
+
const markers = this.#markers;
|
|
549
|
+
if (!markers.has(map)) {
|
|
550
|
+
markers.set(map, this.buildMarkerAdapterFor(map));
|
|
551
|
+
}
|
|
552
|
+
// initialize shape adapter
|
|
553
|
+
const shapes = this.#shapes;
|
|
554
|
+
if (!shapes.has(map)) {
|
|
555
|
+
shapes.set(map, this.buildShapeAdapterFor(map));
|
|
556
|
+
}
|
|
557
|
+
return retval.container;
|
|
558
|
+
}
|
|
559
|
+
return maps.get(map).container;
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
* Disposes the resources attached to the map.
|
|
563
|
+
* @param map {PacemMapElement} The map
|
|
564
|
+
*/
|
|
565
|
+
destroy(map) {
|
|
566
|
+
const layers = this.#layers;
|
|
567
|
+
if (layers.has(map)) {
|
|
568
|
+
layers.delete(map);
|
|
569
|
+
}
|
|
570
|
+
const overlays = this.#overlays;
|
|
571
|
+
if (overlays.has(map)) {
|
|
572
|
+
overlays.delete(map);
|
|
573
|
+
}
|
|
574
|
+
const markers = this.#markers;
|
|
575
|
+
if (markers.has(map)) {
|
|
576
|
+
markers.delete(map);
|
|
577
|
+
}
|
|
578
|
+
const shapes = this.#shapes;
|
|
579
|
+
if (shapes.has(map)) {
|
|
580
|
+
shapes.delete(map);
|
|
581
|
+
}
|
|
582
|
+
const maps = this.#maps;
|
|
583
|
+
if (maps.has(map)) {
|
|
584
|
+
this.dispose(map);
|
|
585
|
+
maps.delete(map);
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
/**
|
|
589
|
+
* Removes a map element.
|
|
590
|
+
* @param item {MapRelevantElement} item to be removed
|
|
591
|
+
*/
|
|
592
|
+
removeItem(item) {
|
|
593
|
+
const ctrl = item.map;
|
|
594
|
+
// case layer
|
|
595
|
+
if (item instanceof PacemMapLayerElement) {
|
|
596
|
+
const layers = this.layerAdapters;
|
|
597
|
+
if (layers.has(ctrl)) {
|
|
598
|
+
const adapter = layers.get(ctrl);
|
|
599
|
+
adapter.removeLayer(item);
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
// case marker
|
|
603
|
+
else if (item instanceof PacemMapMarkerElement) {
|
|
604
|
+
const markers = this.markerAdapters;
|
|
605
|
+
if (markers.has(ctrl)) {
|
|
606
|
+
const adapter = markers.get(ctrl);
|
|
607
|
+
adapter.removeMarker(item);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
// case shape
|
|
611
|
+
else if (item instanceof PacemMapShapeElement) {
|
|
612
|
+
const shape = this.shapeAdapters;
|
|
613
|
+
if (shape.has(ctrl)) {
|
|
614
|
+
const adapter = shape.get(ctrl);
|
|
615
|
+
adapter.removeShape(item);
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
// case overlay
|
|
619
|
+
else if (item instanceof PacemMapOverlayElement) {
|
|
620
|
+
const overlays = this.overlayAdapters;
|
|
621
|
+
if (overlays.has(ctrl)) {
|
|
622
|
+
const adapter = overlays.get(ctrl);
|
|
623
|
+
adapter.removeOverlay(item);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
// TODO: other cases
|
|
627
|
+
//...
|
|
628
|
+
// fitBounds just in case
|
|
629
|
+
if (!item.inactive) {
|
|
630
|
+
this.fitBounds(ctrl, true);
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* Draws a map element.
|
|
635
|
+
* @param item {MapRelevantElement} item to be drawn
|
|
636
|
+
*/
|
|
637
|
+
drawItem(item) {
|
|
638
|
+
const ctrl = item.map;
|
|
639
|
+
// case layer
|
|
640
|
+
if (item instanceof PacemMapLayerElement) {
|
|
641
|
+
const layers = this.layerAdapters;
|
|
642
|
+
if (layers.has(ctrl)) {
|
|
643
|
+
const adapter = layers.get(ctrl);
|
|
644
|
+
adapter.drawLayer(item);
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
// case marker
|
|
648
|
+
else if (item instanceof PacemMapMarkerElement) {
|
|
649
|
+
const markers = this.markerAdapters;
|
|
650
|
+
if (markers.has(ctrl)) {
|
|
651
|
+
const adapter = markers.get(ctrl);
|
|
652
|
+
adapter.drawMarker(item);
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
// case shape
|
|
656
|
+
else if (item instanceof PacemMapShapeElement) {
|
|
657
|
+
const shapes = this.shapeAdapters;
|
|
658
|
+
if (shapes.has(ctrl)) {
|
|
659
|
+
const adapter = shapes.get(ctrl);
|
|
660
|
+
adapter.drawShape(item);
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
// case overlay
|
|
664
|
+
else if (item instanceof PacemMapOverlayElement) {
|
|
665
|
+
const overlays = this.overlayAdapters;
|
|
666
|
+
if (overlays.has(ctrl)) {
|
|
667
|
+
const adapter = overlays.get(ctrl);
|
|
668
|
+
adapter.drawOverlay(item);
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
// TODO: other cases
|
|
672
|
+
//...
|
|
673
|
+
// fitBounds just in case
|
|
674
|
+
if (!item.inactive) {
|
|
675
|
+
this.fitBounds(ctrl, true);
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
/**
|
|
679
|
+
* Shows the infowindow relevant to a map element (if any).
|
|
680
|
+
* @param item {MapRelevantElement} item whose infowindow must be displayed
|
|
681
|
+
*/
|
|
682
|
+
popupInfoWindow(item) {
|
|
683
|
+
const ctrl = item.map;
|
|
684
|
+
if (item instanceof PacemMapMarkerElement) {
|
|
685
|
+
const markers = this.markerAdapters;
|
|
686
|
+
if (markers.has(ctrl)) {
|
|
687
|
+
markers.get(ctrl).openInfoWindow(item);
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
/**
|
|
692
|
+
* Hides the infowindow relevant to a map element (if any).
|
|
693
|
+
* @param item {MapRelevantElement} item whose infowindow must be hidden
|
|
694
|
+
*/
|
|
695
|
+
popoutInfoWindow(item) {
|
|
696
|
+
const ctrl = item.map;
|
|
697
|
+
if (item instanceof PacemMapMarkerElement) {
|
|
698
|
+
const markers = this.markerAdapters;
|
|
699
|
+
if (markers.has(ctrl)) {
|
|
700
|
+
markers.get(ctrl).closeInfoWindow(item);
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
setView(ctrl, center, zoom) {
|
|
705
|
+
if (!this.hasMap(ctrl)) {
|
|
706
|
+
return;
|
|
707
|
+
}
|
|
708
|
+
let options = {};
|
|
709
|
+
if (typeof center === 'number') {
|
|
710
|
+
options = pacemCore.Utils.extend({}, { zoom: center });
|
|
711
|
+
}
|
|
712
|
+
else if (LatLng.isLatLng(center)) {
|
|
713
|
+
options = pacemCore.Utils.extend({}, { center, zoom });
|
|
714
|
+
}
|
|
715
|
+
else {
|
|
716
|
+
options = center;
|
|
717
|
+
}
|
|
718
|
+
this.setViewNative(ctrl, options);
|
|
719
|
+
}
|
|
720
|
+
fitBounds(map, onlyIfAutofitOrBounds) {
|
|
721
|
+
if (!pacemCore.Utils.isNull(map)) {
|
|
722
|
+
this._fitBounds(map, onlyIfAutofitOrBounds);
|
|
723
|
+
}
|
|
724
|
+
else {
|
|
725
|
+
for (let m of this.enrolledMaps() || []) {
|
|
726
|
+
this._fitBounds(m, onlyIfAutofitOrBounds);
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
_fitBounds(ctrl, onlyIfAutofitOrBounds) {
|
|
731
|
+
if (!this.hasMap(ctrl))
|
|
732
|
+
return;
|
|
733
|
+
// check against autofit
|
|
734
|
+
if (!ctrl.autofit && onlyIfAutofitOrBounds === true)
|
|
735
|
+
return;
|
|
736
|
+
if (LatLngBounds.isLatLngBounds(onlyIfAutofitOrBounds) && !LatLngBounds.isEmpty(onlyIfAutofitOrBounds)) {
|
|
737
|
+
this.fitBoundsNative(ctrl, onlyIfAutofitOrBounds);
|
|
738
|
+
return;
|
|
739
|
+
}
|
|
740
|
+
const markersBounds = this.markerAdapters.get(ctrl)?.getBounds(), shapesBounds = this.shapeAdapters.get(ctrl)?.getBounds();
|
|
741
|
+
// no markers nor shapes
|
|
742
|
+
const emptyMarkerBounds = pacemCore.Utils.isNull(markersBounds) || LatLngBounds.isEmpty(markersBounds), emptyShapeBounds = pacemCore.Utils.isNull(shapesBounds) || LatLngBounds.isEmpty(shapesBounds);
|
|
743
|
+
if (emptyMarkerBounds && emptyShapeBounds) {
|
|
744
|
+
this.setView(ctrl, { center: ctrl.center, zoom: ctrl.zoom });
|
|
745
|
+
return;
|
|
746
|
+
}
|
|
747
|
+
let bnds = LatLngBounds.Empty;
|
|
748
|
+
if (!emptyMarkerBounds) {
|
|
749
|
+
bnds = LatLngBounds.union(bnds, markersBounds);
|
|
750
|
+
}
|
|
751
|
+
if (!emptyShapeBounds) {
|
|
752
|
+
bnds = LatLngBounds.union(bnds, shapesBounds);
|
|
753
|
+
}
|
|
754
|
+
if (!LatLngBounds.isPoint(bnds)) {
|
|
755
|
+
this.fitBoundsNative(ctrl, bnds);
|
|
756
|
+
}
|
|
757
|
+
else {
|
|
758
|
+
this.setView(ctrl, { zoom: ctrl.zoom, center: bnds.ne });
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
;
|
|
762
|
+
updateMapElement(ctrl, arg1, arg2) {
|
|
763
|
+
['type', 'tilt', 'heading'].forEach(prop => {
|
|
764
|
+
if (prop in arg1) {
|
|
765
|
+
ctrl[prop] = arg1[prop];
|
|
766
|
+
}
|
|
767
|
+
});
|
|
768
|
+
const zoom = ('zoom' in arg1) ? arg1.zoom : arg2;
|
|
769
|
+
if (!pacemCore.Utils.isNullOrEmpty(zoom) && zoom !== ctrl.zoom) {
|
|
770
|
+
ctrl.zoom = zoom;
|
|
771
|
+
}
|
|
772
|
+
const center = LatLng.isLatLng(arg1) ? arg1 : arg1.center;
|
|
773
|
+
if (!pacemCore.Utils.isNullOrEmpty(center) && (center.lat != ctrl.center?.lat || center.lng != ctrl.center?.lng)) {
|
|
774
|
+
ctrl.center = center;
|
|
775
|
+
}
|
|
776
|
+
// update bounds
|
|
777
|
+
ctrl.updateBounds(this.getBounds(ctrl));
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
__decorate$4([
|
|
781
|
+
pacemCore.Watch({ emit: true, converter: pacemCore.PropertyConverters.Boolean })
|
|
782
|
+
], PacemMapAdapterElement.prototype, "active", void 0);
|
|
783
|
+
__decorate$4([
|
|
784
|
+
pacemCore.Debounce(1000, (key, ctrl) => `pacem:debounce:${key}:${ctrl.id}`)
|
|
785
|
+
], PacemMapAdapterElement.prototype, "_fitBounds", null);
|
|
786
|
+
class MapItemAdapter {
|
|
787
|
+
constructor(_map, _adapter = _map.adapter) {
|
|
788
|
+
this._map = _map;
|
|
789
|
+
this._adapter = _adapter;
|
|
790
|
+
}
|
|
791
|
+
get adapter() { return this._adapter; }
|
|
792
|
+
get map() { return this._map; }
|
|
793
|
+
getMap(item) {
|
|
794
|
+
return this._adapter.getMap(item.map);
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
class PacemOverlayAdapter extends MapItemAdapter {
|
|
798
|
+
constructor(map, adapter = map.adapter) {
|
|
799
|
+
super(map, adapter);
|
|
800
|
+
}
|
|
801
|
+
#overlays = new Map();
|
|
802
|
+
get layers() { return this.#overlays; }
|
|
803
|
+
onOverlayLoad(item, evt) {
|
|
804
|
+
item.dispatchEvent(new Event('overlayload'));
|
|
805
|
+
}
|
|
806
|
+
ensureOverlay(item, map) {
|
|
807
|
+
const ctrl = this, overlays = ctrl.#overlays;
|
|
808
|
+
let overlay;
|
|
809
|
+
if (!overlays.has(item)) {
|
|
810
|
+
overlay = this.buildOverlay(item, map);
|
|
811
|
+
if (!pacemCore.Utils.isNull(overlay)) {
|
|
812
|
+
overlays.set(item, overlay);
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
else {
|
|
816
|
+
overlay = overlays.get(item);
|
|
817
|
+
}
|
|
818
|
+
return overlay;
|
|
819
|
+
}
|
|
820
|
+
removeOverlay(item) {
|
|
821
|
+
const ctrl = this, map = ctrl.getMap(item), overlays = this.#overlays;
|
|
822
|
+
if (overlays.has(item)) {
|
|
823
|
+
const layer = overlays.get(item);
|
|
824
|
+
ctrl.deleteOverlay(layer, map);
|
|
825
|
+
overlays.delete(item);
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
drawOverlay(item) {
|
|
829
|
+
const ctrl = this, map = ctrl.getMap(item);
|
|
830
|
+
if (pacemCore.Utils.isNull(map)) {
|
|
831
|
+
return;
|
|
832
|
+
}
|
|
833
|
+
else if (pacemCore.Utils.isNullOrEmpty(item) || item.hide) {
|
|
834
|
+
ctrl.removeOverlay(item);
|
|
835
|
+
return;
|
|
836
|
+
}
|
|
837
|
+
//
|
|
838
|
+
const overlay = this.ensureOverlay(item, map);
|
|
839
|
+
this.setBounds(overlay, map, item.bounds);
|
|
840
|
+
this.updateOverlay(overlay, map, item);
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
class PacemMapOverlayElement extends MapRelevantElement {
|
|
844
|
+
}
|
|
845
|
+
__decorate$4([
|
|
846
|
+
pacemCore.Watch({ emit: false, converter: LatLngBoundsConverter })
|
|
847
|
+
], PacemMapOverlayElement.prototype, "bounds", void 0);
|
|
848
|
+
let PacemMapOverlayImageElement = class PacemMapOverlayImageElement extends PacemMapOverlayElement {
|
|
849
|
+
};
|
|
850
|
+
__decorate$4([
|
|
851
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.String })
|
|
852
|
+
], PacemMapOverlayImageElement.prototype, "src", void 0);
|
|
853
|
+
PacemMapOverlayImageElement = __decorate$4([
|
|
854
|
+
pacemCore.CustomElement({ tagName: MapConstsInternal.OVERLAY_IMAGE_SELECTOR })
|
|
855
|
+
], PacemMapOverlayImageElement);
|
|
856
|
+
class PacemLayerAdapter extends MapItemAdapter {
|
|
857
|
+
constructor(map, adapter = map.adapter) {
|
|
858
|
+
super(map, adapter);
|
|
859
|
+
}
|
|
860
|
+
#layers = new Map();
|
|
861
|
+
#loadHandlers = new Map();
|
|
862
|
+
get layers() { return this.#layers; }
|
|
863
|
+
onTileLoad(item, evt) {
|
|
864
|
+
item.dispatchEvent(new Event('tileload'));
|
|
865
|
+
}
|
|
866
|
+
ensureLayer(item, map) {
|
|
867
|
+
const ctrl = this, layers = ctrl.#layers;
|
|
868
|
+
let layer;
|
|
869
|
+
if (!layers.has(item)) {
|
|
870
|
+
layer = this.buildLayer(item, map);
|
|
871
|
+
if (layer != null) {
|
|
872
|
+
const handler = (e) => { ctrl.onTileLoad(item, e); };
|
|
873
|
+
this.#loadHandlers.set(item, handler);
|
|
874
|
+
this.addLoadEventListener(layer, map, handler);
|
|
875
|
+
layers.set(item, layer);
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
else {
|
|
879
|
+
layer = layers.get(item);
|
|
880
|
+
}
|
|
881
|
+
return layer;
|
|
882
|
+
}
|
|
883
|
+
removeLayer(item) {
|
|
884
|
+
const ctrl = this, map = ctrl.getMap(item), layers = this.#layers;
|
|
885
|
+
if (layers.has(item)) {
|
|
886
|
+
const layer = layers.get(item);
|
|
887
|
+
const handlers = this.#loadHandlers;
|
|
888
|
+
if (handlers.has(item)) {
|
|
889
|
+
const handler = handlers.get(item);
|
|
890
|
+
this.removeLoadEventListener(layer, map, handler);
|
|
891
|
+
handlers.delete(item);
|
|
892
|
+
}
|
|
893
|
+
ctrl.deleteLayer(layer, map);
|
|
894
|
+
layers.delete(item);
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
drawLayer(item) {
|
|
898
|
+
const ctrl = this, map = ctrl.getMap(item);
|
|
899
|
+
if (pacemCore.Utils.isNull(map)) {
|
|
900
|
+
return;
|
|
901
|
+
}
|
|
902
|
+
else if (pacemCore.Utils.isNullOrEmpty(item) || item.hide) {
|
|
903
|
+
ctrl.removeLayer(item);
|
|
904
|
+
return;
|
|
905
|
+
}
|
|
906
|
+
//
|
|
907
|
+
this.ensureLayer(item, map);
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
let PacemMapLayerElement = class PacemMapLayerElement extends MapRelevantElement {
|
|
911
|
+
};
|
|
912
|
+
__decorate$4([
|
|
913
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.String })
|
|
914
|
+
], PacemMapLayerElement.prototype, "url", void 0);
|
|
915
|
+
__decorate$4([
|
|
916
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.Json })
|
|
917
|
+
], PacemMapLayerElement.prototype, "include", void 0);
|
|
918
|
+
__decorate$4([
|
|
919
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.String })
|
|
920
|
+
], PacemMapLayerElement.prototype, "mode", void 0);
|
|
921
|
+
__decorate$4([
|
|
922
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.Number })
|
|
923
|
+
], PacemMapLayerElement.prototype, "minZoom", void 0);
|
|
924
|
+
__decorate$4([
|
|
925
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.Number })
|
|
926
|
+
], PacemMapLayerElement.prototype, "maxZoom", void 0);
|
|
927
|
+
PacemMapLayerElement = __decorate$4([
|
|
928
|
+
pacemCore.CustomElement({ tagName: MapConstsInternal.LAYER_SELECTOR })
|
|
929
|
+
], PacemMapLayerElement);
|
|
930
|
+
class PacemMarkerAdapter extends MapItemAdapter {
|
|
931
|
+
constructor(map, adapter = map.adapter) {
|
|
932
|
+
super(map, adapter);
|
|
933
|
+
}
|
|
934
|
+
get mapAutomaticallyScrollsOnDrag() {
|
|
935
|
+
return false;
|
|
936
|
+
}
|
|
937
|
+
#markers = new Map();
|
|
938
|
+
#infoWindows = new Map();
|
|
939
|
+
getBounds(filter = _ => true) {
|
|
940
|
+
const markers = this.markers;
|
|
941
|
+
let bnds = LatLngBounds.Empty;
|
|
942
|
+
for (var m of markers.keys()) {
|
|
943
|
+
if (!filter(m) || m.inactive) {
|
|
944
|
+
continue;
|
|
945
|
+
}
|
|
946
|
+
let marker = markers.get(m);
|
|
947
|
+
if (pacemCore.Utils.isNull(marker)) {
|
|
948
|
+
continue;
|
|
949
|
+
}
|
|
950
|
+
bnds = LatLngBounds.union(bnds, this.getMarkerPosition(marker));
|
|
951
|
+
}
|
|
952
|
+
return bnds;
|
|
953
|
+
}
|
|
954
|
+
get markers() { return this.#markers; }
|
|
955
|
+
get infoWindows() { return this.#infoWindows; }
|
|
956
|
+
onDragEnd(item, evt) {
|
|
957
|
+
const marker = this.markers.get(item), dpos = this.getMarkerPosition(marker);
|
|
958
|
+
item.onDragEnd(dpos);
|
|
959
|
+
}
|
|
960
|
+
onClick(item, evt) {
|
|
961
|
+
const marker = this.markers.get(item), dpos = this.getMarkerPosition(marker);
|
|
962
|
+
item.onClick(dpos);
|
|
963
|
+
}
|
|
964
|
+
onInfoOpen(item) {
|
|
965
|
+
item.onInfoOpen();
|
|
966
|
+
}
|
|
967
|
+
onInfoClose(item) {
|
|
968
|
+
item.onInfoClose();
|
|
969
|
+
}
|
|
970
|
+
ensureMarker(item, map) {
|
|
971
|
+
const ctrl = this;
|
|
972
|
+
let marker;
|
|
973
|
+
if (!ctrl.markers.has(item)) {
|
|
974
|
+
marker = this.buildMarker(item, map);
|
|
975
|
+
if (marker != null) {
|
|
976
|
+
this.addClickEventListener(marker, map, (e) => { ctrl.onClick(item, e); ctrl.openInfoWindow(item, e); });
|
|
977
|
+
this.addDragEventListener(marker, map, (e) => { if (!this.mapAutomaticallyScrollsOnDrag)
|
|
978
|
+
ctrl.adapter.fitBounds(item.map, true); });
|
|
979
|
+
this.addDragEndEventListener(marker, map, (e) => ctrl.onDragEnd(item, e));
|
|
980
|
+
ctrl.markers.set(item, marker);
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
else {
|
|
984
|
+
marker = ctrl.markers.get(item);
|
|
985
|
+
}
|
|
986
|
+
return marker;
|
|
987
|
+
}
|
|
988
|
+
removeMarker(item) {
|
|
989
|
+
const ctrl = this, map = ctrl.getMap(item), infoWindows = this.#infoWindows, markers = this.#markers;
|
|
990
|
+
if (infoWindows.has(item)) {
|
|
991
|
+
// const info = infoWindows.get(item);
|
|
992
|
+
infoWindows.delete(item);
|
|
993
|
+
}
|
|
994
|
+
if (markers.has(item)) {
|
|
995
|
+
const marker = markers.get(item);
|
|
996
|
+
ctrl.deleteMarker(marker, map);
|
|
997
|
+
markers.delete(item);
|
|
998
|
+
// ctrl._adapter.removeItem(item);
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
drawMarker(item) {
|
|
1002
|
+
const ctrl = this, map = ctrl.getMap(item);
|
|
1003
|
+
if (pacemCore.Utils.isNull(map)) {
|
|
1004
|
+
return;
|
|
1005
|
+
}
|
|
1006
|
+
else if (pacemCore.Utils.isNullOrEmpty(item && item.position) || item.hide) {
|
|
1007
|
+
ctrl.removeMarker(item);
|
|
1008
|
+
return;
|
|
1009
|
+
}
|
|
1010
|
+
//
|
|
1011
|
+
const marker = this.ensureMarker(item, map);
|
|
1012
|
+
// set position
|
|
1013
|
+
this.setPosition(marker, item.position);
|
|
1014
|
+
this.setIcon(marker, item.icon);
|
|
1015
|
+
this.setLabel(marker, item.caption);
|
|
1016
|
+
this.setDraggable(marker, item.draggable);
|
|
1017
|
+
}
|
|
1018
|
+
closeInfoWindow(item, evt) {
|
|
1019
|
+
const ctrl = this;
|
|
1020
|
+
if (ctrl.infoWindows.has(item)) {
|
|
1021
|
+
const info = ctrl.infoWindows.get(item);
|
|
1022
|
+
this.closeInfo(info);
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
ensureInfoWindow(item, map) {
|
|
1026
|
+
var ctrl = this;
|
|
1027
|
+
let info;
|
|
1028
|
+
if (!ctrl.infoWindows.has(item)) {
|
|
1029
|
+
info = this.buildInfoWindow(item);
|
|
1030
|
+
this.addCloseClickEventListener(info, map, (_) => {
|
|
1031
|
+
ctrl.deleteInfoWindow(info, map);
|
|
1032
|
+
ctrl.onInfoClose(item);
|
|
1033
|
+
});
|
|
1034
|
+
ctrl.infoWindows.set(item, info);
|
|
1035
|
+
}
|
|
1036
|
+
else {
|
|
1037
|
+
info = ctrl.infoWindows.get(item);
|
|
1038
|
+
}
|
|
1039
|
+
return info;
|
|
1040
|
+
}
|
|
1041
|
+
openInfoWindow(item, evt) {
|
|
1042
|
+
var ctrl = this, marker = ctrl.markers.get(item), content = item.caption, map = ctrl.getMap(item);
|
|
1043
|
+
if (!MapUtils.isContentEmpty(item)) {
|
|
1044
|
+
content = item.innerHTML;
|
|
1045
|
+
}
|
|
1046
|
+
if (!pacemCore.Utils.isNullOrEmpty(content)) {
|
|
1047
|
+
const info = this.ensureInfoWindow(item, map);
|
|
1048
|
+
this.setContent(info, content);
|
|
1049
|
+
this.openInfo(info, content, map, marker);
|
|
1050
|
+
ctrl.onInfoOpen(item);
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
let PacemMapMarkerElement = class PacemMapMarkerElement extends MapRelevantElement {
|
|
1055
|
+
onDragEnd(position) {
|
|
1056
|
+
this.position = position;
|
|
1057
|
+
this.dispatchEvent(new MapEvent('dragend', { position: position }));
|
|
1058
|
+
}
|
|
1059
|
+
onClick(position) {
|
|
1060
|
+
this.position = position;
|
|
1061
|
+
this.dispatchEvent(new MapEvent('click', { position: position }));
|
|
1062
|
+
}
|
|
1063
|
+
onInfoOpen() {
|
|
1064
|
+
this.dispatchEvent(new MapEvent('openinfo'));
|
|
1065
|
+
}
|
|
1066
|
+
onInfoClose() {
|
|
1067
|
+
this.dispatchEvent(new MapEvent('closeinfo'));
|
|
1068
|
+
}
|
|
1069
|
+
};
|
|
1070
|
+
__decorate$4([
|
|
1071
|
+
pacemCore.Watch({ converter: LatLngConverter })
|
|
1072
|
+
], PacemMapMarkerElement.prototype, "position", void 0);
|
|
1073
|
+
__decorate$4([
|
|
1074
|
+
pacemCore.Watch({ converter: pacemCore.PropertyConverters.Json })
|
|
1075
|
+
], PacemMapMarkerElement.prototype, "icon", void 0);
|
|
1076
|
+
__decorate$4([
|
|
1077
|
+
pacemCore.Watch({ converter: pacemCore.PropertyConverters.String })
|
|
1078
|
+
], PacemMapMarkerElement.prototype, "caption", void 0);
|
|
1079
|
+
__decorate$4([
|
|
1080
|
+
pacemCore.Watch({ converter: pacemCore.PropertyConverters.Boolean })
|
|
1081
|
+
], PacemMapMarkerElement.prototype, "draggable", void 0);
|
|
1082
|
+
PacemMapMarkerElement = __decorate$4([
|
|
1083
|
+
pacemCore.CustomElement({ tagName: MapConstsInternal.MARKER_SELECTOR })
|
|
1084
|
+
], PacemMapMarkerElement);
|
|
1085
|
+
class PacemShapeAdapter extends MapItemAdapter {
|
|
1086
|
+
constructor(map, adapter = map.adapter) {
|
|
1087
|
+
super(map, adapter);
|
|
1088
|
+
}
|
|
1089
|
+
#shapes = new Map();
|
|
1090
|
+
get shapes() { return this.#shapes; }
|
|
1091
|
+
getBounds(filter = _ => true) {
|
|
1092
|
+
const shapes = this.shapes;
|
|
1093
|
+
let bnds = LatLngBounds.Empty;
|
|
1094
|
+
for (var s of shapes.keys()) {
|
|
1095
|
+
if (!filter(s) || s.inactive) {
|
|
1096
|
+
continue;
|
|
1097
|
+
}
|
|
1098
|
+
let shape = shapes.get(s);
|
|
1099
|
+
if (pacemCore.Utils.isNull(shape)) {
|
|
1100
|
+
continue;
|
|
1101
|
+
}
|
|
1102
|
+
bnds = LatLngBounds.union(bnds, this.getShapeBounds(shape));
|
|
1103
|
+
}
|
|
1104
|
+
return bnds;
|
|
1105
|
+
}
|
|
1106
|
+
removeShape(item) {
|
|
1107
|
+
const ctrl = this, map = ctrl.getMap(item), shapes = this.#shapes;
|
|
1108
|
+
if (shapes.has(item)) {
|
|
1109
|
+
const shape = shapes.get(item);
|
|
1110
|
+
ctrl.deleteShape(shape, map);
|
|
1111
|
+
shapes.delete(item);
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
_dispatchEvent(item, type, evt) {
|
|
1115
|
+
const shape = this.shapes.get(item), position = this.getShapePosition(evt ?? shape);
|
|
1116
|
+
item.dispatchEvent(new MapEvent(type, { position }));
|
|
1117
|
+
}
|
|
1118
|
+
#dragDelta = new Map();
|
|
1119
|
+
onDragStart(item, evt) {
|
|
1120
|
+
const shape = this.shapes.get(item);
|
|
1121
|
+
const bounds = this.getShapeBounds(shape);
|
|
1122
|
+
this.#dragDelta.set(item, bounds.ne);
|
|
1123
|
+
this._dispatchEvent(item, 'dragstart', evt);
|
|
1124
|
+
}
|
|
1125
|
+
onDragEnd(item, evt) {
|
|
1126
|
+
const shape = this.shapes.get(item);
|
|
1127
|
+
const bounds = this.getShapeBounds(shape);
|
|
1128
|
+
const neStart = this.#dragDelta.get(item), neEnd = bounds.ne;
|
|
1129
|
+
const delta = { lat: neEnd.lat - neStart.lat, lng: neEnd.lng - neStart.lng };
|
|
1130
|
+
this._translateShape(item, delta);
|
|
1131
|
+
this._dispatchEvent(item, 'dragend', evt);
|
|
1132
|
+
}
|
|
1133
|
+
_translateShape(item, latLng) {
|
|
1134
|
+
if (item instanceof PacemMapCircleElement) {
|
|
1135
|
+
item.center = LatLng.translate(item.center, latLng);
|
|
1136
|
+
return;
|
|
1137
|
+
}
|
|
1138
|
+
if (item instanceof PacemMapPolylineElement) {
|
|
1139
|
+
const path = item.vertices.map(p => LatLng.translate(p, latLng));
|
|
1140
|
+
item.vertices = path;
|
|
1141
|
+
return;
|
|
1142
|
+
}
|
|
1143
|
+
if (item instanceof PacemMapPolygonElement) {
|
|
1144
|
+
const path = item.vertices.map(p => LatLng.translate(p, latLng));
|
|
1145
|
+
item.vertices = path;
|
|
1146
|
+
return;
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
onDrag(item, evt) {
|
|
1150
|
+
this._dispatchEvent(item, 'drag', evt);
|
|
1151
|
+
}
|
|
1152
|
+
onClick(item, evt) {
|
|
1153
|
+
this._dispatchEvent(item, 'click', evt);
|
|
1154
|
+
}
|
|
1155
|
+
ensureShape(item, map) {
|
|
1156
|
+
const ctrl = this;
|
|
1157
|
+
let shape;
|
|
1158
|
+
if (!ctrl.shapes.has(item)) {
|
|
1159
|
+
shape = this.buildShape(item, map);
|
|
1160
|
+
if (shape != null) {
|
|
1161
|
+
this.addClickEventListener(shape, (e) => ctrl.onClick(item, e));
|
|
1162
|
+
this.addDragEventListener(shape, (e) => { ctrl.onDrag(item, e); ctrl.adapter.fitBounds(item.map, true); });
|
|
1163
|
+
this.addDragEndEventListener(shape, (e) => ctrl.onDragEnd(item, e));
|
|
1164
|
+
this.addDragStartEventListener(shape, (e) => ctrl.onDragStart(item, e));
|
|
1165
|
+
ctrl.shapes.set(item, shape);
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
else {
|
|
1169
|
+
shape = ctrl.shapes.get(item);
|
|
1170
|
+
}
|
|
1171
|
+
return shape;
|
|
1172
|
+
}
|
|
1173
|
+
drawShape(item) {
|
|
1174
|
+
const ctrl = this, map = ctrl.getMap(item);
|
|
1175
|
+
if (pacemCore.Utils.isNull(map)) {
|
|
1176
|
+
return;
|
|
1177
|
+
}
|
|
1178
|
+
else if (pacemCore.Utils.isNullOrEmpty(item) || item.hide) {
|
|
1179
|
+
ctrl.removeShape(item);
|
|
1180
|
+
return;
|
|
1181
|
+
}
|
|
1182
|
+
//
|
|
1183
|
+
const shape = this.ensureShape(item, map);
|
|
1184
|
+
this.setShape(shape, item);
|
|
1185
|
+
this.setEditable(shape, item.editable);
|
|
1186
|
+
this.setDraggable(shape, item.draggable);
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
class PacemMapShapeElement extends MapRelevantElement {
|
|
1190
|
+
}
|
|
1191
|
+
__decorate$4([
|
|
1192
|
+
pacemCore.Watch({ emit: true, converter: pacemCore.PropertyConverters.Boolean })
|
|
1193
|
+
], PacemMapShapeElement.prototype, "draggable", void 0);
|
|
1194
|
+
__decorate$4([
|
|
1195
|
+
pacemCore.Watch({ emit: true, converter: pacemCore.PropertyConverters.Boolean })
|
|
1196
|
+
], PacemMapShapeElement.prototype, "editable", void 0);
|
|
1197
|
+
__decorate$4([
|
|
1198
|
+
pacemCore.Watch({ emit: true, converter: pacemCore.PropertyConverters.Json })
|
|
1199
|
+
], PacemMapShapeElement.prototype, "stroke", void 0);
|
|
1200
|
+
__decorate$4([
|
|
1201
|
+
pacemCore.Watch({ emit: true, converter: pacemCore.PropertyConverters.Json })
|
|
1202
|
+
], PacemMapShapeElement.prototype, "fill", void 0);
|
|
1203
|
+
let PacemMapPolylineElement = class PacemMapPolylineElement extends PacemMapShapeElement {
|
|
1204
|
+
};
|
|
1205
|
+
__decorate$4([
|
|
1206
|
+
pacemCore.Watch({ emit: true, converter: pacemCore.PropertyConverters.Json })
|
|
1207
|
+
], PacemMapPolylineElement.prototype, "vertices", void 0);
|
|
1208
|
+
PacemMapPolylineElement = __decorate$4([
|
|
1209
|
+
pacemCore.CustomElement({ tagName: MapConstsInternal.POLYLINE_SELECTOR })
|
|
1210
|
+
], PacemMapPolylineElement);
|
|
1211
|
+
let PacemMapPolygonElement = class PacemMapPolygonElement extends PacemMapShapeElement {
|
|
1212
|
+
};
|
|
1213
|
+
__decorate$4([
|
|
1214
|
+
pacemCore.Watch({ emit: true, converter: pacemCore.PropertyConverters.Json })
|
|
1215
|
+
], PacemMapPolygonElement.prototype, "vertices", void 0);
|
|
1216
|
+
PacemMapPolygonElement = __decorate$4([
|
|
1217
|
+
pacemCore.CustomElement({ tagName: MapConstsInternal.POLYGON_SELECTOR })
|
|
1218
|
+
], PacemMapPolygonElement);
|
|
1219
|
+
let PacemMapCircleElement = class PacemMapCircleElement extends PacemMapShapeElement {
|
|
1220
|
+
};
|
|
1221
|
+
__decorate$4([
|
|
1222
|
+
pacemCore.Watch({ emit: true, converter: LatLngConverter })
|
|
1223
|
+
], PacemMapCircleElement.prototype, "center", void 0);
|
|
1224
|
+
__decorate$4([
|
|
1225
|
+
pacemCore.Watch({ emit: true, converter: pacemCore.PropertyConverters.Json })
|
|
1226
|
+
], PacemMapCircleElement.prototype, "radius", void 0);
|
|
1227
|
+
PacemMapCircleElement = __decorate$4([
|
|
1228
|
+
pacemCore.CustomElement({ tagName: MapConstsInternal.CIRCLE_SELECTOR })
|
|
1229
|
+
], PacemMapCircleElement);
|
|
1230
|
+
//#endregion
|
|
1231
|
+
let PacemMapElement = class PacemMapElement extends pacemCore.PacemEventTarget {
|
|
1232
|
+
constructor() {
|
|
1233
|
+
super(...arguments);
|
|
1234
|
+
this.zoom = 12;
|
|
1235
|
+
this.center = MapConstsInternal.DEFAULT_COORDS;
|
|
1236
|
+
this.#bounds = LatLngBounds.Empty;
|
|
1237
|
+
this.scale = true;
|
|
1238
|
+
this.mousewheel = true;
|
|
1239
|
+
this.draggable = true;
|
|
1240
|
+
this.doubleClickZoom = true;
|
|
1241
|
+
this.keyboardShortcuts = true;
|
|
1242
|
+
/** Gets or sets whether to autofit the bounds whenever the map gets refreshed. */
|
|
1243
|
+
this.autofit = true;
|
|
1244
|
+
this.paddingTop = 0;
|
|
1245
|
+
this.paddingLeft = 0;
|
|
1246
|
+
this.paddingRight = 0;
|
|
1247
|
+
this.paddingBottom = 0;
|
|
1248
|
+
// GMaps features
|
|
1249
|
+
this.tilt = 0;
|
|
1250
|
+
this.heading = 0;
|
|
1251
|
+
this._drawHandler = (evt) => {
|
|
1252
|
+
this._draw(evt.target);
|
|
1253
|
+
};
|
|
1254
|
+
//#endregion
|
|
1255
|
+
//#region lifecycle
|
|
1256
|
+
this._listenToActiveAdapter = (e) => {
|
|
1257
|
+
const adapter = e.target;
|
|
1258
|
+
if (e.detail.propertyName === 'active' && e.detail.currentValue) {
|
|
1259
|
+
adapter.removeEventListener(pacemCore.PropertyChangeEventName, this._listenToActiveAdapter, false);
|
|
1260
|
+
this._switchAdapter(adapter);
|
|
1261
|
+
}
|
|
1262
|
+
};
|
|
1263
|
+
this._initialized = false;
|
|
1264
|
+
this._afterInit = (_, old) => {
|
|
1265
|
+
this._initialized = true;
|
|
1266
|
+
// loop through child element map-relevant-items
|
|
1267
|
+
for (var child of pacemCore.CustomElementUtils.findDescendants(this, n => n instanceof MapRelevantElement)) {
|
|
1268
|
+
this._erase(child, old);
|
|
1269
|
+
this._draw(child);
|
|
1270
|
+
}
|
|
1271
|
+
// dispose old, if any.
|
|
1272
|
+
if (old) {
|
|
1273
|
+
old?.destroy(this);
|
|
1274
|
+
}
|
|
1275
|
+
};
|
|
1276
|
+
this._resizeHandler = (e) => {
|
|
1277
|
+
this.onResize(e);
|
|
1278
|
+
};
|
|
1279
|
+
//#endregion
|
|
1280
|
+
}
|
|
1281
|
+
updateBounds(bounds) {
|
|
1282
|
+
if (!LatLngBounds.equals(bounds, this.#bounds)) {
|
|
1283
|
+
const oldValue = this.#bounds;
|
|
1284
|
+
const currentValue = this.#bounds = bounds;
|
|
1285
|
+
this.dispatchEvent(new pacemCore.PropertyChangeEvent({ propertyName: 'bounds', oldValue, currentValue }));
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
#bounds;
|
|
1289
|
+
get bounds() {
|
|
1290
|
+
return this.#bounds;
|
|
1291
|
+
}
|
|
1292
|
+
get container() {
|
|
1293
|
+
return this._container;
|
|
1294
|
+
}
|
|
1295
|
+
register(item) {
|
|
1296
|
+
item.addEventListener(pacemCore.PropertyChangeEventName, this._drawHandler, false);
|
|
1297
|
+
this._draw(item);
|
|
1298
|
+
}
|
|
1299
|
+
unregister(item) {
|
|
1300
|
+
this._erase(item);
|
|
1301
|
+
item.removeEventListener(pacemCore.PropertyChangeEventName, this._drawHandler, false);
|
|
1302
|
+
}
|
|
1303
|
+
_draw(item, adapter = this.adapter) {
|
|
1304
|
+
this._initialized &&
|
|
1305
|
+
adapter &&
|
|
1306
|
+
adapter.drawItem(item);
|
|
1307
|
+
}
|
|
1308
|
+
_erase(item, adapter = this.adapter) {
|
|
1309
|
+
this._initialized &&
|
|
1310
|
+
adapter &&
|
|
1311
|
+
adapter.removeItem(item);
|
|
1312
|
+
}
|
|
1313
|
+
_switchAdapter(val, old) {
|
|
1314
|
+
if (!val.active) {
|
|
1315
|
+
if (old) {
|
|
1316
|
+
this._afterInit(null, old);
|
|
1317
|
+
}
|
|
1318
|
+
val.addEventListener(pacemCore.PropertyChangeEventName, this._listenToActiveAdapter, false);
|
|
1319
|
+
}
|
|
1320
|
+
else {
|
|
1321
|
+
val.initialize(this).then(_ => this._afterInit(_, old));
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
viewActivatedCallback() {
|
|
1325
|
+
super.viewActivatedCallback();
|
|
1326
|
+
this._setupContainer();
|
|
1327
|
+
//
|
|
1328
|
+
this.adapter && this._switchAdapter(this.adapter);
|
|
1329
|
+
}
|
|
1330
|
+
propertyChangedCallback(name, old, val, first) {
|
|
1331
|
+
super.propertyChangedCallback(name, old, val, first);
|
|
1332
|
+
if (name === 'bounds') {
|
|
1333
|
+
return;
|
|
1334
|
+
}
|
|
1335
|
+
if (name === 'adapter') {
|
|
1336
|
+
if (!pacemCore.Utils.isNull(this._container)) {
|
|
1337
|
+
this._initialized = false;
|
|
1338
|
+
if (val) {
|
|
1339
|
+
this._switchAdapter(val, old);
|
|
1340
|
+
}
|
|
1341
|
+
else if (old) {
|
|
1342
|
+
this._afterInit(null, old);
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
else {
|
|
1347
|
+
switch (name) {
|
|
1348
|
+
case 'zoom':
|
|
1349
|
+
case 'center':
|
|
1350
|
+
case 'type':
|
|
1351
|
+
case 'theme':
|
|
1352
|
+
case 'tilt':
|
|
1353
|
+
case 'heading':
|
|
1354
|
+
this.adapter?.setView(this, { type: this.type, tilt: this.tilt, heading: this.heading, zoom: this.zoom, center: this.center, theme: this.theme });
|
|
1355
|
+
break;
|
|
1356
|
+
case 'autofit':
|
|
1357
|
+
if (val) {
|
|
1358
|
+
this.adapter?.fitBounds(this);
|
|
1359
|
+
}
|
|
1360
|
+
break;
|
|
1361
|
+
case 'target':
|
|
1362
|
+
if (old) {
|
|
1363
|
+
this._dismissContainer(old);
|
|
1364
|
+
}
|
|
1365
|
+
if (val) {
|
|
1366
|
+
this._setupContainer(val);
|
|
1367
|
+
this._setupResizer();
|
|
1368
|
+
}
|
|
1369
|
+
else {
|
|
1370
|
+
this._dismissResizer();
|
|
1371
|
+
}
|
|
1372
|
+
break;
|
|
1373
|
+
}
|
|
1374
|
+
this.adapter && this.adapter.invalidateSize(this);
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
_dismissContainer(container = this._container) {
|
|
1378
|
+
if (container.dataset[DEFAULT_MAPTARGET_KEY] === 'true') {
|
|
1379
|
+
container.remove();
|
|
1380
|
+
}
|
|
1381
|
+
else {
|
|
1382
|
+
pacemCore.Utils.removeClass(container, pacemCore.PCSS + '-map');
|
|
1383
|
+
}
|
|
1384
|
+
if (container === this._container) {
|
|
1385
|
+
this._container = null;
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
_dismissResizer() {
|
|
1389
|
+
const resizer = this._resizer;
|
|
1390
|
+
resizer.removeEventListener('resize', this._resizeHandler, false);
|
|
1391
|
+
resizer.remove();
|
|
1392
|
+
this._resizer = null;
|
|
1393
|
+
}
|
|
1394
|
+
_setupContainer(val = this.target) {
|
|
1395
|
+
if (pacemCore.Utils.isNull(val)) {
|
|
1396
|
+
val = document.createElement('div');
|
|
1397
|
+
val.dataset[DEFAULT_MAPTARGET_KEY] = 'true';
|
|
1398
|
+
this.insertAdjacentElement('afterend', val);
|
|
1399
|
+
}
|
|
1400
|
+
const container = this._container = val;
|
|
1401
|
+
pacemCore.Utils.addClass(container, pacemCore.PCSS + '-map');
|
|
1402
|
+
return container;
|
|
1403
|
+
}
|
|
1404
|
+
_setupResizer() {
|
|
1405
|
+
const container = this._container;
|
|
1406
|
+
if (pacemCore.Utils.isNull(container)) {
|
|
1407
|
+
throw new Error('You must set up the map container before its resizing listener.');
|
|
1408
|
+
}
|
|
1409
|
+
if (pacemCore.Utils.isNull(this._resizer)) {
|
|
1410
|
+
const resizer = this._resizer = document.createElement(pacemCore.P + '-resize');
|
|
1411
|
+
resizer.addEventListener('resize', this._resizeHandler, false);
|
|
1412
|
+
container.insertAdjacentElement('afterend', resizer);
|
|
1413
|
+
}
|
|
1414
|
+
this._resizer.target = container;
|
|
1415
|
+
return this._resizer;
|
|
1416
|
+
}
|
|
1417
|
+
_detach() {
|
|
1418
|
+
if (!pacemCore.Utils.isNull(this._container)) {
|
|
1419
|
+
this._dismissContainer();
|
|
1420
|
+
}
|
|
1421
|
+
if (!pacemCore.Utils.isNull(this._resizer)) {
|
|
1422
|
+
this._dismissResizer();
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1425
|
+
disconnectedCallback() {
|
|
1426
|
+
this._detach();
|
|
1427
|
+
super.disconnectedCallback();
|
|
1428
|
+
}
|
|
1429
|
+
onResize(e) {
|
|
1430
|
+
this.adapter && this.adapter.invalidateSize(this);
|
|
1431
|
+
}
|
|
1432
|
+
};
|
|
1433
|
+
__decorate$4([
|
|
1434
|
+
pacemCore.Watch({ emit: true, converter: pacemCore.PropertyConverters.Number })
|
|
1435
|
+
], PacemMapElement.prototype, "zoom", void 0);
|
|
1436
|
+
__decorate$4([
|
|
1437
|
+
pacemCore.Watch({ emit: true, converter: LatLngConverter })
|
|
1438
|
+
], PacemMapElement.prototype, "center", void 0);
|
|
1439
|
+
__decorate$4([
|
|
1440
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.String })
|
|
1441
|
+
], PacemMapElement.prototype, "type", void 0);
|
|
1442
|
+
__decorate$4([
|
|
1443
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.String })
|
|
1444
|
+
], PacemMapElement.prototype, "theme", void 0);
|
|
1445
|
+
__decorate$4([
|
|
1446
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.Boolean })
|
|
1447
|
+
], PacemMapElement.prototype, "scale", void 0);
|
|
1448
|
+
__decorate$4([
|
|
1449
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.Boolean })
|
|
1450
|
+
], PacemMapElement.prototype, "mousewheel", void 0);
|
|
1451
|
+
__decorate$4([
|
|
1452
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.String })
|
|
1453
|
+
], PacemMapElement.prototype, "zoomControl", void 0);
|
|
1454
|
+
__decorate$4([
|
|
1455
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.Boolean })
|
|
1456
|
+
], PacemMapElement.prototype, "draggable", void 0);
|
|
1457
|
+
__decorate$4([
|
|
1458
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.Boolean })
|
|
1459
|
+
], PacemMapElement.prototype, "doubleClickZoom", void 0);
|
|
1460
|
+
__decorate$4([
|
|
1461
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.Boolean })
|
|
1462
|
+
], PacemMapElement.prototype, "keyboardShortcuts", void 0);
|
|
1463
|
+
__decorate$4([
|
|
1464
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.Boolean })
|
|
1465
|
+
], PacemMapElement.prototype, "autofit", void 0);
|
|
1466
|
+
__decorate$4([
|
|
1467
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.Number })
|
|
1468
|
+
], PacemMapElement.prototype, "paddingTop", void 0);
|
|
1469
|
+
__decorate$4([
|
|
1470
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.Number })
|
|
1471
|
+
], PacemMapElement.prototype, "paddingLeft", void 0);
|
|
1472
|
+
__decorate$4([
|
|
1473
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.Number })
|
|
1474
|
+
], PacemMapElement.prototype, "paddingRight", void 0);
|
|
1475
|
+
__decorate$4([
|
|
1476
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.Number })
|
|
1477
|
+
], PacemMapElement.prototype, "paddingBottom", void 0);
|
|
1478
|
+
__decorate$4([
|
|
1479
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.Element })
|
|
1480
|
+
], PacemMapElement.prototype, "adapter", void 0);
|
|
1481
|
+
__decorate$4([
|
|
1482
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.Element })
|
|
1483
|
+
], PacemMapElement.prototype, "target", void 0);
|
|
1484
|
+
__decorate$4([
|
|
1485
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.Number })
|
|
1486
|
+
], PacemMapElement.prototype, "tilt", void 0);
|
|
1487
|
+
__decorate$4([
|
|
1488
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.Number })
|
|
1489
|
+
], PacemMapElement.prototype, "heading", void 0);
|
|
1490
|
+
PacemMapElement = __decorate$4([
|
|
1491
|
+
pacemCore.CustomElement({ tagName: MapConstsInternal.MAP_SELECTOR })
|
|
1492
|
+
], PacemMapElement);
|
|
1493
|
+
//}
|
|
1494
|
+
|
|
1495
|
+
var __decorate$3 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
1496
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1497
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1498
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1499
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1500
|
+
};
|
|
1501
|
+
const consts$3 = {
|
|
1502
|
+
GEOLOCATION_UNAVAILABLE: 'geolocation_unavailable',
|
|
1503
|
+
POSITION_UNAVAILABLE: 'position_unavailable',
|
|
1504
|
+
PERMISSION_DENIED: 'permission_denied',
|
|
1505
|
+
TIMEOUT: 'timeout',
|
|
1506
|
+
UNKNOWN_ERROR: 'unknown_error',
|
|
1507
|
+
};
|
|
1508
|
+
let PacemMapGeolocateElement = class PacemMapGeolocateElement extends pacemCore.PacemEventTarget {
|
|
1509
|
+
constructor() {
|
|
1510
|
+
super(...arguments);
|
|
1511
|
+
this.permission = 'prompt';
|
|
1512
|
+
this.maximumAge = 15000;
|
|
1513
|
+
this.timeout = 30000;
|
|
1514
|
+
this.#fetching = false;
|
|
1515
|
+
this._successCallback = (position) => {
|
|
1516
|
+
this.permission = 'granted';
|
|
1517
|
+
this._setFetching(false);
|
|
1518
|
+
const detail = {
|
|
1519
|
+
lat: position.coords.latitude, lng: position.coords.longitude,
|
|
1520
|
+
timestamp: position.timestamp, altitude: position.coords.altitude,
|
|
1521
|
+
heading: position.coords.heading, speed: position.coords.speed
|
|
1522
|
+
};
|
|
1523
|
+
this.position = detail;
|
|
1524
|
+
this.dispatchEvent(new CustomEvent('success', { detail }));
|
|
1525
|
+
};
|
|
1526
|
+
this._errorCallback = (err) => {
|
|
1527
|
+
this._setFetching(false);
|
|
1528
|
+
const detail = typeof err === 'string' ? err : this._errToString(err);
|
|
1529
|
+
this.dispatchEvent(new CustomEvent('error', { detail }));
|
|
1530
|
+
};
|
|
1531
|
+
}
|
|
1532
|
+
_checkPermission() {
|
|
1533
|
+
return new Promise(resolve => {
|
|
1534
|
+
const permissionApi = navigator.permissions;
|
|
1535
|
+
if (pacemCore.Utils.isNull(permissionApi)) {
|
|
1536
|
+
resolve('prompt');
|
|
1537
|
+
}
|
|
1538
|
+
else {
|
|
1539
|
+
permissionApi.query({ name: 'geolocation' }).then(p => {
|
|
1540
|
+
resolve(this.permission = p.state);
|
|
1541
|
+
});
|
|
1542
|
+
}
|
|
1543
|
+
});
|
|
1544
|
+
}
|
|
1545
|
+
#fetching;
|
|
1546
|
+
get fetching() {
|
|
1547
|
+
return this.#fetching;
|
|
1548
|
+
}
|
|
1549
|
+
_setFetching(val) {
|
|
1550
|
+
if (val !== this.fetching) {
|
|
1551
|
+
this.#fetching = val;
|
|
1552
|
+
this.dispatchEvent(new pacemCore.PropertyChangeEvent({ propertyName: 'fetching', currentValue: val, oldValue: !val }));
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
fetch() {
|
|
1556
|
+
if (this.disabled) {
|
|
1557
|
+
return;
|
|
1558
|
+
}
|
|
1559
|
+
if (!navigator.geolocation) {
|
|
1560
|
+
this._errorCallback(consts$3.GEOLOCATION_UNAVAILABLE);
|
|
1561
|
+
return;
|
|
1562
|
+
}
|
|
1563
|
+
this._checkPermission().then(_ => {
|
|
1564
|
+
this._setFetching(true);
|
|
1565
|
+
navigator.geolocation.getCurrentPosition(this._successCallback, this._errorCallback, { enableHighAccuracy: true, maximumAge: this.maximumAge });
|
|
1566
|
+
});
|
|
1567
|
+
}
|
|
1568
|
+
viewActivatedCallback() {
|
|
1569
|
+
super.viewActivatedCallback();
|
|
1570
|
+
this._checkPermission();
|
|
1571
|
+
}
|
|
1572
|
+
_errToString(err) {
|
|
1573
|
+
switch (err.code) {
|
|
1574
|
+
case GeolocationPositionError.PERMISSION_DENIED:
|
|
1575
|
+
return consts$3.PERMISSION_DENIED;
|
|
1576
|
+
case GeolocationPositionError.POSITION_UNAVAILABLE:
|
|
1577
|
+
return consts$3.POSITION_UNAVAILABLE;
|
|
1578
|
+
case GeolocationPositionError.TIMEOUT:
|
|
1579
|
+
return consts$3.TIMEOUT;
|
|
1580
|
+
default:
|
|
1581
|
+
return consts$3.UNKNOWN_ERROR;
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
};
|
|
1585
|
+
__decorate$3([
|
|
1586
|
+
pacemCore.Watch({ emit: true, converter: LatLngConverter })
|
|
1587
|
+
], PacemMapGeolocateElement.prototype, "position", void 0);
|
|
1588
|
+
__decorate$3([
|
|
1589
|
+
pacemCore.Watch({ emit: true, converter: pacemCore.PropertyConverters.String })
|
|
1590
|
+
], PacemMapGeolocateElement.prototype, "permission", void 0);
|
|
1591
|
+
__decorate$3([
|
|
1592
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.Number })
|
|
1593
|
+
], PacemMapGeolocateElement.prototype, "maximumAge", void 0);
|
|
1594
|
+
__decorate$3([
|
|
1595
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.Number })
|
|
1596
|
+
], PacemMapGeolocateElement.prototype, "timeout", void 0);
|
|
1597
|
+
PacemMapGeolocateElement = __decorate$3([
|
|
1598
|
+
pacemCore.CustomElement({ tagName: pacemCore.P + '-map-geolocate' })
|
|
1599
|
+
], PacemMapGeolocateElement);
|
|
1600
|
+
|
|
1601
|
+
var __decorate$2 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
1602
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1603
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1604
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1605
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1606
|
+
};
|
|
1607
|
+
var PacemAzureMapAdapterElement_1;
|
|
1608
|
+
// namespace Pacem.Components.Maps {
|
|
1609
|
+
const consts$2 = {
|
|
1610
|
+
API_JS: 'https://atlas.microsoft.com/sdk/javascript/mapcontrol/3/atlas.min.js',
|
|
1611
|
+
API_CSS: 'https://atlas.microsoft.com/sdk/javascript/mapcontrol/3/atlas.min.css'
|
|
1612
|
+
};
|
|
1613
|
+
function convertAddress$1(address) {
|
|
1614
|
+
return {
|
|
1615
|
+
city: address.municipality,
|
|
1616
|
+
state: address.countrySubdivision,
|
|
1617
|
+
province: address.countrySecondarySubdivision,
|
|
1618
|
+
village: address.municipalitySubdivision ?? address.localName,
|
|
1619
|
+
zipCode: address.postalCode,
|
|
1620
|
+
streetName: address.street ?? address.streetName,
|
|
1621
|
+
houseNumber: address.buildingNumber ?? address.streetNumber,
|
|
1622
|
+
countryCode: address.countryCode,
|
|
1623
|
+
country: address.country,
|
|
1624
|
+
};
|
|
1625
|
+
}
|
|
1626
|
+
class AtlasMapUtils {
|
|
1627
|
+
static getPosition(latLng) {
|
|
1628
|
+
if (Array.isArray(latLng)) {
|
|
1629
|
+
latLng = { lat: latLng[0], lng: latLng[1] };
|
|
1630
|
+
}
|
|
1631
|
+
return atlas.data.Position.fromLatLng(latLng);
|
|
1632
|
+
}
|
|
1633
|
+
static getBounds(bounds) {
|
|
1634
|
+
if (pacemCore.Utils.isArray(bounds)) {
|
|
1635
|
+
return atlas.data.BoundingBox.fromPositions(bounds.map(p => /* reverse */ [p[1], p[0]]));
|
|
1636
|
+
}
|
|
1637
|
+
const ne = AtlasMapUtils.getPosition(bounds.ne), sw = AtlasMapUtils.getPosition(bounds.sw);
|
|
1638
|
+
return atlas.data.BoundingBox.fromPositions([ne, sw]);
|
|
1639
|
+
}
|
|
1640
|
+
static getLatLng(position) {
|
|
1641
|
+
return { lat: position[1], lng: position[0] };
|
|
1642
|
+
}
|
|
1643
|
+
static getLatLngBounds(bounds) {
|
|
1644
|
+
const ne = atlas.data.BoundingBox.getNorthEast(bounds), sw = atlas.data.BoundingBox.getSouthWest(bounds);
|
|
1645
|
+
return { ne: AtlasMapUtils.getLatLng(ne), sw: AtlasMapUtils.getLatLng(sw) };
|
|
1646
|
+
}
|
|
1647
|
+
static parseGeocoding(response) {
|
|
1648
|
+
if (pacemCore.Utils.isNullOrEmpty(response.results)) {
|
|
1649
|
+
return [];
|
|
1650
|
+
}
|
|
1651
|
+
return response.results.map(r => {
|
|
1652
|
+
return {
|
|
1653
|
+
fullAddress: r.address.freeformAddress,
|
|
1654
|
+
address: convertAddress$1(r.address),
|
|
1655
|
+
position: { lat: r.position.lat, lng: r.position.lon, altitude: null }
|
|
1656
|
+
};
|
|
1657
|
+
});
|
|
1658
|
+
}
|
|
1659
|
+
static parseReverseGeocoding(response, location) {
|
|
1660
|
+
if (response.summary.numResults < 1) {
|
|
1661
|
+
return { fullAddress: '', address: {}, position: null };
|
|
1662
|
+
}
|
|
1663
|
+
const addr = response.addresses[0], position = (location ?? addr.position).split(',').map(i => parseFloat(i)), address = addr.address, fullAddress = address.freeformAddress;
|
|
1664
|
+
return {
|
|
1665
|
+
fullAddress, address: convertAddress$1(address), position: { lat: position[0], lng: position[1], altitude: position.length > 2 ? position[2] : null }
|
|
1666
|
+
};
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
class PacemAzureOverlayAdapter extends PacemOverlayAdapter {
|
|
1670
|
+
deleteOverlay(overlay, map) {
|
|
1671
|
+
throw new Error("Method not implemented.");
|
|
1672
|
+
}
|
|
1673
|
+
buildOverlay(item, map) {
|
|
1674
|
+
throw new Error("Method not implemented.");
|
|
1675
|
+
}
|
|
1676
|
+
setBounds(item, map, bounds) {
|
|
1677
|
+
throw new Error("Method not implemented.");
|
|
1678
|
+
}
|
|
1679
|
+
updateOverlay(overlay, map, item) {
|
|
1680
|
+
throw new Error("Method not implemented.");
|
|
1681
|
+
}
|
|
1682
|
+
}
|
|
1683
|
+
class PacemAzureLayerAdapter extends PacemLayerAdapter {
|
|
1684
|
+
addLoadEventListener(layer, map, callback) {
|
|
1685
|
+
throw new Error("Method not implemented.");
|
|
1686
|
+
}
|
|
1687
|
+
removeLoadEventListener(layer, map, callback) {
|
|
1688
|
+
throw new Error("Method not implemented.");
|
|
1689
|
+
}
|
|
1690
|
+
deleteLayer(layer, map) {
|
|
1691
|
+
throw new Error("Method not implemented.");
|
|
1692
|
+
}
|
|
1693
|
+
buildLayer(item, map) {
|
|
1694
|
+
throw new Error("Method not implemented.");
|
|
1695
|
+
}
|
|
1696
|
+
}
|
|
1697
|
+
class PacemAzureMarkerAdapter extends PacemMarkerAdapter {
|
|
1698
|
+
getMarkerPosition(marker) {
|
|
1699
|
+
const position = marker.getOptions().position;
|
|
1700
|
+
return AtlasMapUtils.getLatLng(position);
|
|
1701
|
+
}
|
|
1702
|
+
buildMarker(item, map) {
|
|
1703
|
+
const marker = new atlas.HtmlMarker();
|
|
1704
|
+
map.markers.add(marker);
|
|
1705
|
+
marker.setOptions({ popup: new atlas.Popup() });
|
|
1706
|
+
return marker;
|
|
1707
|
+
}
|
|
1708
|
+
addClickEventListener(marker, map, callback) {
|
|
1709
|
+
map.events.add('click', marker, callback);
|
|
1710
|
+
}
|
|
1711
|
+
addDragEventListener(marker, map, callback) {
|
|
1712
|
+
map.events.add('drag', marker, callback);
|
|
1713
|
+
}
|
|
1714
|
+
addDragEndEventListener(marker, map, callback) {
|
|
1715
|
+
map.events.add('dragend', marker, callback);
|
|
1716
|
+
}
|
|
1717
|
+
_setPopupPosition(info, position) {
|
|
1718
|
+
const popup = this._getPopup(info);
|
|
1719
|
+
if (!pacemCore.Utils.isNull(popup)) {
|
|
1720
|
+
popup.setOptions({ position });
|
|
1721
|
+
}
|
|
1722
|
+
}
|
|
1723
|
+
setPosition(marker, position) {
|
|
1724
|
+
const p = AtlasMapUtils.getPosition(position);
|
|
1725
|
+
marker.setOptions({ position: p });
|
|
1726
|
+
this._setPopupPosition(marker, p);
|
|
1727
|
+
}
|
|
1728
|
+
setIcon(marker, icon) {
|
|
1729
|
+
let popupOptions = { pixelOffset: [0, -36 /* default marker size */] };
|
|
1730
|
+
let options = { popup: new atlas.Popup() };
|
|
1731
|
+
let fnIcon = (icon, w, h) => `<img width="${(w || 'auto')}" height="${(h || 'auto')}" style="pointer-events: none" src="${icon}" />`; //item.icon.url;
|
|
1732
|
+
if (typeof icon === 'string') {
|
|
1733
|
+
// icon url only
|
|
1734
|
+
options.htmlContent = fnIcon(icon);
|
|
1735
|
+
}
|
|
1736
|
+
else if (!pacemCore.Utils.isNull(icon)) {
|
|
1737
|
+
// structured icon
|
|
1738
|
+
const size = icon.size, anchor = icon.anchor;
|
|
1739
|
+
options.htmlContent = fnIcon(icon.url, size && size.width, size && size.height);
|
|
1740
|
+
if (anchor) {
|
|
1741
|
+
options.anchor = "top-left";
|
|
1742
|
+
options.pixelOffset = [-anchor.x, -anchor.y];
|
|
1743
|
+
popupOptions.pixelOffset = [0, -anchor.y];
|
|
1744
|
+
}
|
|
1745
|
+
else if (size && size.height) {
|
|
1746
|
+
popupOptions.pixelOffset = [0, -size.height / 2];
|
|
1747
|
+
}
|
|
1748
|
+
}
|
|
1749
|
+
options.popup.setOptions(popupOptions);
|
|
1750
|
+
marker.setOptions(options);
|
|
1751
|
+
}
|
|
1752
|
+
setLabel(marker, label) {
|
|
1753
|
+
let options = { text: label };
|
|
1754
|
+
marker.setOptions(options);
|
|
1755
|
+
}
|
|
1756
|
+
setDraggable(marker, draggable) {
|
|
1757
|
+
let options = { draggable };
|
|
1758
|
+
marker.setOptions(options);
|
|
1759
|
+
}
|
|
1760
|
+
deleteMarker(marker, map) {
|
|
1761
|
+
map.markers.remove(marker);
|
|
1762
|
+
}
|
|
1763
|
+
deleteInfoWindow(info, map) {
|
|
1764
|
+
const popup = this._getPopup(info);
|
|
1765
|
+
popup.remove();
|
|
1766
|
+
}
|
|
1767
|
+
closeInfo(info) {
|
|
1768
|
+
const popup = this._getPopup(info);
|
|
1769
|
+
if (popup?.isOpen() !== true) {
|
|
1770
|
+
return;
|
|
1771
|
+
}
|
|
1772
|
+
popup.close();
|
|
1773
|
+
}
|
|
1774
|
+
openInfo(info, content, map, marker) {
|
|
1775
|
+
const { popup, position } = info.getOptions();
|
|
1776
|
+
this._setContent(popup, content, position);
|
|
1777
|
+
marker.togglePopup();
|
|
1778
|
+
map.events.addOnce('close', popup, (e) => {
|
|
1779
|
+
popup.setOptions({ content: '' });
|
|
1780
|
+
});
|
|
1781
|
+
}
|
|
1782
|
+
buildInfoWindow(item) {
|
|
1783
|
+
return this.markers.get(item);
|
|
1784
|
+
}
|
|
1785
|
+
addCloseClickEventListener(info, map, callback) {
|
|
1786
|
+
const popup = this._getPopup(info);
|
|
1787
|
+
map.events.add('close', popup, callback);
|
|
1788
|
+
}
|
|
1789
|
+
setContent(info, content) {
|
|
1790
|
+
/* unnecessary */
|
|
1791
|
+
const { popup, position } = info.getOptions();
|
|
1792
|
+
this._setContent(popup, content, position);
|
|
1793
|
+
}
|
|
1794
|
+
_getPopup(info) {
|
|
1795
|
+
return info.getOptions().popup;
|
|
1796
|
+
}
|
|
1797
|
+
_setContent(popup, content, position) {
|
|
1798
|
+
popup.setOptions({ content: `<div style="padding: 8px 24px 8px 8px;">${content}</div>`, position });
|
|
1799
|
+
}
|
|
1800
|
+
}
|
|
1801
|
+
class PacemAzureShapeAdapter extends PacemShapeAdapter {
|
|
1802
|
+
addDragStartEventListener(shape, callback) {
|
|
1803
|
+
throw new Error("Method not implemented.");
|
|
1804
|
+
}
|
|
1805
|
+
deleteShape(shape, map) {
|
|
1806
|
+
throw new Error("Method not implemented.");
|
|
1807
|
+
}
|
|
1808
|
+
getShapeBounds(shape) {
|
|
1809
|
+
throw new Error("Method not implemented.");
|
|
1810
|
+
}
|
|
1811
|
+
getShapePosition(obj) {
|
|
1812
|
+
throw new Error("Method not implemented.");
|
|
1813
|
+
}
|
|
1814
|
+
buildShape(item, map) {
|
|
1815
|
+
throw new Error("Method not implemented.");
|
|
1816
|
+
}
|
|
1817
|
+
addClickEventListener(shape, callback) {
|
|
1818
|
+
throw new Error("Method not implemented.");
|
|
1819
|
+
}
|
|
1820
|
+
addDragEventListener(shape, callback) {
|
|
1821
|
+
throw new Error("Method not implemented.");
|
|
1822
|
+
}
|
|
1823
|
+
addDragEndEventListener(shape, callback) {
|
|
1824
|
+
throw new Error("Method not implemented.");
|
|
1825
|
+
}
|
|
1826
|
+
setShape(shape, item) {
|
|
1827
|
+
throw new Error("Method not implemented.");
|
|
1828
|
+
}
|
|
1829
|
+
setEditable(shape, editable) {
|
|
1830
|
+
throw new Error("Method not implemented.");
|
|
1831
|
+
}
|
|
1832
|
+
setDraggable(shape, draggable) {
|
|
1833
|
+
throw new Error("Method not implemented.");
|
|
1834
|
+
}
|
|
1835
|
+
}
|
|
1836
|
+
//#region geocoders
|
|
1837
|
+
class PacemAzureMapGeocoder {
|
|
1838
|
+
_buildGeocodeRequest(key, search, maxResults = 10, language = '') {
|
|
1839
|
+
// TODO: upgrade to newest version (see: https://www.npmjs.com/package/azure-maps-rest)
|
|
1840
|
+
const url = 'https://atlas.microsoft.com/search/address/json?api-version=1.0';
|
|
1841
|
+
const query = { 'subscription-key': key, query: search, limit: '' + maxResults, language };
|
|
1842
|
+
return {
|
|
1843
|
+
uri: pacemCore.Utils.URIs.appendQuery(url, query),
|
|
1844
|
+
options: {
|
|
1845
|
+
mode: 'cors' //, headers: {}
|
|
1846
|
+
}
|
|
1847
|
+
};
|
|
1848
|
+
}
|
|
1849
|
+
parseGeocodeResponse(response) {
|
|
1850
|
+
return new Promise((resolve, reject) => {
|
|
1851
|
+
response.json().then((r) => {
|
|
1852
|
+
const retval = AtlasMapUtils.parseGeocoding(r);
|
|
1853
|
+
resolve(retval);
|
|
1854
|
+
}, e => reject(e));
|
|
1855
|
+
});
|
|
1856
|
+
}
|
|
1857
|
+
geocode(key, address, maxResults = 10, language = '') {
|
|
1858
|
+
return new Promise((resolve, reject) => {
|
|
1859
|
+
const request = this._buildGeocodeRequest(key, address, maxResults, language);
|
|
1860
|
+
return fetch(request.uri, request.options).then(response => {
|
|
1861
|
+
if (response.ok) {
|
|
1862
|
+
this.parseGeocodeResponse(response).then(resolve, reject);
|
|
1863
|
+
}
|
|
1864
|
+
else {
|
|
1865
|
+
reject(response);
|
|
1866
|
+
}
|
|
1867
|
+
}, e => reject(e));
|
|
1868
|
+
});
|
|
1869
|
+
}
|
|
1870
|
+
reverseGeocode(key, latLng, language = '') {
|
|
1871
|
+
return new Promise((resolve, reject) => {
|
|
1872
|
+
const request = this._buildReverseRequest(key, latLng, language);
|
|
1873
|
+
return fetch(request.uri, request.options).then(response => {
|
|
1874
|
+
if (response.ok) {
|
|
1875
|
+
this._parseReverseResponse(response).then(resolve, reject);
|
|
1876
|
+
}
|
|
1877
|
+
else {
|
|
1878
|
+
reject(response);
|
|
1879
|
+
}
|
|
1880
|
+
}, e => reject(e));
|
|
1881
|
+
});
|
|
1882
|
+
}
|
|
1883
|
+
_buildReverseRequest(key, position, language = '') {
|
|
1884
|
+
// TODO: upgrade to newest version (see: https://atlas.microsoft.com/reverseGeocode?api-version=2023-06-01)
|
|
1885
|
+
const url = 'https://atlas.microsoft.com/search/address/reverse/json?api-version=1.0';
|
|
1886
|
+
const latLng = MapUtils.parseCoords(position);
|
|
1887
|
+
const query = {
|
|
1888
|
+
'subscription-key': key,
|
|
1889
|
+
query: latLng[0] + ',' + latLng[1],
|
|
1890
|
+
language
|
|
1891
|
+
};
|
|
1892
|
+
return {
|
|
1893
|
+
uri: pacemCore.Utils.URIs.appendQuery(url, query),
|
|
1894
|
+
options: {
|
|
1895
|
+
mode: 'cors' //, headers: {}
|
|
1896
|
+
}
|
|
1897
|
+
};
|
|
1898
|
+
}
|
|
1899
|
+
_parseReverseResponse(response) {
|
|
1900
|
+
return new Promise((resolve, reject) => {
|
|
1901
|
+
response.json().then((r) => {
|
|
1902
|
+
const retval = AtlasMapUtils.parseReverseGeocoding(r);
|
|
1903
|
+
resolve([retval]);
|
|
1904
|
+
}, e => reject(e));
|
|
1905
|
+
});
|
|
1906
|
+
}
|
|
1907
|
+
}
|
|
1908
|
+
//#endregion
|
|
1909
|
+
const MAP_EVENTS$1 = ['moveend', 'dragend', 'zoomend', 'rotateend'];
|
|
1910
|
+
function getNativeMapStyle$1(options) {
|
|
1911
|
+
const darkTheme = options.theme == MapColorScheme.DARK || (options.theme !== MapColorScheme.LIGHT && window.matchMedia('(prefers-color-scheme: dark)').matches);
|
|
1912
|
+
switch (options.type) {
|
|
1913
|
+
case 'satellite':
|
|
1914
|
+
case 'satellite_road_labels':
|
|
1915
|
+
case 'grayscale_dark':
|
|
1916
|
+
case 'grayscale_light':
|
|
1917
|
+
case 'night':
|
|
1918
|
+
case 'road_shaded_relief':
|
|
1919
|
+
case 'road':
|
|
1920
|
+
case 'high_constrast_dark':
|
|
1921
|
+
case 'high_constrast_light':
|
|
1922
|
+
return options.type;
|
|
1923
|
+
case MapType.HYBRID:
|
|
1924
|
+
return 'satellite_road_labels';
|
|
1925
|
+
case MapType.SATELLITE:
|
|
1926
|
+
return 'satellite';
|
|
1927
|
+
case MapType.TERRAIN:
|
|
1928
|
+
return 'road_shaded_relief';
|
|
1929
|
+
case MapType.HIGH_CONTRAST:
|
|
1930
|
+
return darkTheme ? 'high_constrast_dark' : 'high_constrast_light';
|
|
1931
|
+
default:
|
|
1932
|
+
return darkTheme ? 'night' : 'road';
|
|
1933
|
+
}
|
|
1934
|
+
}
|
|
1935
|
+
let PacemAzureMapAdapterElement = PacemAzureMapAdapterElement_1 = class PacemAzureMapAdapterElement extends PacemMapAdapterElement {
|
|
1936
|
+
geocode(address, maxResults) {
|
|
1937
|
+
return new PacemAzureMapGeocoder().geocode(this.subscriptionKey, address, maxResults, pacemCore.Utils.lang(this));
|
|
1938
|
+
}
|
|
1939
|
+
reverseGeocode(latLng, maxResults) {
|
|
1940
|
+
return new PacemAzureMapGeocoder().reverseGeocode(this.subscriptionKey, latLng, pacemCore.Utils.lang(this));
|
|
1941
|
+
}
|
|
1942
|
+
getBounds(ctrl) {
|
|
1943
|
+
const map = this.getMap(ctrl);
|
|
1944
|
+
const { bounds } = map.getCamera();
|
|
1945
|
+
return AtlasMapUtils.getLatLngBounds(bounds);
|
|
1946
|
+
}
|
|
1947
|
+
isActive() {
|
|
1948
|
+
return !pacemCore.Utils.isNullOrEmpty(this.subscriptionKey);
|
|
1949
|
+
}
|
|
1950
|
+
buildOverlayAdapterFor(map) {
|
|
1951
|
+
return new PacemAzureOverlayAdapter(map, this);
|
|
1952
|
+
}
|
|
1953
|
+
buildMarkerAdapterFor(map) {
|
|
1954
|
+
return new PacemAzureMarkerAdapter(map, this);
|
|
1955
|
+
}
|
|
1956
|
+
buildShapeAdapterFor(map) {
|
|
1957
|
+
return new PacemAzureShapeAdapter(map, this);
|
|
1958
|
+
}
|
|
1959
|
+
buildLayerAdapterFor(map) {
|
|
1960
|
+
return new PacemAzureLayerAdapter(map, this);
|
|
1961
|
+
}
|
|
1962
|
+
setViewNative(ctrl, options) {
|
|
1963
|
+
const map = this.getMap(ctrl);
|
|
1964
|
+
// style
|
|
1965
|
+
options = pacemCore.Utils.extend({ type: ctrl.type, theme: ctrl.theme }, options);
|
|
1966
|
+
const style = getNativeMapStyle$1(options);
|
|
1967
|
+
map.setStyle({ style });
|
|
1968
|
+
const center = options.center && AtlasMapUtils.getPosition(options.center) || map.getCamera().center;
|
|
1969
|
+
const zoom = options.zoom || map.getCamera().zoom;
|
|
1970
|
+
map.setCamera({ center, zoom });
|
|
1971
|
+
}
|
|
1972
|
+
#listeners = new WeakMap();
|
|
1973
|
+
snapshot(ctrl, type = 'image/png', quality) {
|
|
1974
|
+
if (!this.hasMap(ctrl)) {
|
|
1975
|
+
return Promise.reject();
|
|
1976
|
+
}
|
|
1977
|
+
const { map } = this.tryGetMap(ctrl);
|
|
1978
|
+
return new Promise((resolve, _) => {
|
|
1979
|
+
pacemCore.Utils.blobToDataURL(this.#blobs.get(ctrl)).then(dataUrl => {
|
|
1980
|
+
const container = map.getCanvasContainer();
|
|
1981
|
+
container.style.backgroundImage = `url(${dataUrl})`;
|
|
1982
|
+
container.style.backgroundSize = 'contain';
|
|
1983
|
+
pacemCore.Utils.snapshotElement(container, null, type, quality).then(resolve);
|
|
1984
|
+
});
|
|
1985
|
+
});
|
|
1986
|
+
}
|
|
1987
|
+
#blobs = new WeakMap();
|
|
1988
|
+
// #region ABSTRACT IMPLEMENTATION
|
|
1989
|
+
dispose(ctrl) {
|
|
1990
|
+
if (!this.hasMap(ctrl)) {
|
|
1991
|
+
return;
|
|
1992
|
+
}
|
|
1993
|
+
const { map } = this.tryGetMap(ctrl);
|
|
1994
|
+
// detach listeners
|
|
1995
|
+
const listeners = this.#listeners.get(ctrl);
|
|
1996
|
+
listeners.forEach(listener => {
|
|
1997
|
+
map.events.remove(listener.eventName, listener.handler);
|
|
1998
|
+
});
|
|
1999
|
+
// cleanup
|
|
2000
|
+
this.#listeners.delete(ctrl);
|
|
2001
|
+
// destroy map
|
|
2002
|
+
map.dispose();
|
|
2003
|
+
}
|
|
2004
|
+
async init(container) {
|
|
2005
|
+
await Promise.all([
|
|
2006
|
+
pacemCore.CustomElementUtils.importjs(consts$2.API_JS),
|
|
2007
|
+
pacemCore.CustomElementUtils.importcss(consts$2.API_CSS, undefined, true)
|
|
2008
|
+
]);
|
|
2009
|
+
const ctrl = container;
|
|
2010
|
+
const scale = ctrl.scale;
|
|
2011
|
+
const draggable = ctrl.draggable;
|
|
2012
|
+
const dblClickZoom = ctrl.doubleClickZoom;
|
|
2013
|
+
const kbShortcuts = ctrl.keyboardShortcuts;
|
|
2014
|
+
//
|
|
2015
|
+
const center = AtlasMapUtils.getPosition(ctrl.center);
|
|
2016
|
+
const mapOptions = {
|
|
2017
|
+
center: center,
|
|
2018
|
+
zoom: ctrl.zoom,
|
|
2019
|
+
subscriptionKey: this.subscriptionKey,
|
|
2020
|
+
dragPanInteraction: draggable,
|
|
2021
|
+
scrollZoomInteraction: ctrl.mousewheel,
|
|
2022
|
+
dblClickZoomInteraction: !dblClickZoom,
|
|
2023
|
+
keyboardInteraction: kbShortcuts,
|
|
2024
|
+
language: this.language || pacemCore.Utils.lang(container),
|
|
2025
|
+
};
|
|
2026
|
+
const canvas = ctrl.container;
|
|
2027
|
+
const mapElement = document.createElement('div');
|
|
2028
|
+
mapElement.id = `azure-maps-${pacemCore.Utils.uniqueCode()}`;
|
|
2029
|
+
mapElement.style.width = '100%';
|
|
2030
|
+
mapElement.style.height = '100%';
|
|
2031
|
+
canvas.innerHTML = '';
|
|
2032
|
+
canvas.appendChild(mapElement);
|
|
2033
|
+
const map = new atlas.Map(mapElement.id, mapOptions);
|
|
2034
|
+
const listeners = [];
|
|
2035
|
+
this.#listeners.set(ctrl, listeners);
|
|
2036
|
+
MAP_EVENTS$1.forEach((evt) => {
|
|
2037
|
+
const handler = this._spinMapUpdateHandler(ctrl, map);
|
|
2038
|
+
map.events.add(evt, handler);
|
|
2039
|
+
listeners.push({ eventName: evt, handler });
|
|
2040
|
+
});
|
|
2041
|
+
if (scale && ctrl.zoomControl) {
|
|
2042
|
+
map.events.addOnce('ready', (e) => {
|
|
2043
|
+
let pos = atlas.ControlPosition.NonFixed;
|
|
2044
|
+
switch (ctrl.zoomControl) {
|
|
2045
|
+
case 'topleft':
|
|
2046
|
+
pos = atlas.ControlPosition.TopLeft;
|
|
2047
|
+
break;
|
|
2048
|
+
case 'topright':
|
|
2049
|
+
pos = atlas.ControlPosition.TopRight;
|
|
2050
|
+
break;
|
|
2051
|
+
case 'bottomright':
|
|
2052
|
+
pos = atlas.ControlPosition.BottomRight;
|
|
2053
|
+
break;
|
|
2054
|
+
case 'bottomleft':
|
|
2055
|
+
pos = atlas.ControlPosition.BottomLeft;
|
|
2056
|
+
break;
|
|
2057
|
+
}
|
|
2058
|
+
map.controls.add(new atlas.control.ZoomControl(), { position: pos });
|
|
2059
|
+
});
|
|
2060
|
+
}
|
|
2061
|
+
map.events.add('idle', (e) => {
|
|
2062
|
+
map.getCanvas().toBlob(blob => {
|
|
2063
|
+
this.#blobs.set(container, blob);
|
|
2064
|
+
});
|
|
2065
|
+
});
|
|
2066
|
+
map.events.addOnce('ready', () => {
|
|
2067
|
+
container.dispatchEvent(new MapEvent("maploaded"));
|
|
2068
|
+
});
|
|
2069
|
+
return { map, container: mapElement };
|
|
2070
|
+
}
|
|
2071
|
+
invalidateSize(ctrl) {
|
|
2072
|
+
if (!this.hasMap(ctrl)) {
|
|
2073
|
+
return;
|
|
2074
|
+
}
|
|
2075
|
+
const { map } = this.tryGetMap(ctrl);
|
|
2076
|
+
if (map) {
|
|
2077
|
+
map.resize();
|
|
2078
|
+
}
|
|
2079
|
+
}
|
|
2080
|
+
propertyChangedCallback(name, old, val, first) {
|
|
2081
|
+
super.propertyChangedCallback(name, old, val, first);
|
|
2082
|
+
if (!first && name === 'language') {
|
|
2083
|
+
for (let ctrl of this.enrolledMaps()) {
|
|
2084
|
+
const { map } = this.tryGetMap(ctrl);
|
|
2085
|
+
map.setStyle({ language: val || pacemCore.Utils.lang(ctrl) });
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
2088
|
+
}
|
|
2089
|
+
//#endregion
|
|
2090
|
+
_spinMapUpdateHandler(ctrl, map) {
|
|
2091
|
+
return () => {
|
|
2092
|
+
this._updateMap(ctrl, map);
|
|
2093
|
+
};
|
|
2094
|
+
}
|
|
2095
|
+
_updateMap(ctrl, map) {
|
|
2096
|
+
if (!pacemCore.Utils.isNull(map) && !pacemCore.Utils.isNull(ctrl)) {
|
|
2097
|
+
const camera = map.getCamera(), center = camera.center, zoom = camera.zoom;
|
|
2098
|
+
if (camera.zoom === 1) {
|
|
2099
|
+
console.warn('Azure Maps control lacks in reflecting the actual map zoom onto the camera property. Cannot reflect info back to PacemMapElement.');
|
|
2100
|
+
}
|
|
2101
|
+
else
|
|
2102
|
+
this.updateMapElement(ctrl, AtlasMapUtils.getLatLng(center), zoom);
|
|
2103
|
+
}
|
|
2104
|
+
}
|
|
2105
|
+
static _getBounds(ctrl) {
|
|
2106
|
+
const paddingTop = ctrl.paddingTop || 0, paddingLeft = ctrl.paddingLeft || 0, paddingRight = ctrl.paddingRight || 0, paddingBottom = ctrl.paddingBottom || 0;
|
|
2107
|
+
return { 'top': paddingTop, 'bottom': paddingBottom, 'left': paddingLeft, 'right': paddingRight };
|
|
2108
|
+
}
|
|
2109
|
+
fitBoundsNative(ctrl, bnds, padding = PacemAzureMapAdapterElement_1._getBounds(ctrl)) {
|
|
2110
|
+
const map = this.getMap(ctrl);
|
|
2111
|
+
// TODO: avoid double loop (specially for large sets), just set coords in 'correct' place for Azure maps right away...
|
|
2112
|
+
map.setCamera({ bounds: AtlasMapUtils.getBounds(bnds), padding });
|
|
2113
|
+
//} else {
|
|
2114
|
+
// if (bnds.length === 1) {
|
|
2115
|
+
// map.setCamera({ center: AtlasMapUtils.getPosition(bnds[0]), zoom: ctrl.zoom });
|
|
2116
|
+
// }
|
|
2117
|
+
//}
|
|
2118
|
+
}
|
|
2119
|
+
;
|
|
2120
|
+
};
|
|
2121
|
+
__decorate$2([
|
|
2122
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.String })
|
|
2123
|
+
], PacemAzureMapAdapterElement.prototype, "subscriptionKey", void 0);
|
|
2124
|
+
__decorate$2([
|
|
2125
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.String })
|
|
2126
|
+
], PacemAzureMapAdapterElement.prototype, "language", void 0);
|
|
2127
|
+
__decorate$2([
|
|
2128
|
+
pacemCore.Debounce(500)
|
|
2129
|
+
], PacemAzureMapAdapterElement.prototype, "_updateMap", null);
|
|
2130
|
+
PacemAzureMapAdapterElement = PacemAzureMapAdapterElement_1 = __decorate$2([
|
|
2131
|
+
pacemCore.CustomElement({ tagName: pacemCore.P + '-map-adapter-azure' })
|
|
2132
|
+
], PacemAzureMapAdapterElement);
|
|
2133
|
+
//}
|
|
2134
|
+
|
|
2135
|
+
var __decorate$1 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
2136
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2137
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2138
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2139
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2140
|
+
};
|
|
2141
|
+
// namespace Pacem.Components.Maps {
|
|
2142
|
+
const consts$1 = {
|
|
2143
|
+
API_JS: 'https://cdn.jsdelivr.net/npm/leaflet@1.9.4/dist/leaflet.min.js', //'https://unpkg.com/leaflet@1.5.1/dist/leaflet.js',
|
|
2144
|
+
API_JS_INTEGRITY: null, //'sha512-GffPMF3RvMeYyc1LWMHtK8EbPv0iNZ8/oTtHPx9/cc2ILxQ+u905qIwdpULaqDkyBKgOaB57QTMg7ztg8Jm2Og==',
|
|
2145
|
+
API_CSS: 'https://cdn.jsdelivr.net/npm/leaflet@1.9.4/dist/leaflet.min.css', //'https://unpkg.com/leaflet@1.5.1/dist/leaflet.css',
|
|
2146
|
+
API_CSS_INTEGRITY: null // 'sha512-xwE/Az9zrjBIphAcBb3F6JVqxf46+CDLwfLMHloNu6KEQCAWi6HcDUbeOfBIptF7tcCzusKFjFw2yuvEpDL9wQ=='
|
|
2147
|
+
};
|
|
2148
|
+
function convertAddress(address) {
|
|
2149
|
+
return {
|
|
2150
|
+
city: address.city,
|
|
2151
|
+
state: address.state,
|
|
2152
|
+
provinceCode: address["ISO3166-2-lvl6"]?.split('-')[1],
|
|
2153
|
+
province: address.county,
|
|
2154
|
+
village: address.village,
|
|
2155
|
+
zipCode: address.postcode,
|
|
2156
|
+
streetName: address.road,
|
|
2157
|
+
houseNumber: address.house_number,
|
|
2158
|
+
countryCode: address.country_code?.toUpperCase(),
|
|
2159
|
+
country: address.country
|
|
2160
|
+
};
|
|
2161
|
+
}
|
|
2162
|
+
function convertResponse(r) {
|
|
2163
|
+
return { fullAddress: r.display_name, address: convertAddress(r.address), position: { lat: parseFloat(r.lat), lng: parseFloat(r.lon), altitude: null } };
|
|
2164
|
+
}
|
|
2165
|
+
class LeafletUtils {
|
|
2166
|
+
static toLiteral(bounds) {
|
|
2167
|
+
const ne = bounds.getNorthEast(), sw = bounds.getSouthWest();
|
|
2168
|
+
return { ne, sw };
|
|
2169
|
+
}
|
|
2170
|
+
static parseGeocoding(response) {
|
|
2171
|
+
if (pacemCore.Utils.isNullOrEmpty(response)) {
|
|
2172
|
+
return [];
|
|
2173
|
+
}
|
|
2174
|
+
return response.map(convertResponse);
|
|
2175
|
+
}
|
|
2176
|
+
static parseReverseGeocoding(response) {
|
|
2177
|
+
if (pacemCore.Utils.isNullOrEmpty(response)) {
|
|
2178
|
+
return [];
|
|
2179
|
+
}
|
|
2180
|
+
return [convertResponse(response)];
|
|
2181
|
+
}
|
|
2182
|
+
}
|
|
2183
|
+
const LayerLoadEventName = "layerload";
|
|
2184
|
+
class LayerLoadEvent extends pacemCore.CustomTypedEvent {
|
|
2185
|
+
constructor(layer) {
|
|
2186
|
+
super(LayerLoadEventName, layer, { bubbles: true });
|
|
2187
|
+
}
|
|
2188
|
+
}
|
|
2189
|
+
class PacemLeafletMarkerAdapter extends PacemMarkerAdapter {
|
|
2190
|
+
deleteInfoWindow(info, map) {
|
|
2191
|
+
info.unbindPopup();
|
|
2192
|
+
}
|
|
2193
|
+
deleteMarker(marker, map) {
|
|
2194
|
+
marker.removeFrom(map);
|
|
2195
|
+
}
|
|
2196
|
+
getMarkerPosition(marker) {
|
|
2197
|
+
return marker.getLatLng();
|
|
2198
|
+
}
|
|
2199
|
+
buildMarker(item, map) {
|
|
2200
|
+
return L.marker(item.position).addTo(map);
|
|
2201
|
+
}
|
|
2202
|
+
addClickEventListener(marker, map, callback) {
|
|
2203
|
+
marker.on('click', callback);
|
|
2204
|
+
}
|
|
2205
|
+
addDragEventListener(marker, map, callback) {
|
|
2206
|
+
marker.on('drag', callback);
|
|
2207
|
+
}
|
|
2208
|
+
addDragEndEventListener(marker, map, callback) {
|
|
2209
|
+
marker.on('dragend', callback);
|
|
2210
|
+
}
|
|
2211
|
+
setPosition(marker, position) {
|
|
2212
|
+
marker.setLatLng(position);
|
|
2213
|
+
}
|
|
2214
|
+
setIcon(marker, icon) {
|
|
2215
|
+
const ctrl = this;
|
|
2216
|
+
if (typeof icon === 'string') {
|
|
2217
|
+
// icon url only
|
|
2218
|
+
ctrl._setIcon(marker, icon);
|
|
2219
|
+
}
|
|
2220
|
+
else if (!pacemCore.Utils.isNull(icon)) {
|
|
2221
|
+
// structured icon
|
|
2222
|
+
let options = { iconUrl: icon.url };
|
|
2223
|
+
if (!pacemCore.Utils.isNullOrEmpty(icon.size)) {
|
|
2224
|
+
pacemCore.Utils.extend(options, {
|
|
2225
|
+
iconSize: [icon.size.width, icon.size.height],
|
|
2226
|
+
iconAnchor: [icon.size.width / 2, icon.size.height],
|
|
2227
|
+
popupAnchor: [0, -icon.size.height]
|
|
2228
|
+
});
|
|
2229
|
+
}
|
|
2230
|
+
if (!pacemCore.Utils.isNullOrEmpty(icon.anchor)) {
|
|
2231
|
+
pacemCore.Utils.extend(options, {
|
|
2232
|
+
iconAnchor: [icon.anchor.x, icon.anchor.y]
|
|
2233
|
+
});
|
|
2234
|
+
}
|
|
2235
|
+
ctrl._setIcon(marker, new L.Icon(options));
|
|
2236
|
+
}
|
|
2237
|
+
}
|
|
2238
|
+
setLabel(marker, label) {
|
|
2239
|
+
// not available
|
|
2240
|
+
}
|
|
2241
|
+
setDraggable(marker, draggable) {
|
|
2242
|
+
if (draggable === true) {
|
|
2243
|
+
marker.dragging.enable();
|
|
2244
|
+
}
|
|
2245
|
+
else {
|
|
2246
|
+
marker.dragging.disable();
|
|
2247
|
+
}
|
|
2248
|
+
}
|
|
2249
|
+
closeInfo(marker) {
|
|
2250
|
+
marker.closePopup();
|
|
2251
|
+
}
|
|
2252
|
+
openInfo(info, content, map, marker) {
|
|
2253
|
+
info
|
|
2254
|
+
.bindPopup(content /*, { offset: new L.Point( 0, 0) }*/)
|
|
2255
|
+
.openPopup();
|
|
2256
|
+
}
|
|
2257
|
+
buildInfoWindow(item) {
|
|
2258
|
+
return this.markers.get(item);
|
|
2259
|
+
}
|
|
2260
|
+
addCloseClickEventListener(marker, map, callback) {
|
|
2261
|
+
marker.on('popupclose', callback);
|
|
2262
|
+
}
|
|
2263
|
+
setContent(marker, content) {
|
|
2264
|
+
const popup = marker.getPopup();
|
|
2265
|
+
if (popup && popup.getContent() != content) {
|
|
2266
|
+
marker.setPopupContent(content);
|
|
2267
|
+
}
|
|
2268
|
+
}
|
|
2269
|
+
_setIcon(marker, v) {
|
|
2270
|
+
// legacy (deprecated)
|
|
2271
|
+
if (typeof v === 'string') {
|
|
2272
|
+
var icon = { 'iconUrl': v }, size, anchor, popup;
|
|
2273
|
+
if ((size = this['size']) && /[\d]+,[\d]+/.test(size)) {
|
|
2274
|
+
var ndx = -1;
|
|
2275
|
+
var size0 = [parseInt(size.substring(0, (ndx = size.indexOf(',')))), parseInt(size.substring(ndx + 1))];
|
|
2276
|
+
Object.assign(icon, { 'iconSize': size0 });
|
|
2277
|
+
}
|
|
2278
|
+
if ((anchor = this['anchor']) && /[\d]+,[\d]+/.test(anchor)) {
|
|
2279
|
+
var ndx = -1;
|
|
2280
|
+
var anchor0 = [parseInt(anchor.substring(0, (ndx = anchor.indexOf(',')))), parseInt(anchor.substring(ndx + 1))];
|
|
2281
|
+
Object.assign(icon, { 'iconAnchor': anchor0, 'popupAnchor': [0, -anchor0[1]] });
|
|
2282
|
+
}
|
|
2283
|
+
if ((popup = this['popupAnchor']) && /[\d]+,[\d]+/.test(popup)) {
|
|
2284
|
+
var ndx = -1;
|
|
2285
|
+
var anchor0 = [parseInt(anchor.substring(0, (ndx = anchor.indexOf(',')))), parseInt(anchor.substring(ndx + 1))];
|
|
2286
|
+
Object.assign(icon, { 'popupAnchor': anchor0 });
|
|
2287
|
+
}
|
|
2288
|
+
marker.setIcon(L.icon(icon));
|
|
2289
|
+
}
|
|
2290
|
+
// good
|
|
2291
|
+
else if (v)
|
|
2292
|
+
marker.setIcon(v);
|
|
2293
|
+
}
|
|
2294
|
+
}
|
|
2295
|
+
class PacemLeafletShapeAdapter extends PacemShapeAdapter {
|
|
2296
|
+
addDragStartEventListener(shape, callback) {
|
|
2297
|
+
throw new Error("Method not implemented.");
|
|
2298
|
+
}
|
|
2299
|
+
deleteShape(shape, map) {
|
|
2300
|
+
throw new Error("Method not implemented.");
|
|
2301
|
+
}
|
|
2302
|
+
getShapeBounds(shape) {
|
|
2303
|
+
throw new Error("Method not implemented.");
|
|
2304
|
+
}
|
|
2305
|
+
getShapePosition(obj) {
|
|
2306
|
+
throw new Error("Method not implemented.");
|
|
2307
|
+
}
|
|
2308
|
+
buildShape(item, map) {
|
|
2309
|
+
throw new Error("Method not implemented.");
|
|
2310
|
+
}
|
|
2311
|
+
addClickEventListener(shape, callback) {
|
|
2312
|
+
throw new Error("Method not implemented.");
|
|
2313
|
+
}
|
|
2314
|
+
addDragEventListener(shape, callback) {
|
|
2315
|
+
throw new Error("Method not implemented.");
|
|
2316
|
+
}
|
|
2317
|
+
addDragEndEventListener(shape, callback) {
|
|
2318
|
+
throw new Error("Method not implemented.");
|
|
2319
|
+
}
|
|
2320
|
+
setShape(shape, item) {
|
|
2321
|
+
throw new Error("Method not implemented.");
|
|
2322
|
+
}
|
|
2323
|
+
setEditable(shape, editable) {
|
|
2324
|
+
throw new Error("Method not implemented.");
|
|
2325
|
+
}
|
|
2326
|
+
setDraggable(shape, draggable) {
|
|
2327
|
+
throw new Error("Method not implemented.");
|
|
2328
|
+
}
|
|
2329
|
+
}
|
|
2330
|
+
class PacemLeafletLayerAdapter extends PacemLayerAdapter {
|
|
2331
|
+
addLoadEventListener(layer, map, callback) {
|
|
2332
|
+
layer.on('load', callback);
|
|
2333
|
+
}
|
|
2334
|
+
removeLoadEventListener(layer, map, callback) {
|
|
2335
|
+
layer.off('load', callback);
|
|
2336
|
+
}
|
|
2337
|
+
deleteLayer(layer, map) {
|
|
2338
|
+
layer.remove();
|
|
2339
|
+
}
|
|
2340
|
+
buildLayer(item, map) {
|
|
2341
|
+
const mode = (item.mode || '').toLowerCase();
|
|
2342
|
+
switch (mode) {
|
|
2343
|
+
case 'wms':
|
|
2344
|
+
return L.tileLayer.wms(item.url, { layers: (item.include || []).join(','), minZoom: item.minZoom, maxZoom: item.maxZoom, transparent: true, format: 'image/png' }).addTo(map);
|
|
2345
|
+
default:
|
|
2346
|
+
return L.tileLayer(item.url, { tms: mode === 'tms', minZoom: item.minZoom, maxZoom: item.maxZoom }).addTo(map);
|
|
2347
|
+
}
|
|
2348
|
+
}
|
|
2349
|
+
}
|
|
2350
|
+
class PacemLeafletOverlayAdapter extends PacemOverlayAdapter {
|
|
2351
|
+
deleteOverlay(overlay, map) {
|
|
2352
|
+
throw new Error("Method not implemented.");
|
|
2353
|
+
}
|
|
2354
|
+
buildOverlay(item, map) {
|
|
2355
|
+
throw new Error("Method not implemented.");
|
|
2356
|
+
}
|
|
2357
|
+
setBounds(item, map, bounds) {
|
|
2358
|
+
throw new Error("Method not implemented.");
|
|
2359
|
+
}
|
|
2360
|
+
updateOverlay(overlay, map, item) {
|
|
2361
|
+
throw new Error("Method not implemented.");
|
|
2362
|
+
}
|
|
2363
|
+
}
|
|
2364
|
+
let PacemLeafletMapAdapterElement = class PacemLeafletMapAdapterElement extends PacemMapAdapterElement {
|
|
2365
|
+
constructor() {
|
|
2366
|
+
super(...arguments);
|
|
2367
|
+
this.#tileLayers = new WeakMap();
|
|
2368
|
+
this.tiles = '//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
|
|
2369
|
+
this.attribution = 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors';
|
|
2370
|
+
this._tileLayerLoadHandler = (evt) => {
|
|
2371
|
+
this.dispatchLayerLoadEvent(evt.sourceTarget);
|
|
2372
|
+
};
|
|
2373
|
+
//#endregion
|
|
2374
|
+
this._mapUpdateHandler = (ctrl) => {
|
|
2375
|
+
const map = this.getMap(ctrl);
|
|
2376
|
+
if (!pacemCore.Utils.isNull(map) && !pacemCore.Utils.isNull(ctrl)) {
|
|
2377
|
+
this.updateMapElement(ctrl, map.getCenter(), map.getZoom());
|
|
2378
|
+
}
|
|
2379
|
+
};
|
|
2380
|
+
}
|
|
2381
|
+
buildOverlayAdapterFor(map) {
|
|
2382
|
+
return new PacemLeafletOverlayAdapter(map, this);
|
|
2383
|
+
}
|
|
2384
|
+
geocode(address, maxResults) {
|
|
2385
|
+
return new PacemNominatimMapGeocoder().geocode(address, maxResults, pacemCore.Utils.lang(this));
|
|
2386
|
+
}
|
|
2387
|
+
reverseGeocode(latLng, _) {
|
|
2388
|
+
return new PacemNominatimMapGeocoder().reverseGeocode(latLng, pacemCore.Utils.lang(this));
|
|
2389
|
+
}
|
|
2390
|
+
getBounds(ctrl) {
|
|
2391
|
+
const nativeMap = this.getMap(ctrl);
|
|
2392
|
+
const bounds = nativeMap.getBounds();
|
|
2393
|
+
return LeafletUtils.toLiteral(bounds);
|
|
2394
|
+
}
|
|
2395
|
+
isActive() {
|
|
2396
|
+
return true;
|
|
2397
|
+
}
|
|
2398
|
+
setViewNative(ctrl, options) {
|
|
2399
|
+
const map = this.getMap(ctrl);
|
|
2400
|
+
if (options.center) {
|
|
2401
|
+
map.setView(options.center, options.zoom ?? map.getZoom(), { animate: true });
|
|
2402
|
+
}
|
|
2403
|
+
else if (typeof options.zoom === 'number') {
|
|
2404
|
+
map.setZoom(options.zoom, { animate: true });
|
|
2405
|
+
}
|
|
2406
|
+
}
|
|
2407
|
+
buildMarkerAdapterFor(map) {
|
|
2408
|
+
return new PacemLeafletMarkerAdapter(map, this);
|
|
2409
|
+
}
|
|
2410
|
+
buildShapeAdapterFor(map) {
|
|
2411
|
+
return new PacemLeafletShapeAdapter(map, this);
|
|
2412
|
+
}
|
|
2413
|
+
buildLayerAdapterFor(map) {
|
|
2414
|
+
return new PacemLeafletLayerAdapter(map, this);
|
|
2415
|
+
}
|
|
2416
|
+
#tileLayers;
|
|
2417
|
+
snapshot(map, type = 'image/png', quality) {
|
|
2418
|
+
return pacemCore.Utils.snapshotElement(map.container.firstElementChild, null, type, quality);
|
|
2419
|
+
}
|
|
2420
|
+
propertyChangedCallback(name, old, val, first) {
|
|
2421
|
+
super.propertyChangedCallback(name, old, val, first);
|
|
2422
|
+
switch (name) {
|
|
2423
|
+
case 'tiles':
|
|
2424
|
+
for (let map of this.enrolledMaps()) {
|
|
2425
|
+
this._redrawMap(map);
|
|
2426
|
+
}
|
|
2427
|
+
default:
|
|
2428
|
+
for (let map of this.enrolledMaps()) {
|
|
2429
|
+
this.invalidateSize(map);
|
|
2430
|
+
}
|
|
2431
|
+
break;
|
|
2432
|
+
}
|
|
2433
|
+
}
|
|
2434
|
+
// #region ABSTRACT IMPLEMENTATION
|
|
2435
|
+
dispose(ctrl) {
|
|
2436
|
+
const { map } = this.tryGetMap(ctrl);
|
|
2437
|
+
const tiles = this.#tileLayers.get(ctrl);
|
|
2438
|
+
if (tiles) {
|
|
2439
|
+
tiles.off('load', this._tileLayerLoadHandler);
|
|
2440
|
+
}
|
|
2441
|
+
map.clearAllEventListeners();
|
|
2442
|
+
this.#tileLayers.delete(ctrl);
|
|
2443
|
+
}
|
|
2444
|
+
async init(container) {
|
|
2445
|
+
await Promise.all([pacemCore.CustomElementUtils.importjs(consts$1.API_JS, consts$1.API_JS_INTEGRITY, true),
|
|
2446
|
+
pacemCore.CustomElementUtils.importcss(consts$1.API_CSS, consts$1.API_CSS_INTEGRITY, true)]);
|
|
2447
|
+
const ctrl = container;
|
|
2448
|
+
var scale = ctrl.scale;
|
|
2449
|
+
var draggable = ctrl.draggable;
|
|
2450
|
+
var dblClickZoom = ctrl.doubleClickZoom;
|
|
2451
|
+
var kbShortcuts = ctrl.keyboardShortcuts;
|
|
2452
|
+
//
|
|
2453
|
+
var center = L.latLng(MapUtils.parseCoords(ctrl.center));
|
|
2454
|
+
var mapOptions = {
|
|
2455
|
+
zoomControl: scale && !pacemCore.Utils.isNullOrEmpty(ctrl.zoomControl),
|
|
2456
|
+
scrollWheelZoom: ctrl.mousewheel,
|
|
2457
|
+
dragging: draggable,
|
|
2458
|
+
doubleClickZoom: !dblClickZoom,
|
|
2459
|
+
keyboard: kbShortcuts
|
|
2460
|
+
};
|
|
2461
|
+
const canvas = ctrl.container;
|
|
2462
|
+
const mapElement = document.createElement('div');
|
|
2463
|
+
mapElement.style.width = '100%';
|
|
2464
|
+
mapElement.style.height = '100%';
|
|
2465
|
+
canvas.innerHTML = '';
|
|
2466
|
+
canvas.appendChild(mapElement);
|
|
2467
|
+
const map = L.map(mapElement, mapOptions);
|
|
2468
|
+
['zoomend', 'moveend'].forEach(evt => {
|
|
2469
|
+
map.on(evt, _ => {
|
|
2470
|
+
this._idleFiller(ctrl);
|
|
2471
|
+
this._mapUpdateHandler(ctrl);
|
|
2472
|
+
});
|
|
2473
|
+
});
|
|
2474
|
+
map.on('load', () => {
|
|
2475
|
+
if (scale && ctrl.zoomControl) {
|
|
2476
|
+
map.zoomControl.setPosition(ctrl['zoomControl']);
|
|
2477
|
+
}
|
|
2478
|
+
this._idleFiller(ctrl);
|
|
2479
|
+
});
|
|
2480
|
+
const tiles = L.tileLayer(this.tiles, { attribution: this.attribution }).addTo(map);
|
|
2481
|
+
tiles.on('load', this._tileLayerLoadHandler);
|
|
2482
|
+
this.#tileLayers.set(ctrl, tiles);
|
|
2483
|
+
// setting now the center and zoom, triggers the "load" event and activates the child-components, if any.
|
|
2484
|
+
/*
|
|
2485
|
+
LeafletJS docs: Map's "load" Event
|
|
2486
|
+
"Fired when the map is initialized (when its center and zoom are set for the first time)."
|
|
2487
|
+
(http://leafletjs.com/reference.html#map-events)
|
|
2488
|
+
*/
|
|
2489
|
+
map.setView(center, ctrl.zoom);
|
|
2490
|
+
// first-load
|
|
2491
|
+
map.once('idle', function () {
|
|
2492
|
+
map.fire('resize');
|
|
2493
|
+
container.dispatchEvent(new MapEvent("maploaded"));
|
|
2494
|
+
});
|
|
2495
|
+
// call setView NOW to trigger the load event :(
|
|
2496
|
+
const cnt = MapUtils.parseCoords(ctrl.center), xpr = [cnt[0], cnt[1]];
|
|
2497
|
+
map.setView(xpr, ctrl.zoom);
|
|
2498
|
+
return { map, container: mapElement };
|
|
2499
|
+
}
|
|
2500
|
+
dispatchLayerLoadEvent(layer) {
|
|
2501
|
+
this.dispatchEvent(new LayerLoadEvent(layer));
|
|
2502
|
+
}
|
|
2503
|
+
invalidateSize(ctrl) {
|
|
2504
|
+
if (this.hasMap(ctrl)) {
|
|
2505
|
+
const map = this.getMap(ctrl);
|
|
2506
|
+
map.invalidateSize();
|
|
2507
|
+
}
|
|
2508
|
+
}
|
|
2509
|
+
_idleFiller(ctrl) {
|
|
2510
|
+
if (this.hasMap(ctrl)) {
|
|
2511
|
+
const map = this.getMap(ctrl);
|
|
2512
|
+
map.fire('idle');
|
|
2513
|
+
}
|
|
2514
|
+
}
|
|
2515
|
+
fitBoundsNative(ctrl, bounds, padding = { top: ctrl.paddingTop || 0, left: ctrl.paddingLeft || 0, right: ctrl.paddingRight || 0, bottom: ctrl.paddingBottom || 0 }) {
|
|
2516
|
+
const map = this.getMap(ctrl);
|
|
2517
|
+
const pads = { 'paddingTopLeft': new L.Point(padding.left, padding.top), 'paddingBottomRight': new L.Point(padding.right, padding.bottom) };
|
|
2518
|
+
const ne = bounds.ne, sw = bounds.sw;
|
|
2519
|
+
try {
|
|
2520
|
+
map.fitBounds([[ne.lat, ne.lng], [sw.lat, sw.lng]], pads);
|
|
2521
|
+
}
|
|
2522
|
+
catch (e) {
|
|
2523
|
+
throw e;
|
|
2524
|
+
}
|
|
2525
|
+
}
|
|
2526
|
+
;
|
|
2527
|
+
_redrawMap(map) {
|
|
2528
|
+
var ctrl = this, tileLayer = ctrl.#tileLayers.get(map);
|
|
2529
|
+
if (!pacemCore.Utils.isNull(ctrl.tiles && tileLayer)) {
|
|
2530
|
+
tileLayer.setUrl(ctrl.tiles);
|
|
2531
|
+
}
|
|
2532
|
+
}
|
|
2533
|
+
};
|
|
2534
|
+
__decorate$1([
|
|
2535
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.String })
|
|
2536
|
+
], PacemLeafletMapAdapterElement.prototype, "tiles", void 0);
|
|
2537
|
+
__decorate$1([
|
|
2538
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.String })
|
|
2539
|
+
], PacemLeafletMapAdapterElement.prototype, "attribution", void 0);
|
|
2540
|
+
__decorate$1([
|
|
2541
|
+
pacemCore.Debounce(500)
|
|
2542
|
+
], PacemLeafletMapAdapterElement.prototype, "_idleFiller", null);
|
|
2543
|
+
PacemLeafletMapAdapterElement = __decorate$1([
|
|
2544
|
+
pacemCore.CustomElement({ tagName: pacemCore.P + '-map-adapter-leaflet' })
|
|
2545
|
+
], PacemLeafletMapAdapterElement);
|
|
2546
|
+
//#region geocoders
|
|
2547
|
+
class PacemNominatimMapGeocoder {
|
|
2548
|
+
_buildGeocodeRequest(search, maxResults = 10, language = '') {
|
|
2549
|
+
// https://nominatim.openstreetmap.org/search?addressdetails=1&format=json&limit={limit}&accept-language={culture}&q={q}
|
|
2550
|
+
const url = 'https://nominatim.openstreetmap.org/search?addressdetails=1&format=json';
|
|
2551
|
+
const query = { q: search, limit: '' + maxResults, 'accept-language': language };
|
|
2552
|
+
return {
|
|
2553
|
+
uri: pacemCore.Utils.URIs.appendQuery(url, query),
|
|
2554
|
+
options: {
|
|
2555
|
+
mode: 'cors' //, headers: {}
|
|
2556
|
+
}
|
|
2557
|
+
};
|
|
2558
|
+
}
|
|
2559
|
+
parseGeocodeResponse(response) {
|
|
2560
|
+
return new Promise((resolve, reject) => {
|
|
2561
|
+
response.json().then((r) => {
|
|
2562
|
+
const retval = LeafletUtils.parseGeocoding(r);
|
|
2563
|
+
resolve(retval);
|
|
2564
|
+
}, e => reject(e));
|
|
2565
|
+
});
|
|
2566
|
+
}
|
|
2567
|
+
geocode(address, maxResults = 10, language = '') {
|
|
2568
|
+
return new Promise((resolve, reject) => {
|
|
2569
|
+
const request = this._buildGeocodeRequest(address, maxResults, language);
|
|
2570
|
+
return fetch(request.uri, request.options).then(response => {
|
|
2571
|
+
if (response.ok) {
|
|
2572
|
+
this.parseGeocodeResponse(response).then(resolve, reject);
|
|
2573
|
+
}
|
|
2574
|
+
else {
|
|
2575
|
+
reject(response);
|
|
2576
|
+
}
|
|
2577
|
+
}, e => reject(e));
|
|
2578
|
+
});
|
|
2579
|
+
}
|
|
2580
|
+
reverseGeocode(latLng, language = '') {
|
|
2581
|
+
return new Promise((resolve, reject) => {
|
|
2582
|
+
const request = this._buildReverseRequest(latLng, language);
|
|
2583
|
+
return fetch(request.uri, request.options).then(response => {
|
|
2584
|
+
if (response.ok) {
|
|
2585
|
+
this._parseReverseResponse(response).then(resolve, reject);
|
|
2586
|
+
}
|
|
2587
|
+
else {
|
|
2588
|
+
reject(response);
|
|
2589
|
+
}
|
|
2590
|
+
}, e => reject(e));
|
|
2591
|
+
});
|
|
2592
|
+
}
|
|
2593
|
+
_buildReverseRequest(position, language = '') {
|
|
2594
|
+
// https://nominatim.openstreetmap.org/reverse?addressdetails=1&format=json&accept-language={culture}&lat={lat}&lon={lng}
|
|
2595
|
+
const url = 'https://nominatim.openstreetmap.org/reverse?addressdetails=1&format=json';
|
|
2596
|
+
const latLng = MapUtils.parseCoords(position);
|
|
2597
|
+
const query = {
|
|
2598
|
+
lat: '' + latLng[0],
|
|
2599
|
+
lon: '' + latLng[1],
|
|
2600
|
+
'accept-language': language
|
|
2601
|
+
};
|
|
2602
|
+
return {
|
|
2603
|
+
uri: pacemCore.Utils.URIs.appendQuery(url, query),
|
|
2604
|
+
options: {
|
|
2605
|
+
mode: 'cors' //, headers: {}
|
|
2606
|
+
}
|
|
2607
|
+
};
|
|
2608
|
+
}
|
|
2609
|
+
_parseReverseResponse(response) {
|
|
2610
|
+
return new Promise((resolve, reject) => {
|
|
2611
|
+
response.json().then((r) => {
|
|
2612
|
+
const retval = LeafletUtils.parseReverseGeocoding(r);
|
|
2613
|
+
resolve(retval);
|
|
2614
|
+
}, e => reject(e));
|
|
2615
|
+
});
|
|
2616
|
+
}
|
|
2617
|
+
}
|
|
2618
|
+
//#endregion
|
|
2619
|
+
//}
|
|
2620
|
+
|
|
2621
|
+
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
2622
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2623
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2624
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2625
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2626
|
+
};
|
|
2627
|
+
// namespace Pacem.Components.Maps {
|
|
2628
|
+
const consts = {
|
|
2629
|
+
DETACH_TIMEOUT: 200,
|
|
2630
|
+
/**@deprecated */
|
|
2631
|
+
API_URI: 'https://maps.googleapis.com/maps/api/js',
|
|
2632
|
+
MAX_ROADMAP_ZOOM: 22,
|
|
2633
|
+
//MAX_SATELLITE_ZOOM: 22,
|
|
2634
|
+
BOOTSTRAP_SNIPPET: (key, lang, region, v) => {
|
|
2635
|
+
return `(g=>{var h,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement("script"));e.set("libraries",[...r]+"");for(k in g)e.set(k.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),g[k]);e.set("callback",c+".maps."+q);a.src=\`https://maps.$\{c\}apis.com/maps/api/js?\`+e;d[q]=f;a.onerror=()=>h=n(Error(p+" could not load."));a.nonce=m.querySelector("script[nonce]")?.nonce||"";m.head.append(a)}));d[l]?console.warn(p+" only loads once. Ignoring:",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})({
|
|
2636
|
+
key: "${key}", v: "${v}", language: "${lang}", region: "${region}",
|
|
2637
|
+
// Add other bootstrap parameters as needed, using camel case.
|
|
2638
|
+
});`;
|
|
2639
|
+
},
|
|
2640
|
+
MAPS_NOT_FOUND: 'google.maps not found.',
|
|
2641
|
+
GEOCODER_UNAVAILABLE: 'google.maps geocoder unavailable.',
|
|
2642
|
+
INVALID_KEY: 'invalid google.maps api key.',
|
|
2643
|
+
TILE_EXTENT: [-Math.PI * 6378137, Math.PI * 6378137],
|
|
2644
|
+
};
|
|
2645
|
+
class Bootstrapper {
|
|
2646
|
+
#promise;
|
|
2647
|
+
#params;
|
|
2648
|
+
_equivalent(key, language, region, version) {
|
|
2649
|
+
const guard = this.#params;
|
|
2650
|
+
return !pacemCore.Utils.isNull(guard)
|
|
2651
|
+
&& guard.key === key
|
|
2652
|
+
// fallback on curreny values when not explicitated
|
|
2653
|
+
&& guard.language === (language || guard.language)
|
|
2654
|
+
&& guard.region === (region || guard.region)
|
|
2655
|
+
&& guard.version === (version || guard.version);
|
|
2656
|
+
}
|
|
2657
|
+
_spinFuture(key, language, region, version) {
|
|
2658
|
+
return new Promise((resolve, reject) => {
|
|
2659
|
+
// check if already bootstrapped with the same variables
|
|
2660
|
+
if (!this._equivalent(key, language, region, version)) {
|
|
2661
|
+
Bootstrapper._ensureBootstrapScript(key, language, region, version);
|
|
2662
|
+
}
|
|
2663
|
+
this.#params = { language, region, version, key };
|
|
2664
|
+
google.maps.importLibrary("maps").then(_ => {
|
|
2665
|
+
resolve();
|
|
2666
|
+
this.#promise = null;
|
|
2667
|
+
}, e => {
|
|
2668
|
+
reject(e);
|
|
2669
|
+
this.#promise = null;
|
|
2670
|
+
});
|
|
2671
|
+
});
|
|
2672
|
+
}
|
|
2673
|
+
boostrap(key, language, region, version = 'weekly') {
|
|
2674
|
+
if (pacemCore.Utils.isNullOrEmpty(key)) {
|
|
2675
|
+
return Promise.reject(consts.INVALID_KEY);
|
|
2676
|
+
}
|
|
2677
|
+
if (pacemCore.Utils.isNull(this.#promise) || !this._equivalent(key, language, region, version)) {
|
|
2678
|
+
this.#promise = this._spinFuture(key, language, region, version);
|
|
2679
|
+
}
|
|
2680
|
+
return this.#promise;
|
|
2681
|
+
}
|
|
2682
|
+
static _ensureBootstrapScript(key, language, region, v) {
|
|
2683
|
+
const uniqueAttrName = 'pacem-googlemaps';
|
|
2684
|
+
const uniqueAttrValue = `v=${v},l=${language},r=${region}`;
|
|
2685
|
+
let script = document.querySelector(`script[${uniqueAttrName}]`);
|
|
2686
|
+
if (!pacemCore.Utils.isNull(script)) {
|
|
2687
|
+
if (script.getAttribute(uniqueAttrName) === uniqueAttrValue) {
|
|
2688
|
+
return;
|
|
2689
|
+
}
|
|
2690
|
+
else {
|
|
2691
|
+
script.remove();
|
|
2692
|
+
document.querySelectorAll('script[src^=\'https://maps.googleapis.com/maps\']').forEach(i => i.remove());
|
|
2693
|
+
delete window['google'];
|
|
2694
|
+
}
|
|
2695
|
+
}
|
|
2696
|
+
if (pacemCore.Utils.isNullOrEmpty(key)) {
|
|
2697
|
+
return;
|
|
2698
|
+
}
|
|
2699
|
+
script = document.createElement('script');
|
|
2700
|
+
script.setAttribute(uniqueAttrName, uniqueAttrValue);
|
|
2701
|
+
script.textContent = consts.BOOTSTRAP_SNIPPET(key, language, region, v);
|
|
2702
|
+
document.head.appendChild(script);
|
|
2703
|
+
}
|
|
2704
|
+
}
|
|
2705
|
+
/** Bootstrapper singleton. */
|
|
2706
|
+
const bootstrapper = new Bootstrapper();
|
|
2707
|
+
class GMapsUtils {
|
|
2708
|
+
static getPosition(latLng) {
|
|
2709
|
+
if (Array.isArray(latLng)) {
|
|
2710
|
+
return { lat: latLng[0], lng: latLng[1] };
|
|
2711
|
+
}
|
|
2712
|
+
return latLng;
|
|
2713
|
+
}
|
|
2714
|
+
static getBounds(bnds) {
|
|
2715
|
+
if (pacemCore.Utils.isNullOrEmpty(bnds)) {
|
|
2716
|
+
return null;
|
|
2717
|
+
}
|
|
2718
|
+
return { north: bnds.ne.lat, east: bnds.ne.lng, south: bnds.sw.lat, west: bnds.sw.lng };
|
|
2719
|
+
}
|
|
2720
|
+
static mapGeocodeResults(a, b = []) {
|
|
2721
|
+
const retval = [];
|
|
2722
|
+
a ??= [];
|
|
2723
|
+
for (let j = 0; j < a.length; j++) {
|
|
2724
|
+
const elevation = b.length > j ? b[j] : null;
|
|
2725
|
+
const address = GMapsUtils.mapGeocodeResult(a[j], elevation);
|
|
2726
|
+
retval.push(address);
|
|
2727
|
+
}
|
|
2728
|
+
return retval;
|
|
2729
|
+
}
|
|
2730
|
+
static mapGeocodeResult(a, b) {
|
|
2731
|
+
const address = a?.address_components || [];
|
|
2732
|
+
const buildingNumber = address.find(a => a.types.indexOf('street_number') >= 0)?.long_name;
|
|
2733
|
+
const streetName = address.find(a => a.types.indexOf('route') >= 0)?.long_name;
|
|
2734
|
+
const city = address.find(a => a.types.indexOf('locality') >= 0)?.long_name;
|
|
2735
|
+
const comune = address.find(a => a.types.indexOf("administrative_area_level_3") >= 0)?.long_name;
|
|
2736
|
+
const provinceObj = address.find(a => a.types.indexOf("administrative_area_level_2") >= 0);
|
|
2737
|
+
const region = address.find(a => a.types.indexOf("administrative_area_level_1") >= 0)?.short_name;
|
|
2738
|
+
const countryObj = address.find(a => a.types.indexOf("country") >= 0);
|
|
2739
|
+
const zipCode = address.find(a => a.types.indexOf("postal_code") >= 0)?.short_name;
|
|
2740
|
+
const structuredAddress = {
|
|
2741
|
+
houseNumber: buildingNumber,
|
|
2742
|
+
city: comune || city,
|
|
2743
|
+
provinceCode: provinceObj?.short_name,
|
|
2744
|
+
province: provinceObj?.long_name,
|
|
2745
|
+
countryCode: countryObj?.short_name,
|
|
2746
|
+
country: countryObj?.long_name,
|
|
2747
|
+
zipCode,
|
|
2748
|
+
streetName,
|
|
2749
|
+
state: region,
|
|
2750
|
+
village: city,
|
|
2751
|
+
type: a.geometry.location_type
|
|
2752
|
+
};
|
|
2753
|
+
const retval = {
|
|
2754
|
+
fullAddress: a.formatted_address,
|
|
2755
|
+
position: GMapsUtils.toLiteral(a.geometry.location, b?.elevation),
|
|
2756
|
+
address: structuredAddress
|
|
2757
|
+
};
|
|
2758
|
+
return retval;
|
|
2759
|
+
}
|
|
2760
|
+
static toLiteral(l, e) {
|
|
2761
|
+
if (pacemCore.Utils.isNull(l)) {
|
|
2762
|
+
return null;
|
|
2763
|
+
}
|
|
2764
|
+
if ('lat' in l && typeof l.lat === 'function' && 'lng' in l && typeof l.lng === 'function') {
|
|
2765
|
+
return { lat: l.lat(), lng: l.lng(), altitude: e };
|
|
2766
|
+
}
|
|
2767
|
+
if ('getNorthEast' in l && typeof l.getNorthEast === 'function' && 'getSouthWest' in l && typeof l.getSouthWest === 'function') {
|
|
2768
|
+
const ne = l.getNorthEast(), sw = l.getSouthWest();
|
|
2769
|
+
return { ne: GMapsUtils.toLiteral(ne), sw: GMapsUtils.toLiteral(sw) };
|
|
2770
|
+
}
|
|
2771
|
+
if ('north' in l && typeof l.north === 'number'
|
|
2772
|
+
&& 'south' in l && typeof l.south === 'number'
|
|
2773
|
+
&& 'west' in l && typeof l.west === 'number'
|
|
2774
|
+
&& 'east' in l && typeof l.east === 'number') {
|
|
2775
|
+
return {
|
|
2776
|
+
ne: { lat: l.north, lng: l.east }, sw: { lat: l.south, lng: l.west }
|
|
2777
|
+
};
|
|
2778
|
+
}
|
|
2779
|
+
return pacemCore.Utils.extend({ altitude: e }, l);
|
|
2780
|
+
}
|
|
2781
|
+
static areEqual(l1, l2) {
|
|
2782
|
+
if (pacemCore.Utils.isNull(l1) || pacemCore.Utils.isNull(l2)) {
|
|
2783
|
+
return false;
|
|
2784
|
+
}
|
|
2785
|
+
const latLng1 = GMapsUtils.toLiteral(l1), latLng2 = GMapsUtils.toLiteral(l2);
|
|
2786
|
+
return latLng1.lat === latLng2.lat && latLng1.lng === latLng2.lng;
|
|
2787
|
+
}
|
|
2788
|
+
static fitBounds(map, bnds, padding) {
|
|
2789
|
+
//map.panToBounds(bnds, padding);
|
|
2790
|
+
map?.fitBounds(bnds, padding);
|
|
2791
|
+
}
|
|
2792
|
+
static setCenter(map, center) {
|
|
2793
|
+
if (!pacemCore.Utils.isNull(map) && !GMapsUtils.areEqual(map.getCenter(), center)) {
|
|
2794
|
+
map.panTo(center);
|
|
2795
|
+
//map.setCenter(center);
|
|
2796
|
+
}
|
|
2797
|
+
}
|
|
2798
|
+
}
|
|
2799
|
+
class PacemGoogleShapeAdapter extends PacemShapeAdapter {
|
|
2800
|
+
getShapeBounds(shape) {
|
|
2801
|
+
const bnds = new google.maps.LatLngBounds();
|
|
2802
|
+
if (shape instanceof google.maps.Circle) {
|
|
2803
|
+
const b = shape.getBounds();
|
|
2804
|
+
if (b) {
|
|
2805
|
+
bnds.extend(b.getNorthEast());
|
|
2806
|
+
bnds.extend(b.getSouthWest());
|
|
2807
|
+
}
|
|
2808
|
+
}
|
|
2809
|
+
else if (shape instanceof google.maps.Polygon) {
|
|
2810
|
+
shape.getPath().forEach(l => bnds.extend(l));
|
|
2811
|
+
}
|
|
2812
|
+
else if (shape instanceof google.maps.Polyline) {
|
|
2813
|
+
shape.getPath().forEach(l => bnds.extend(l));
|
|
2814
|
+
}
|
|
2815
|
+
if (bnds.isEmpty() !== false) {
|
|
2816
|
+
return LatLngBounds.Empty;
|
|
2817
|
+
}
|
|
2818
|
+
return GMapsUtils.toLiteral(bnds);
|
|
2819
|
+
}
|
|
2820
|
+
deleteShape(shape, map) {
|
|
2821
|
+
shape.setMap(null);
|
|
2822
|
+
}
|
|
2823
|
+
getShapePosition(obj) {
|
|
2824
|
+
if ('latLng' in obj) {
|
|
2825
|
+
return obj.latLng;
|
|
2826
|
+
}
|
|
2827
|
+
return null;
|
|
2828
|
+
}
|
|
2829
|
+
buildShape(item, map) {
|
|
2830
|
+
const clickable = true;
|
|
2831
|
+
if (item instanceof PacemMapPolylineElement) {
|
|
2832
|
+
return new google.maps.Polyline({
|
|
2833
|
+
path: item.vertices,
|
|
2834
|
+
clickable,
|
|
2835
|
+
map
|
|
2836
|
+
});
|
|
2837
|
+
}
|
|
2838
|
+
if (item instanceof PacemMapPolygonElement) {
|
|
2839
|
+
return new google.maps.Polygon({
|
|
2840
|
+
paths: [item.vertices],
|
|
2841
|
+
clickable,
|
|
2842
|
+
map
|
|
2843
|
+
});
|
|
2844
|
+
}
|
|
2845
|
+
if (item instanceof PacemMapCircleElement) {
|
|
2846
|
+
return new google.maps.Circle({
|
|
2847
|
+
center: item.center,
|
|
2848
|
+
radius: item.radius,
|
|
2849
|
+
clickable,
|
|
2850
|
+
map
|
|
2851
|
+
});
|
|
2852
|
+
}
|
|
2853
|
+
return null;
|
|
2854
|
+
}
|
|
2855
|
+
addClickEventListener(shape, callback) {
|
|
2856
|
+
shape.addListener('click', callback);
|
|
2857
|
+
}
|
|
2858
|
+
addDragEventListener(shape, callback) {
|
|
2859
|
+
shape.addListener('drag', callback);
|
|
2860
|
+
}
|
|
2861
|
+
addDragStartEventListener(shape, callback) {
|
|
2862
|
+
shape.addListener('dragstart', callback);
|
|
2863
|
+
}
|
|
2864
|
+
addDragEndEventListener(shape, callback) {
|
|
2865
|
+
shape.addListener('dragend', callback);
|
|
2866
|
+
}
|
|
2867
|
+
setShape(shape, item) {
|
|
2868
|
+
if (item instanceof PacemMapPolylineElement) {
|
|
2869
|
+
const polyline = shape;
|
|
2870
|
+
polyline.setOptions({
|
|
2871
|
+
strokeColor: item.stroke?.color,
|
|
2872
|
+
strokeOpacity: item.stroke?.alpha ?? 1,
|
|
2873
|
+
strokeWeight: item.stroke?.thickness,
|
|
2874
|
+
path: item.vertices,
|
|
2875
|
+
});
|
|
2876
|
+
}
|
|
2877
|
+
if (item instanceof PacemMapPolygonElement) {
|
|
2878
|
+
const polygon = shape;
|
|
2879
|
+
polygon.setOptions({
|
|
2880
|
+
strokeColor: item.stroke?.color,
|
|
2881
|
+
strokeOpacity: item.stroke?.alpha ?? 1,
|
|
2882
|
+
strokeWeight: item.stroke?.thickness,
|
|
2883
|
+
strokePosition: google.maps.StrokePosition.CENTER,
|
|
2884
|
+
fillColor: item.fill?.color,
|
|
2885
|
+
fillOpacity: item.fill?.alpha,
|
|
2886
|
+
paths: [item.vertices]
|
|
2887
|
+
});
|
|
2888
|
+
}
|
|
2889
|
+
if (item instanceof PacemMapCircleElement) {
|
|
2890
|
+
const circle = shape;
|
|
2891
|
+
circle.setOptions({
|
|
2892
|
+
strokeColor: item.stroke?.color,
|
|
2893
|
+
strokeOpacity: item.stroke?.alpha ?? 1,
|
|
2894
|
+
strokeWeight: item.stroke?.thickness,
|
|
2895
|
+
strokePosition: google.maps.StrokePosition.CENTER,
|
|
2896
|
+
fillColor: item.fill?.color,
|
|
2897
|
+
fillOpacity: item.fill?.alpha,
|
|
2898
|
+
center: item.center,
|
|
2899
|
+
radius: item.radius
|
|
2900
|
+
});
|
|
2901
|
+
}
|
|
2902
|
+
}
|
|
2903
|
+
setEditable(shape, editable) {
|
|
2904
|
+
shape.setOptions({
|
|
2905
|
+
editable
|
|
2906
|
+
});
|
|
2907
|
+
}
|
|
2908
|
+
setDraggable(shape, draggable) {
|
|
2909
|
+
shape.setOptions({
|
|
2910
|
+
draggable
|
|
2911
|
+
});
|
|
2912
|
+
}
|
|
2913
|
+
}
|
|
2914
|
+
class PacemGoogleMarkerAdapter extends PacemMarkerAdapter {
|
|
2915
|
+
deleteInfoWindow(info, map) {
|
|
2916
|
+
info.unbindAll();
|
|
2917
|
+
}
|
|
2918
|
+
deleteMarker(marker, map) {
|
|
2919
|
+
marker.setMap(null);
|
|
2920
|
+
}
|
|
2921
|
+
get mapAutomaticallyScrollsOnDrag() {
|
|
2922
|
+
return true;
|
|
2923
|
+
}
|
|
2924
|
+
getMarkerPosition(marker) {
|
|
2925
|
+
const latLng = marker.getPosition();
|
|
2926
|
+
return { lat: latLng.lat(), lng: latLng.lng() };
|
|
2927
|
+
}
|
|
2928
|
+
buildMarker(item, map) {
|
|
2929
|
+
return new google.maps.Marker({
|
|
2930
|
+
position: item.position,
|
|
2931
|
+
map
|
|
2932
|
+
});
|
|
2933
|
+
}
|
|
2934
|
+
addClickEventListener(marker, map, callback) {
|
|
2935
|
+
marker.addListener('click', callback);
|
|
2936
|
+
}
|
|
2937
|
+
addDragEventListener(marker, map, callback) {
|
|
2938
|
+
marker.addListener('drag', callback);
|
|
2939
|
+
}
|
|
2940
|
+
addDragEndEventListener(marker, map, callback) {
|
|
2941
|
+
marker.addListener('dragend', callback);
|
|
2942
|
+
}
|
|
2943
|
+
setPosition(marker, position) {
|
|
2944
|
+
marker.setPosition(position);
|
|
2945
|
+
}
|
|
2946
|
+
setIcon(marker, icon) {
|
|
2947
|
+
if (typeof icon === 'string') {
|
|
2948
|
+
// icon url only
|
|
2949
|
+
marker.setIcon(icon);
|
|
2950
|
+
}
|
|
2951
|
+
else if (!pacemCore.Utils.isNull(icon)) {
|
|
2952
|
+
// structured icon
|
|
2953
|
+
let options = { url: icon.url };
|
|
2954
|
+
if (!pacemCore.Utils.isNullOrEmpty(icon.size)) {
|
|
2955
|
+
options.size = new google.maps.Size(icon.size.width, icon.size.height);
|
|
2956
|
+
options.anchor = new google.maps.Point(icon.size.width / 2, icon.size.height);
|
|
2957
|
+
}
|
|
2958
|
+
if (!pacemCore.Utils.isNullOrEmpty(icon.anchor)) {
|
|
2959
|
+
options.anchor = new google.maps.Point(icon.anchor.x, icon.anchor.y);
|
|
2960
|
+
}
|
|
2961
|
+
marker.setIcon(options);
|
|
2962
|
+
}
|
|
2963
|
+
}
|
|
2964
|
+
setLabel(marker, label) {
|
|
2965
|
+
marker.setLabel(label);
|
|
2966
|
+
}
|
|
2967
|
+
setDraggable(marker, draggable) {
|
|
2968
|
+
marker.setDraggable(draggable);
|
|
2969
|
+
}
|
|
2970
|
+
closeInfo(info) {
|
|
2971
|
+
info.close();
|
|
2972
|
+
}
|
|
2973
|
+
openInfo(info, _, map, marker) {
|
|
2974
|
+
info.open(map, marker);
|
|
2975
|
+
}
|
|
2976
|
+
buildInfoWindow(item) {
|
|
2977
|
+
let offsX = 0;
|
|
2978
|
+
if (typeof item.icon !== 'string' && !pacemCore.Utils.isNull(item.icon)) {
|
|
2979
|
+
offsX = ((item.icon.size?.width ?? 0) / 2) -
|
|
2980
|
+
(item.icon.anchor?.x ?? 0);
|
|
2981
|
+
}
|
|
2982
|
+
return new google.maps.InfoWindow({
|
|
2983
|
+
pixelOffset: new google.maps.Size(-offsX, 0)
|
|
2984
|
+
});
|
|
2985
|
+
}
|
|
2986
|
+
addCloseClickEventListener(info, map, callback) {
|
|
2987
|
+
info.addListener('closeclick', callback);
|
|
2988
|
+
}
|
|
2989
|
+
setContent(info, content) {
|
|
2990
|
+
info.setContent(content);
|
|
2991
|
+
}
|
|
2992
|
+
}
|
|
2993
|
+
class PacemGoogleLayerAdapter extends PacemLayerAdapter {
|
|
2994
|
+
addLoadEventListener(layer, map, callback) {
|
|
2995
|
+
layer.addListener('tilesloaded', callback);
|
|
2996
|
+
}
|
|
2997
|
+
removeLoadEventListener(layer, map, callback) {
|
|
2998
|
+
// not necessary
|
|
2999
|
+
}
|
|
3000
|
+
deleteLayer(layer, map) {
|
|
3001
|
+
const layers = map.overlayMapTypes.getArray();
|
|
3002
|
+
const index = layers.findIndex(v => v === layer);
|
|
3003
|
+
if (index >= 0) {
|
|
3004
|
+
map.overlayMapTypes.removeAt(index);
|
|
3005
|
+
}
|
|
3006
|
+
}
|
|
3007
|
+
_getBounds(x, y, zoom) {
|
|
3008
|
+
const ext = consts.TILE_EXTENT;
|
|
3009
|
+
var tileSize = (ext[1] * 2) / Math.pow(2, zoom);
|
|
3010
|
+
var minx = ext[0] + x * tileSize;
|
|
3011
|
+
var maxx = ext[0] + (x + 1) * tileSize;
|
|
3012
|
+
// remember y origin starts at top
|
|
3013
|
+
var miny = ext[1] - (y + 1) * tileSize;
|
|
3014
|
+
var maxy = ext[1] - y * tileSize;
|
|
3015
|
+
return [minx, miny, maxx, maxy];
|
|
3016
|
+
}
|
|
3017
|
+
_getWmsTileUrl(url, layers) {
|
|
3018
|
+
return (coords, zoom) => {
|
|
3019
|
+
const tileUrl = pacemCore.Utils.URIs.appendQuery(url, {
|
|
3020
|
+
service: 'WMS', styles: '', transparent: 'true',
|
|
3021
|
+
request: 'GetMap', srs: 'EPSG:3857', format: 'image/png', version: '1.1.1',
|
|
3022
|
+
layers: layers?.join(',') || '', width: '256', height: '256',
|
|
3023
|
+
bbox: this._getBounds(coords.x, coords.y, zoom).join(',')
|
|
3024
|
+
});
|
|
3025
|
+
return tileUrl;
|
|
3026
|
+
};
|
|
3027
|
+
}
|
|
3028
|
+
_getWmsLayer(item, map) {
|
|
3029
|
+
const wmsLayer = new google.maps.ImageMapType({
|
|
3030
|
+
getTileUrl: this._getWmsTileUrl(item.url, item.include),
|
|
3031
|
+
//name: item.id,
|
|
3032
|
+
//alt: "TODO",
|
|
3033
|
+
minZoom: item.minZoom,
|
|
3034
|
+
maxZoom: item.maxZoom,
|
|
3035
|
+
opacity: 1 /* TODO */,
|
|
3036
|
+
});
|
|
3037
|
+
map.overlayMapTypes.push(wmsLayer);
|
|
3038
|
+
return wmsLayer;
|
|
3039
|
+
}
|
|
3040
|
+
_getTmsTileUrl(template) {
|
|
3041
|
+
const subdomains = 'abc';
|
|
3042
|
+
function getSubDomain(tilePoint) {
|
|
3043
|
+
const index = Math.abs(tilePoint.x + tilePoint.y) % subdomains.length;
|
|
3044
|
+
return subdomains[index];
|
|
3045
|
+
}
|
|
3046
|
+
//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png
|
|
3047
|
+
return (coords, zoom) => {
|
|
3048
|
+
const data = {
|
|
3049
|
+
r: /*retina ? '@2x' :*/ '',
|
|
3050
|
+
s: getSubDomain(coords),
|
|
3051
|
+
x: '' + coords.x,
|
|
3052
|
+
y: '' + coords.y,
|
|
3053
|
+
z: '' + zoom
|
|
3054
|
+
};
|
|
3055
|
+
let tileUrl = template;
|
|
3056
|
+
for (let prop in data) {
|
|
3057
|
+
tileUrl = tileUrl.replaceAll('{' + prop + '}', data[prop]);
|
|
3058
|
+
}
|
|
3059
|
+
return tileUrl;
|
|
3060
|
+
};
|
|
3061
|
+
}
|
|
3062
|
+
_getTmsLayer(item, map) {
|
|
3063
|
+
const wmsLayer = new google.maps.ImageMapType({
|
|
3064
|
+
getTileUrl: this._getTmsTileUrl(item.url),
|
|
3065
|
+
//name: item.id,
|
|
3066
|
+
//alt: "TODO",
|
|
3067
|
+
minZoom: item.minZoom,
|
|
3068
|
+
maxZoom: item.maxZoom,
|
|
3069
|
+
opacity: 1 /* TODO */,
|
|
3070
|
+
});
|
|
3071
|
+
map.overlayMapTypes.push(wmsLayer);
|
|
3072
|
+
return wmsLayer;
|
|
3073
|
+
}
|
|
3074
|
+
buildLayer(item, map) {
|
|
3075
|
+
const mode = (item.mode || '').toLowerCase();
|
|
3076
|
+
switch (mode) {
|
|
3077
|
+
case 'wms':
|
|
3078
|
+
return this._getWmsLayer(item, map);
|
|
3079
|
+
case 'tms':
|
|
3080
|
+
return this._getTmsLayer(item, map);
|
|
3081
|
+
default:
|
|
3082
|
+
throw new Error(`"${item.mode}" overlays not supported for the Google Maps integration.`);
|
|
3083
|
+
}
|
|
3084
|
+
}
|
|
3085
|
+
}
|
|
3086
|
+
function createOverlay(item) {
|
|
3087
|
+
//#region closure classes
|
|
3088
|
+
class PacemGoogleOverlay extends google.maps.OverlayView {
|
|
3089
|
+
constructor(_item) {
|
|
3090
|
+
super();
|
|
3091
|
+
this._item = _item;
|
|
3092
|
+
}
|
|
3093
|
+
get element() {
|
|
3094
|
+
return this._item;
|
|
3095
|
+
}
|
|
3096
|
+
get bounds() {
|
|
3097
|
+
const bounds = this._item.bounds;
|
|
3098
|
+
if (pacemCore.Utils.isNull(bounds)) {
|
|
3099
|
+
return null;
|
|
3100
|
+
}
|
|
3101
|
+
return GMapsUtils.getBounds(bounds);
|
|
3102
|
+
}
|
|
3103
|
+
getBoundingBox() {
|
|
3104
|
+
const proj = this.getProjection(), bounds = this.bounds;
|
|
3105
|
+
if (pacemCore.Utils.isNullOrEmpty(bounds)) {
|
|
3106
|
+
return null;
|
|
3107
|
+
}
|
|
3108
|
+
const sw = proj.fromLatLngToDivPixel({ lat: bounds.south, lng: bounds.west });
|
|
3109
|
+
const ne = proj.fromLatLngToDivPixel({ lat: bounds.north, lng: bounds.east });
|
|
3110
|
+
return { x: sw.x, y: ne.y, width: ne.x - sw.x, height: sw.y - ne.y };
|
|
3111
|
+
}
|
|
3112
|
+
}
|
|
3113
|
+
class PacemGoogleImageOverlay extends PacemGoogleOverlay {
|
|
3114
|
+
get src() {
|
|
3115
|
+
return this.element.src;
|
|
3116
|
+
}
|
|
3117
|
+
#div;
|
|
3118
|
+
onAdd() {
|
|
3119
|
+
// TODO: switch to canvas
|
|
3120
|
+
const div = this.#div = this.#div || document.createElement('div');
|
|
3121
|
+
div.style.position = 'absolute';
|
|
3122
|
+
const panes = this.getPanes();
|
|
3123
|
+
panes.overlayLayer.appendChild(div);
|
|
3124
|
+
}
|
|
3125
|
+
onRemove() {
|
|
3126
|
+
const div = this.#div;
|
|
3127
|
+
if (!pacemCore.Utils.isNull(div)) {
|
|
3128
|
+
div.remove();
|
|
3129
|
+
this.#div = null;
|
|
3130
|
+
}
|
|
3131
|
+
}
|
|
3132
|
+
draw() {
|
|
3133
|
+
const div = this.#div;
|
|
3134
|
+
if (pacemCore.Utils.isNull(div)) {
|
|
3135
|
+
return;
|
|
3136
|
+
}
|
|
3137
|
+
const bbox = this.getBoundingBox();
|
|
3138
|
+
if (pacemCore.Utils.isNull(bbox)) {
|
|
3139
|
+
return;
|
|
3140
|
+
}
|
|
3141
|
+
div.style.top = bbox.y + 'px';
|
|
3142
|
+
div.style.left = bbox.x + 'px';
|
|
3143
|
+
div.style.width = bbox.width + 'px';
|
|
3144
|
+
div.style.height = bbox.height + 'px';
|
|
3145
|
+
div.style.backgroundSize = `${bbox.width}px ${bbox.height}px`;
|
|
3146
|
+
div.style.backgroundImage = `url(${this.src})`;
|
|
3147
|
+
}
|
|
3148
|
+
}
|
|
3149
|
+
//#endregion
|
|
3150
|
+
if (item instanceof PacemMapOverlayImageElement) {
|
|
3151
|
+
return new PacemGoogleImageOverlay(item);
|
|
3152
|
+
}
|
|
3153
|
+
return null;
|
|
3154
|
+
}
|
|
3155
|
+
class PacemGoogleOverlayAdapter extends PacemOverlayAdapter {
|
|
3156
|
+
updateOverlay(overlay, map, item) {
|
|
3157
|
+
overlay.set;
|
|
3158
|
+
overlay.draw();
|
|
3159
|
+
}
|
|
3160
|
+
deleteOverlay(overlay, map) {
|
|
3161
|
+
overlay.setMap(null);
|
|
3162
|
+
}
|
|
3163
|
+
buildOverlay(item, map) {
|
|
3164
|
+
let overlay = createOverlay(item);
|
|
3165
|
+
overlay.setMap(map);
|
|
3166
|
+
return overlay;
|
|
3167
|
+
}
|
|
3168
|
+
setBounds(item, map, bounds) {
|
|
3169
|
+
item.draw();
|
|
3170
|
+
}
|
|
3171
|
+
}
|
|
3172
|
+
const MAP_EVENTS = ['dragend', 'zoom_changed', 'center_changed', 'maptypeid_changed', 'tilt_changed', 'heading_changed', 'bounds_changed'];
|
|
3173
|
+
function getNativeMapStyle(options) {
|
|
3174
|
+
const theme = options.theme == MapColorScheme.DARK ? google.maps.ColorScheme.DARK : (options.theme != MapColorScheme.LIGHT ? google.maps.ColorScheme.FOLLOW_SYSTEM : google.maps.ColorScheme.LIGHT);
|
|
3175
|
+
switch (options.type) {
|
|
3176
|
+
case google.maps.MapTypeId.HYBRID:
|
|
3177
|
+
case google.maps.MapTypeId.ROADMAP:
|
|
3178
|
+
case google.maps.MapTypeId.TERRAIN:
|
|
3179
|
+
case google.maps.MapTypeId.SATELLITE:
|
|
3180
|
+
return { type: options.type, theme };
|
|
3181
|
+
case MapType.HYBRID:
|
|
3182
|
+
return { type: google.maps.MapTypeId.HYBRID, theme };
|
|
3183
|
+
case MapType.SATELLITE:
|
|
3184
|
+
return { type: google.maps.MapTypeId.SATELLITE, theme };
|
|
3185
|
+
case MapType.TERRAIN:
|
|
3186
|
+
return { type: google.maps.MapTypeId.TERRAIN, theme };
|
|
3187
|
+
default:
|
|
3188
|
+
return { type: google.maps.MapTypeId.ROADMAP, theme };
|
|
3189
|
+
}
|
|
3190
|
+
}
|
|
3191
|
+
let PacemGoogleMapAdapterElement = class PacemGoogleMapAdapterElement extends PacemMapAdapterElement {
|
|
3192
|
+
geocode(address, maxResults) {
|
|
3193
|
+
const language = this.language || '', region = this.region || '', version = this.version || 'weekly';
|
|
3194
|
+
const geocoder = new PacemGoogleMapGeocoder(this.apiKey, language, region, version);
|
|
3195
|
+
return geocoder.geocode(address, maxResults);
|
|
3196
|
+
}
|
|
3197
|
+
reverseGeocode(latLng, maxResults) {
|
|
3198
|
+
const language = this.language || '', region = this.region || '', version = this.version || 'weekly';
|
|
3199
|
+
const geocoder = new PacemGoogleMapGeocoder(this.apiKey, language, region, version);
|
|
3200
|
+
return geocoder.reverseGeocode(latLng, maxResults);
|
|
3201
|
+
}
|
|
3202
|
+
getBounds(map) {
|
|
3203
|
+
if (!this.hasMap(map)) {
|
|
3204
|
+
return LatLngBounds.Empty;
|
|
3205
|
+
}
|
|
3206
|
+
const nativeMap = this.getMap(map);
|
|
3207
|
+
const retval = nativeMap.getBounds();
|
|
3208
|
+
return GMapsUtils.toLiteral(retval);
|
|
3209
|
+
}
|
|
3210
|
+
isActive() {
|
|
3211
|
+
return !pacemCore.Utils.isNullOrEmpty(this.apiKey);
|
|
3212
|
+
}
|
|
3213
|
+
buildMarkerAdapterFor(map) {
|
|
3214
|
+
return new PacemGoogleMarkerAdapter(map, this);
|
|
3215
|
+
}
|
|
3216
|
+
buildOverlayAdapterFor(map) {
|
|
3217
|
+
return new PacemGoogleOverlayAdapter(map, this);
|
|
3218
|
+
}
|
|
3219
|
+
buildShapeAdapterFor(map) {
|
|
3220
|
+
return new PacemGoogleShapeAdapter(map, this);
|
|
3221
|
+
}
|
|
3222
|
+
buildLayerAdapterFor(map) {
|
|
3223
|
+
return new PacemGoogleLayerAdapter(map, this);
|
|
3224
|
+
}
|
|
3225
|
+
getMaxAvailableZoom(latLng) {
|
|
3226
|
+
return new Promise((resolve, reject) => {
|
|
3227
|
+
const svc = new google.maps.MaxZoomService();
|
|
3228
|
+
svc.getMaxZoomAtLatLng(latLng, result => {
|
|
3229
|
+
if (result.status === google.maps.MaxZoomStatus.OK) {
|
|
3230
|
+
resolve(result.zoom);
|
|
3231
|
+
}
|
|
3232
|
+
else {
|
|
3233
|
+
reject();
|
|
3234
|
+
}
|
|
3235
|
+
});
|
|
3236
|
+
});
|
|
3237
|
+
}
|
|
3238
|
+
#listeners = new WeakMap();
|
|
3239
|
+
snapshot(ctrl, type = 'image/png', quality) {
|
|
3240
|
+
const { container } = this.tryGetMap(ctrl);
|
|
3241
|
+
return pacemCore.Utils.snapshotElement(container, null, type, quality);
|
|
3242
|
+
}
|
|
3243
|
+
setViewNative(ctrl, options) {
|
|
3244
|
+
const map = this.getMap(ctrl);
|
|
3245
|
+
options = pacemCore.Utils.extend({ type: ctrl.type, theme: ctrl.theme }, options);
|
|
3246
|
+
const { type, theme } = getNativeMapStyle(options);
|
|
3247
|
+
if (this.#bootstrapped && theme !== map.get('colorScheme')) {
|
|
3248
|
+
this._bootstrapDebounced();
|
|
3249
|
+
return;
|
|
3250
|
+
}
|
|
3251
|
+
map.setOptions({ colorScheme: theme, mapTypeId: type });
|
|
3252
|
+
if (typeof options.tilt === 'number') {
|
|
3253
|
+
map.setTilt(options.tilt);
|
|
3254
|
+
}
|
|
3255
|
+
if (typeof options.heading === 'number') {
|
|
3256
|
+
map.setHeading(options.heading);
|
|
3257
|
+
}
|
|
3258
|
+
// `setZoom` BEFORE
|
|
3259
|
+
// calling `panTo` method, otherwise
|
|
3260
|
+
// no smooth transition will be applied.
|
|
3261
|
+
const fnSetCenter = () => {
|
|
3262
|
+
if (options.center) {
|
|
3263
|
+
GMapsUtils.setCenter(map, options.center);
|
|
3264
|
+
}
|
|
3265
|
+
};
|
|
3266
|
+
if (typeof options.zoom === 'number' && options.zoom !== map.getZoom()) {
|
|
3267
|
+
const mapType = map.getMapTypeId();
|
|
3268
|
+
switch (mapType) {
|
|
3269
|
+
case google.maps.MapTypeId.SATELLITE:
|
|
3270
|
+
case google.maps.MapTypeId.HYBRID:
|
|
3271
|
+
// async retrieve
|
|
3272
|
+
const currentCenter = GMapsUtils.toLiteral(map.getCenter());
|
|
3273
|
+
this.getMaxAvailableZoom(currentCenter).then(z => {
|
|
3274
|
+
const zoom = Math.min(z, options.zoom);
|
|
3275
|
+
map.setZoom(zoom);
|
|
3276
|
+
fnSetCenter();
|
|
3277
|
+
});
|
|
3278
|
+
break;
|
|
3279
|
+
default:
|
|
3280
|
+
const zoom = Math.min(consts.MAX_ROADMAP_ZOOM, options.zoom);
|
|
3281
|
+
map.setZoom(zoom);
|
|
3282
|
+
fnSetCenter();
|
|
3283
|
+
break;
|
|
3284
|
+
}
|
|
3285
|
+
}
|
|
3286
|
+
else {
|
|
3287
|
+
fnSetCenter();
|
|
3288
|
+
}
|
|
3289
|
+
}
|
|
3290
|
+
propertyChangedCallback(name, old, val, first) {
|
|
3291
|
+
super.propertyChangedCallback(name, old, val, first);
|
|
3292
|
+
if (!first) {
|
|
3293
|
+
switch (name) {
|
|
3294
|
+
case 'libraries':
|
|
3295
|
+
case 'apiKey':
|
|
3296
|
+
case 'language':
|
|
3297
|
+
case 'region':
|
|
3298
|
+
if (this.#bootstrapped) {
|
|
3299
|
+
this._bootstrapDebounced();
|
|
3300
|
+
}
|
|
3301
|
+
break;
|
|
3302
|
+
case 'defaultOptions':
|
|
3303
|
+
for (let map of this.enrolledMaps()) {
|
|
3304
|
+
this._updateMapOptions(map);
|
|
3305
|
+
}
|
|
3306
|
+
break;
|
|
3307
|
+
default:
|
|
3308
|
+
for (let map of this.enrolledMaps()) {
|
|
3309
|
+
this.invalidateSize(map);
|
|
3310
|
+
}
|
|
3311
|
+
break;
|
|
3312
|
+
}
|
|
3313
|
+
}
|
|
3314
|
+
}
|
|
3315
|
+
// #region ABSTRACT IMPLEMENTATION
|
|
3316
|
+
dispose(map) {
|
|
3317
|
+
const listeners = this.#listeners.get(map);
|
|
3318
|
+
while (listeners.length) {
|
|
3319
|
+
google.maps.event.removeListener(listeners.pop());
|
|
3320
|
+
}
|
|
3321
|
+
this.#listeners.delete(map);
|
|
3322
|
+
}
|
|
3323
|
+
_updateMapOptions(ctrl) {
|
|
3324
|
+
if (!this.hasMap(ctrl)) {
|
|
3325
|
+
return;
|
|
3326
|
+
}
|
|
3327
|
+
const { map } = this.tryGetMap(ctrl);
|
|
3328
|
+
map.setOptions(this._buildMapOptions(ctrl));
|
|
3329
|
+
}
|
|
3330
|
+
_buildMapOptions(ctrl) {
|
|
3331
|
+
const scale = ctrl.scale;
|
|
3332
|
+
const draggable = ctrl.draggable;
|
|
3333
|
+
const dblClickZoom = ctrl.doubleClickZoom;
|
|
3334
|
+
const kbShortcuts = ctrl.keyboardShortcuts;
|
|
3335
|
+
const { type: mapTypeId, theme: colorScheme } = getNativeMapStyle({ type: ctrl.type, theme: ctrl.theme });
|
|
3336
|
+
return pacemCore.Utils.extend({}, this.defaultOptions || { streetViewControl: false, zoomControl: false, mapTypeControl: false, fullscreenControl: false, cameraControl: false }, {
|
|
3337
|
+
zoomControl: scale && !pacemCore.Utils.isNullOrEmpty(ctrl.zoomControl),
|
|
3338
|
+
zoomControlOptions: {
|
|
3339
|
+
position: (function (zpos) {
|
|
3340
|
+
switch (zpos) {
|
|
3341
|
+
case 'topright':
|
|
3342
|
+
return google.maps.ControlPosition.RIGHT_TOP;
|
|
3343
|
+
case 'bottomleft':
|
|
3344
|
+
return google.maps.ControlPosition.LEFT_BOTTOM;
|
|
3345
|
+
case 'bottomright':
|
|
3346
|
+
return google.maps.ControlPosition.RIGHT_BOTTOM;
|
|
3347
|
+
default:
|
|
3348
|
+
return google.maps.ControlPosition.LEFT_TOP;
|
|
3349
|
+
}
|
|
3350
|
+
})(ctrl.zoomControl)
|
|
3351
|
+
},
|
|
3352
|
+
scrollwheel: ctrl.mousewheel,
|
|
3353
|
+
disableDoubleClickZoom: dblClickZoom,
|
|
3354
|
+
keyboardShortcuts: kbShortcuts,
|
|
3355
|
+
draggable: draggable,
|
|
3356
|
+
mapTypeId,
|
|
3357
|
+
colorScheme,
|
|
3358
|
+
tilt: ctrl.tilt,
|
|
3359
|
+
heading: ctrl.heading,
|
|
3360
|
+
});
|
|
3361
|
+
}
|
|
3362
|
+
#bootstrapped = false;
|
|
3363
|
+
_bootstrapDebounced() {
|
|
3364
|
+
this._bootstrap().then(_ => {
|
|
3365
|
+
for (let map of this.enrolledMaps()) {
|
|
3366
|
+
// HACK: (toggle adapter off/on)
|
|
3367
|
+
map.adapter = null;
|
|
3368
|
+
map.adapter = this;
|
|
3369
|
+
}
|
|
3370
|
+
});
|
|
3371
|
+
}
|
|
3372
|
+
_bootstrap() {
|
|
3373
|
+
return new Promise((resolve, reject) => {
|
|
3374
|
+
const apiKey = this.apiKey, language = this.language || '', region = this.region || '', version = this.version || 'weekly';
|
|
3375
|
+
bootstrapper.boostrap(apiKey, language, region, version).then(_ => {
|
|
3376
|
+
const promises = [];
|
|
3377
|
+
for (let lib of this.libraries || []) {
|
|
3378
|
+
promises.push(google.maps.importLibrary(lib));
|
|
3379
|
+
}
|
|
3380
|
+
Promise.all(promises).then(_ => {
|
|
3381
|
+
resolve();
|
|
3382
|
+
this.#bootstrapped = true;
|
|
3383
|
+
}, reject);
|
|
3384
|
+
}, reject);
|
|
3385
|
+
});
|
|
3386
|
+
}
|
|
3387
|
+
async init(container) {
|
|
3388
|
+
await this._bootstrap();
|
|
3389
|
+
//
|
|
3390
|
+
const ctrl = container;
|
|
3391
|
+
const centerPos = MapUtils.parseCoords(ctrl.center);
|
|
3392
|
+
const center = new google.maps.LatLng(centerPos[0], centerPos[1]);
|
|
3393
|
+
const mapOptions = this._buildMapOptions(ctrl);
|
|
3394
|
+
const canvas = ctrl.container;
|
|
3395
|
+
const mapElement = document.createElement('div');
|
|
3396
|
+
mapElement.style.width = '100%';
|
|
3397
|
+
mapElement.style.height = '100%';
|
|
3398
|
+
canvas.innerHTML = '';
|
|
3399
|
+
canvas.appendChild(mapElement);
|
|
3400
|
+
const map = new google.maps.Map(mapElement, mapOptions);
|
|
3401
|
+
const listeners = [];
|
|
3402
|
+
this.#listeners.set(ctrl, listeners);
|
|
3403
|
+
MAP_EVENTS.forEach(evt => {
|
|
3404
|
+
listeners.push(map.addListener(evt, this._spinMapUpdateHandler(ctrl, map)));
|
|
3405
|
+
});
|
|
3406
|
+
// setting now the center and zoom, triggers the "load" event and activates the child-components, if any.
|
|
3407
|
+
map.setZoom(ctrl.zoom);
|
|
3408
|
+
map.setCenter(center);
|
|
3409
|
+
// first-load
|
|
3410
|
+
var listener = map.addListener('idle', function once(e) {
|
|
3411
|
+
listener.remove();
|
|
3412
|
+
container.dispatchEvent(new MapEvent("maploaded"));
|
|
3413
|
+
});
|
|
3414
|
+
// tilesloaded
|
|
3415
|
+
listeners.push(map.addListener('tilesloaded', evt => {
|
|
3416
|
+
container.dispatchEvent(new MapEvent("tilesloaded"));
|
|
3417
|
+
}));
|
|
3418
|
+
// call setView NOW to trigger the load event :(
|
|
3419
|
+
const cnt = MapUtils.parseCoords(ctrl.center), xpr = new google.maps.LatLng(cnt[0], cnt[1]);
|
|
3420
|
+
map.setZoom(ctrl.zoom);
|
|
3421
|
+
map.setCenter(xpr);
|
|
3422
|
+
return { map, container: mapElement };
|
|
3423
|
+
}
|
|
3424
|
+
invalidateSize(ctrl) {
|
|
3425
|
+
if (!this.hasMap(ctrl)) {
|
|
3426
|
+
return;
|
|
3427
|
+
}
|
|
3428
|
+
const { map } = this.tryGetMap(ctrl);
|
|
3429
|
+
google.maps.event.trigger(map, "resize");
|
|
3430
|
+
}
|
|
3431
|
+
//#endregion
|
|
3432
|
+
_spinMapUpdateHandler(ctrl, map) {
|
|
3433
|
+
return () => {
|
|
3434
|
+
if (!pacemCore.Utils.isNull(map) && !pacemCore.Utils.isNull(ctrl)) {
|
|
3435
|
+
const center = map.getCenter();
|
|
3436
|
+
if (pacemCore.Utils.isNull(center)) {
|
|
3437
|
+
// not fully initialized yet
|
|
3438
|
+
return;
|
|
3439
|
+
}
|
|
3440
|
+
this.updateMapElement(ctrl, {
|
|
3441
|
+
center: { lat: center.lat(), lng: center.lng() }, zoom: map.getZoom(),
|
|
3442
|
+
type: map.getMapTypeId(), tilt: map.getTilt(), heading: map.getHeading()
|
|
3443
|
+
});
|
|
3444
|
+
}
|
|
3445
|
+
};
|
|
3446
|
+
}
|
|
3447
|
+
fitBoundsNative(ctrl, bounds, padding = this._getPadding(ctrl)) {
|
|
3448
|
+
const map = this.tryGetMap(ctrl)?.map;
|
|
3449
|
+
if (pacemCore.Utils.isNull(map)) {
|
|
3450
|
+
return;
|
|
3451
|
+
}
|
|
3452
|
+
const bnds = GMapsUtils.getBounds(bounds);
|
|
3453
|
+
GMapsUtils.fitBounds(map, bnds, padding);
|
|
3454
|
+
}
|
|
3455
|
+
;
|
|
3456
|
+
_getPadding(ctrl) {
|
|
3457
|
+
const top = ctrl.paddingTop || 0, left = ctrl.paddingLeft || 0, right = ctrl.paddingRight || 0, bottom = ctrl.paddingBottom || 0;
|
|
3458
|
+
if (left || top || right || bottom) {
|
|
3459
|
+
return { top, bottom, left, right };
|
|
3460
|
+
}
|
|
3461
|
+
return null;
|
|
3462
|
+
}
|
|
3463
|
+
/**
|
|
3464
|
+
@deprecated
|
|
3465
|
+
*/
|
|
3466
|
+
_padBounds(ctrl) {
|
|
3467
|
+
const paddingTop = ctrl.paddingTop || 0, paddingLeft = ctrl.paddingLeft || 0, paddingRight = ctrl.paddingRight || 0, paddingBottom = ctrl.paddingBottom || 0;
|
|
3468
|
+
if (paddingLeft || paddingTop || paddingRight || paddingBottom) {
|
|
3469
|
+
const map = this.tryGetMap(ctrl).map;
|
|
3470
|
+
const bnds = map.getBounds();
|
|
3471
|
+
const w = map.getDiv().clientWidth, h = map.getDiv().clientHeight;
|
|
3472
|
+
//
|
|
3473
|
+
const n_nw = map.getProjection().fromPointToLatLng(new google.maps.Point(-paddingLeft, -paddingTop));
|
|
3474
|
+
const n_se = map.getProjection().fromPointToLatLng(new google.maps.Point(w + paddingRight, h + paddingBottom));
|
|
3475
|
+
//
|
|
3476
|
+
bnds.extend(n_nw);
|
|
3477
|
+
bnds.extend(n_se);
|
|
3478
|
+
}
|
|
3479
|
+
}
|
|
3480
|
+
_redrawMap() {
|
|
3481
|
+
// do nothing (no tiles)
|
|
3482
|
+
}
|
|
3483
|
+
};
|
|
3484
|
+
__decorate([
|
|
3485
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.String })
|
|
3486
|
+
], PacemGoogleMapAdapterElement.prototype, "apiKey", void 0);
|
|
3487
|
+
__decorate([
|
|
3488
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.String })
|
|
3489
|
+
], PacemGoogleMapAdapterElement.prototype, "version", void 0);
|
|
3490
|
+
__decorate([
|
|
3491
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.String })
|
|
3492
|
+
], PacemGoogleMapAdapterElement.prototype, "language", void 0);
|
|
3493
|
+
__decorate([
|
|
3494
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.String })
|
|
3495
|
+
], PacemGoogleMapAdapterElement.prototype, "region", void 0);
|
|
3496
|
+
__decorate([
|
|
3497
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.Json })
|
|
3498
|
+
], PacemGoogleMapAdapterElement.prototype, "defaultOptions", void 0);
|
|
3499
|
+
__decorate([
|
|
3500
|
+
pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.StringArray })
|
|
3501
|
+
], PacemGoogleMapAdapterElement.prototype, "libraries", void 0);
|
|
3502
|
+
__decorate([
|
|
3503
|
+
pacemCore.Debounce(consts.DETACH_TIMEOUT)
|
|
3504
|
+
], PacemGoogleMapAdapterElement.prototype, "_bootstrapDebounced", null);
|
|
3505
|
+
PacemGoogleMapAdapterElement = __decorate([
|
|
3506
|
+
pacemCore.CustomElement({ tagName: pacemCore.P + '-map-adapter-google' })
|
|
3507
|
+
], PacemGoogleMapAdapterElement);
|
|
3508
|
+
//#region geocoders
|
|
3509
|
+
class PacemGoogleMapGeocoder {
|
|
3510
|
+
constructor(apiKey, language = '', region = '', version = 'weekly') {
|
|
3511
|
+
this.apiKey = apiKey;
|
|
3512
|
+
this.language = language;
|
|
3513
|
+
this.region = region;
|
|
3514
|
+
this.version = version;
|
|
3515
|
+
}
|
|
3516
|
+
/**
|
|
3517
|
+
* Try add altitude info.
|
|
3518
|
+
* @param results
|
|
3519
|
+
* @returns
|
|
3520
|
+
*/
|
|
3521
|
+
_elevateResults(set) {
|
|
3522
|
+
return new Promise((resolve, reject) => {
|
|
3523
|
+
// try get elevation as well
|
|
3524
|
+
const elevation = new google.maps.ElevationService();
|
|
3525
|
+
elevation.getElevationForLocations({ locations: set.map(i => i.geometry.location) }, (results2, status2) => {
|
|
3526
|
+
if (status2 === google.maps.ElevationStatus.OK) {
|
|
3527
|
+
const retval = GMapsUtils.mapGeocodeResults(set, results2);
|
|
3528
|
+
// success
|
|
3529
|
+
resolve(retval);
|
|
3530
|
+
}
|
|
3531
|
+
else {
|
|
3532
|
+
// partial success (no elevation)
|
|
3533
|
+
const retval = GMapsUtils.mapGeocodeResults(set);
|
|
3534
|
+
resolve(retval);
|
|
3535
|
+
}
|
|
3536
|
+
});
|
|
3537
|
+
});
|
|
3538
|
+
}
|
|
3539
|
+
geocode(search, maxResults = 10) {
|
|
3540
|
+
return new Promise((resolve, reject) => {
|
|
3541
|
+
bootstrapper.boostrap(this.apiKey, this.language || '', this.region || '', this.version || 'weekly').then(_ => {
|
|
3542
|
+
const geocoder = new google.maps.Geocoder();
|
|
3543
|
+
geocoder.geocode({
|
|
3544
|
+
address: search,
|
|
3545
|
+
//language: this.language || '',
|
|
3546
|
+
//region: this.region || ''
|
|
3547
|
+
}, (results, status) => {
|
|
3548
|
+
if (status === google.maps.GeocoderStatus.OK
|
|
3549
|
+
|| status == google.maps.GeocoderStatus.ZERO_RESULTS) {
|
|
3550
|
+
const set = (results || [])
|
|
3551
|
+
.filter((_, index) => index < (maxResults || 10));
|
|
3552
|
+
this._elevateResults(set).then(resolve);
|
|
3553
|
+
}
|
|
3554
|
+
else {
|
|
3555
|
+
// error
|
|
3556
|
+
reject(status);
|
|
3557
|
+
}
|
|
3558
|
+
});
|
|
3559
|
+
}, reject);
|
|
3560
|
+
});
|
|
3561
|
+
}
|
|
3562
|
+
_reverseGeocodeInternal(position, maxResults) {
|
|
3563
|
+
const location = GMapsUtils.getPosition(position);
|
|
3564
|
+
return new Promise((resolve, reject) => {
|
|
3565
|
+
bootstrapper.boostrap(this.apiKey, this.language || '', this.region || '', this.version || 'weekly').then(_ => {
|
|
3566
|
+
const geocoder = new google.maps.Geocoder();
|
|
3567
|
+
geocoder.geocode({
|
|
3568
|
+
location,
|
|
3569
|
+
//language: this.language || '',
|
|
3570
|
+
//region: this.region || ''
|
|
3571
|
+
}, (results, status) => {
|
|
3572
|
+
if (status === google.maps.GeocoderStatus.OK
|
|
3573
|
+
|| status == google.maps.GeocoderStatus.ZERO_RESULTS) {
|
|
3574
|
+
const set = (results || [])
|
|
3575
|
+
.filter((_, index) => index < (maxResults || 10));
|
|
3576
|
+
this._elevateResults(set).then(resolve);
|
|
3577
|
+
}
|
|
3578
|
+
else {
|
|
3579
|
+
// error
|
|
3580
|
+
reject(status);
|
|
3581
|
+
}
|
|
3582
|
+
});
|
|
3583
|
+
}, reject);
|
|
3584
|
+
});
|
|
3585
|
+
}
|
|
3586
|
+
reverseGeocode(position, maxResults = 1) {
|
|
3587
|
+
return this._reverseGeocodeInternal(position, maxResults);
|
|
3588
|
+
}
|
|
3589
|
+
}
|
|
3590
|
+
//#endregion
|
|
3591
|
+
//}
|
|
3592
|
+
|
|
3593
|
+
var indexComponentsMaps = /*#__PURE__*/Object.freeze({
|
|
3594
|
+
__proto__: null,
|
|
3595
|
+
LatLngBoundsConverter: LatLngBoundsConverter,
|
|
3596
|
+
LatLngConverter: LatLngConverter,
|
|
3597
|
+
LayerLoadEventName: LayerLoadEventName,
|
|
3598
|
+
get MapColorScheme () { return MapColorScheme; },
|
|
3599
|
+
MapConsts: MapConsts,
|
|
3600
|
+
MapEvent: MapEvent,
|
|
3601
|
+
MapItemAdapter: MapItemAdapter,
|
|
3602
|
+
MapRelevantElement: MapRelevantElement,
|
|
3603
|
+
get MapType () { return MapType; },
|
|
3604
|
+
MapUtils: MapUtils,
|
|
3605
|
+
get PacemAzureMapAdapterElement () { return PacemAzureMapAdapterElement; },
|
|
3606
|
+
get PacemGoogleMapAdapterElement () { return PacemGoogleMapAdapterElement; },
|
|
3607
|
+
PacemLayerAdapter: PacemLayerAdapter,
|
|
3608
|
+
get PacemLeafletMapAdapterElement () { return PacemLeafletMapAdapterElement; },
|
|
3609
|
+
PacemMapAdapterElement: PacemMapAdapterElement,
|
|
3610
|
+
get PacemMapCircleElement () { return PacemMapCircleElement; },
|
|
3611
|
+
get PacemMapElement () { return PacemMapElement; },
|
|
3612
|
+
get PacemMapGeocodeElement () { return PacemMapGeocodeElement; },
|
|
3613
|
+
get PacemMapGeolocateElement () { return PacemMapGeolocateElement; },
|
|
3614
|
+
get PacemMapLayerElement () { return PacemMapLayerElement; },
|
|
3615
|
+
get PacemMapMarkerElement () { return PacemMapMarkerElement; },
|
|
3616
|
+
PacemMapOverlayElement: PacemMapOverlayElement,
|
|
3617
|
+
get PacemMapOverlayImageElement () { return PacemMapOverlayImageElement; },
|
|
3618
|
+
get PacemMapPolygonElement () { return PacemMapPolygonElement; },
|
|
3619
|
+
get PacemMapPolylineElement () { return PacemMapPolylineElement; },
|
|
3620
|
+
PacemMapShapeElement: PacemMapShapeElement,
|
|
3621
|
+
PacemMarkerAdapter: PacemMarkerAdapter,
|
|
3622
|
+
PacemOverlayAdapter: PacemOverlayAdapter,
|
|
3623
|
+
PacemShapeAdapter: PacemShapeAdapter,
|
|
3624
|
+
isLatLng: isLatLng,
|
|
3625
|
+
isLatLngBounds: isLatLngBounds
|
|
3626
|
+
});
|
|
3627
|
+
|
|
3628
|
+
var indexComponents = /*#__PURE__*/Object.freeze({
|
|
3629
|
+
__proto__: null,
|
|
3630
|
+
Maps: indexComponentsMaps
|
|
3631
|
+
});
|
|
3632
|
+
|
|
3633
|
+
var Output = /*#__PURE__*/Object.freeze({
|
|
3634
|
+
__proto__: null,
|
|
3635
|
+
Components: indexComponents,
|
|
3636
|
+
Maps: types
|
|
3637
|
+
});
|
|
3638
|
+
|
|
3639
|
+
pacemFoundation.DeepMerger.merge(Output);
|
|
3640
|
+
|
|
3641
|
+
})(Pacem, Pacem);
|
|
3642
|
+
//# sourceMappingURL=pacem-maps.js.map
|