@mint-ui/map 0.1.1-beta → 0.1.2-beta
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/dist/components/mint-map/MintMap.d.ts +2 -2
- package/dist/components/mint-map/MintMap.js +69 -49
- package/dist/components/mint-map/core/MintMapController.d.ts +1 -1
- package/dist/components/mint-map/core/MintMapController.js +3 -1
- package/dist/components/mint-map/core/MintMapCore.d.ts +1 -1
- package/dist/components/mint-map/core/MintMapCore.js +3 -1
- package/dist/components/mint-map/core/advanced/MapBuildingProjection.js +4 -4
- package/dist/components/mint-map/core/advanced/index.d.ts +1 -0
- package/dist/components/mint-map/core/hooks/index.d.ts +1 -0
- package/dist/components/mint-map/core/index.d.ts +7 -7
- package/dist/components/mint-map/core/provider/MintMapProvider.d.ts +2 -2
- package/dist/components/mint-map/core/provider/MintMapProvider.js +1 -1
- package/dist/components/mint-map/core/provider/index.d.ts +1 -0
- package/dist/components/mint-map/core/util/index.d.ts +3 -0
- package/dist/components/mint-map/core/util/waiting.d.ts +1 -1
- package/dist/components/mint-map/core/util/waiting.js +33 -0
- package/dist/components/mint-map/core/wrapper/MapControlWrapper.d.ts +1 -1
- package/dist/components/mint-map/core/wrapper/MapControlWrapper.js +3 -1
- package/dist/components/mint-map/core/wrapper/MapMarkerWrapper.d.ts +1 -1
- package/dist/components/mint-map/core/wrapper/MapMarkerWrapper.js +3 -1
- package/dist/components/mint-map/core/wrapper/MapPolygonWrapper.d.ts +1 -1
- package/dist/components/mint-map/core/wrapper/MapPolygonWrapper.js +3 -1
- package/dist/components/mint-map/core/wrapper/MapPolylineWrapper.d.ts +1 -1
- package/dist/components/mint-map/core/wrapper/MapPolylineWrapper.js +3 -1
- package/dist/components/mint-map/core/wrapper/index.d.ts +4 -0
- package/dist/components/mint-map/google/GoogleMintMapController.d.ts +2 -2
- package/dist/components/mint-map/google/GoogleMintMapController.js +431 -0
- package/dist/components/mint-map/index.d.ts +3 -1
- package/dist/components/mint-map/naver/NaverMintMapController.d.ts +2 -2
- package/dist/components/mint-map/naver/NaverMintMapController.js +427 -0
- package/dist/index.es.js +1095 -197
- package/dist/index.js +32 -9
- package/dist/index.umd.js +1109 -195
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __awaiter, __generator, __extends,
|
|
1
|
+
import { __awaiter, __generator, __extends, __spreadArray, __assign, __rest } from 'tslib';
|
|
2
2
|
import React, { createContext, useContext, useRef, useState, useEffect } from 'react';
|
|
3
3
|
import classNames from 'classnames/bind';
|
|
4
4
|
import styleInject from 'style-inject';
|
|
@@ -16,7 +16,7 @@ function MintMapProvider(_a) {
|
|
|
16
16
|
value: controller
|
|
17
17
|
}, children);
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function useMintMapController() {
|
|
20
20
|
var controller = useContext(MintMapControllerContext);
|
|
21
21
|
|
|
22
22
|
if (controller === null) {
|
|
@@ -38,7 +38,7 @@ function MintMapCore(_a) {
|
|
|
38
38
|
_b = _a.visible,
|
|
39
39
|
visible = _b === void 0 ? true : _b,
|
|
40
40
|
children = _a.children;
|
|
41
|
-
var controller =
|
|
41
|
+
var controller = useMintMapController();
|
|
42
42
|
var elementRef = useRef(null);
|
|
43
43
|
|
|
44
44
|
var _c = useState(false),
|
|
@@ -123,7 +123,7 @@ var PolygonCalculator = function () {
|
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
if (maxX && minX && maxY && minY) {
|
|
126
|
-
return new
|
|
126
|
+
return new Position(minX + (maxX - minX) / 2, minY + (maxY - minY) / 2);
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
throw new Error('Calculate Center Error!!!');
|
|
@@ -172,7 +172,7 @@ var PolygonCalculator = function () {
|
|
|
172
172
|
return PolygonCalculator;
|
|
173
173
|
}();
|
|
174
174
|
|
|
175
|
-
var
|
|
175
|
+
var GeoCalulator = function () {
|
|
176
176
|
function GeoCalulator() {}
|
|
177
177
|
|
|
178
178
|
GeoCalulator.computeDistanceKiloMeter = function (pos1, pos2) {
|
|
@@ -228,7 +228,7 @@ var calculate.GeoCalulator = function () {
|
|
|
228
228
|
var ratio = nextDistance / totalDistance;
|
|
229
229
|
var latCalib = pos2.lat > pos1.lat ? 1 : -1;
|
|
230
230
|
var lngCalib = pos2.lng > pos1.lng ? 1 : -1;
|
|
231
|
-
var newPos = new
|
|
231
|
+
var newPos = new Position(pos1.lat + (pos2.lat - pos1.lat) * ratio, pos1.lng + (pos2.lng - pos1.lng) * ratio);
|
|
232
232
|
|
|
233
233
|
if ((latCalib === 1 && pos2.lat <= newPos.lat || latCalib === -1 && pos2.lat >= newPos.lat) && (lngCalib === 1 && pos2.lng <= newPos.lng || lngCalib === -1 && pos2.lng >= newPos.lng)) {
|
|
234
234
|
newPos = pos2;
|
|
@@ -244,7 +244,922 @@ var calculate.GeoCalulator = function () {
|
|
|
244
244
|
return GeoCalulator;
|
|
245
245
|
}();
|
|
246
246
|
|
|
247
|
-
var
|
|
247
|
+
var MintMapController = function () {
|
|
248
|
+
function MintMapController(props) {
|
|
249
|
+
this.mapApiLoaded = false;
|
|
250
|
+
this.mapInitialized = false;
|
|
251
|
+
this.mapProps = props;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
MintMapController.prototype.getMap = function () {
|
|
255
|
+
return this.map;
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
MintMapController.prototype.getMapType = function () {
|
|
259
|
+
return this.type;
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
MintMapController.prototype.loadScript = function (url, id) {
|
|
263
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
264
|
+
return __generator(this, function (_a) {
|
|
265
|
+
return [2, new Promise(function (resolve) {
|
|
266
|
+
if (id && document.getElementById(id)) {
|
|
267
|
+
console.log("already loaded script => ".concat(id));
|
|
268
|
+
resolve();
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
var script = document.createElement('script');
|
|
273
|
+
script.src = url;
|
|
274
|
+
script.async = true;
|
|
275
|
+
script.defer = true;
|
|
276
|
+
script.addEventListener('load', function () {
|
|
277
|
+
resolve();
|
|
278
|
+
});
|
|
279
|
+
document.body.appendChild(script);
|
|
280
|
+
})];
|
|
281
|
+
});
|
|
282
|
+
});
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
MintMapController.prototype.buildUrl = function (baseUrl, param) {
|
|
286
|
+
var params = Object.entries(param).map(function (_a) {
|
|
287
|
+
var key = _a[0],
|
|
288
|
+
value = _a[1];
|
|
289
|
+
var temp = encodeURIComponent(Array.isArray(value) ? value.join(',') : value);
|
|
290
|
+
return "".concat(key, "=").concat(temp);
|
|
291
|
+
}).join('&');
|
|
292
|
+
return "".concat(baseUrl, "?").concat(params);
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
return MintMapController;
|
|
296
|
+
}();
|
|
297
|
+
|
|
298
|
+
function waiting(evaluation, timeoutSeconds) {
|
|
299
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
300
|
+
var max;
|
|
301
|
+
return __generator(this, function (_a) {
|
|
302
|
+
max = (timeoutSeconds || 5) * 1000;
|
|
303
|
+
return [2, new Promise(function (resolve) {
|
|
304
|
+
var start = new Date().getTime();
|
|
305
|
+
var inter = setInterval(function () {
|
|
306
|
+
var time = new Date().getTime();
|
|
307
|
+
|
|
308
|
+
if (time - start > max) {
|
|
309
|
+
clearInterval(inter);
|
|
310
|
+
resolve(false);
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
if (evaluation()) {
|
|
315
|
+
clearInterval(inter);
|
|
316
|
+
resolve(true);
|
|
317
|
+
}
|
|
318
|
+
}, 100);
|
|
319
|
+
})];
|
|
320
|
+
});
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
var NaverMintMapController = function (_super) {
|
|
325
|
+
__extends(NaverMintMapController, _super);
|
|
326
|
+
|
|
327
|
+
function NaverMintMapController(props) {
|
|
328
|
+
var _this = _super.call(this, props) || this;
|
|
329
|
+
|
|
330
|
+
_this.type = 'naver';
|
|
331
|
+
_this.map = null;
|
|
332
|
+
_this.scriptUrl = 'https://openapi.map.naver.com/openapi/v3/maps.js';
|
|
333
|
+
_this.scriptModules = ['drawing'];
|
|
334
|
+
_this.polylineEvents = ['mouseover', 'mouseout'];
|
|
335
|
+
_this.polygonEvents = ['mouseover', 'mouseout'];
|
|
336
|
+
_this.markerEvents = ['click', 'mouseover', 'mouseout'];
|
|
337
|
+
_this.dragStartPoint = [0, 0];
|
|
338
|
+
_this.dragged = false;
|
|
339
|
+
console.log("".concat(_this.type, " controller loadded"));
|
|
340
|
+
return _this;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
NaverMintMapController.prototype.createPolyline = function (polyline) {
|
|
344
|
+
var _this = this;
|
|
345
|
+
|
|
346
|
+
var _a = polyline.options,
|
|
347
|
+
position = _a.position,
|
|
348
|
+
_b = _a.lineColor,
|
|
349
|
+
lineColor = _b === void 0 ? 'blue' : _b,
|
|
350
|
+
_c = _a.lineSize,
|
|
351
|
+
lineSize = _c === void 0 ? 1 : _c,
|
|
352
|
+
_d = _a.lineOpacity,
|
|
353
|
+
lineOpacity = _d === void 0 ? 1 : _d,
|
|
354
|
+
_e = _a.visible,
|
|
355
|
+
visible = _e === void 0 ? true : _e,
|
|
356
|
+
_f = _a.editable,
|
|
357
|
+
editable = _f === void 0 ? false : _f,
|
|
358
|
+
event = _a.event;
|
|
359
|
+
|
|
360
|
+
if (this.map && Array.isArray(position)) {
|
|
361
|
+
var path = position.map(function (elem) {
|
|
362
|
+
return Array.isArray(elem) ? new Position(elem[1], elem[0]) : elem;
|
|
363
|
+
});
|
|
364
|
+
var pol_1 = new naver.maps.Polyline({
|
|
365
|
+
map: this.map,
|
|
366
|
+
path: path,
|
|
367
|
+
strokeColor: lineColor,
|
|
368
|
+
strokeWeight: lineSize,
|
|
369
|
+
strokeOpacity: lineOpacity,
|
|
370
|
+
clickable: true,
|
|
371
|
+
visible: visible
|
|
372
|
+
});
|
|
373
|
+
editable && pol_1.setEditable(editable);
|
|
374
|
+
polyline.native = pol_1;
|
|
375
|
+
event && event.forEach(function (handler, key) {
|
|
376
|
+
if (_this.polylineEvents.includes(key)) {
|
|
377
|
+
naver.maps.Event.addListener(pol_1, key, handler);
|
|
378
|
+
}
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
NaverMintMapController.prototype.updatePolyline = function (polyline, options) {
|
|
384
|
+
if (polyline && polyline.native && polyline.native instanceof naver.maps.Polyline) {
|
|
385
|
+
var path = void 0;
|
|
386
|
+
|
|
387
|
+
if (Array.isArray(options.position)) {
|
|
388
|
+
path = options.position.map(function (elem) {
|
|
389
|
+
return Array.isArray(elem) ? new Position(elem[1], elem[0]) : elem;
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
polyline.native.setOptions({
|
|
394
|
+
path: path || polyline.native.getPath(),
|
|
395
|
+
visible: options.visible === undefined || options.visible,
|
|
396
|
+
strokeColor: options.lineColor,
|
|
397
|
+
strokeWeight: options.lineSize,
|
|
398
|
+
strokeOpacity: options.lineOpacity
|
|
399
|
+
});
|
|
400
|
+
options.editable !== undefined && polyline.native.setEditable(options.editable);
|
|
401
|
+
}
|
|
402
|
+
};
|
|
403
|
+
|
|
404
|
+
NaverMintMapController.prototype.createPolygon = function (polygon) {
|
|
405
|
+
var _this = this;
|
|
406
|
+
|
|
407
|
+
var _a = polygon.options,
|
|
408
|
+
position = _a.position,
|
|
409
|
+
innerPositions = _a.innerPositions,
|
|
410
|
+
_b = _a.lineColor,
|
|
411
|
+
lineColor = _b === void 0 ? 'green' : _b,
|
|
412
|
+
_c = _a.lineSize,
|
|
413
|
+
lineSize = _c === void 0 ? 1 : _c,
|
|
414
|
+
_d = _a.lineOpacity,
|
|
415
|
+
lineOpacity = _d === void 0 ? 1 : _d,
|
|
416
|
+
_e = _a.fillColor,
|
|
417
|
+
fillColor = _e === void 0 ? 'lightgreen' : _e,
|
|
418
|
+
_f = _a.fillOpacity,
|
|
419
|
+
fillOpacity = _f === void 0 ? 0.5 : _f,
|
|
420
|
+
_g = _a.visible,
|
|
421
|
+
visible = _g === void 0 ? true : _g;
|
|
422
|
+
_a.editable;
|
|
423
|
+
var event = _a.event;
|
|
424
|
+
|
|
425
|
+
if (this.map && Array.isArray(position)) {
|
|
426
|
+
var outLine = position.map(function (elem) {
|
|
427
|
+
return Array.isArray(elem) ? new Position(elem[1], elem[0]) : elem;
|
|
428
|
+
});
|
|
429
|
+
var paths = innerPositions ? __spreadArray([outLine], innerPositions, true) : [outLine];
|
|
430
|
+
var pol_2 = new naver.maps.Polygon({
|
|
431
|
+
map: this.map,
|
|
432
|
+
paths: paths,
|
|
433
|
+
strokeColor: lineColor,
|
|
434
|
+
strokeWeight: lineSize,
|
|
435
|
+
strokeOpacity: lineOpacity,
|
|
436
|
+
fillColor: fillColor,
|
|
437
|
+
fillOpacity: fillOpacity,
|
|
438
|
+
clickable: true,
|
|
439
|
+
visible: visible
|
|
440
|
+
});
|
|
441
|
+
polygon.native = pol_2;
|
|
442
|
+
event && event.forEach(function (handler, key) {
|
|
443
|
+
if (_this.polygonEvents.includes(key)) {
|
|
444
|
+
naver.maps.Event.addListener(pol_2, key, handler);
|
|
445
|
+
}
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
|
|
450
|
+
NaverMintMapController.prototype.updatePolygon = function (polygon, options) {
|
|
451
|
+
if (polygon && polygon.native && polygon.native instanceof naver.maps.Polygon) {
|
|
452
|
+
polygon.native.setOptions({
|
|
453
|
+
paths: polygon.native.getPaths(),
|
|
454
|
+
visible: options.visible === undefined || options.visible,
|
|
455
|
+
strokeColor: options.lineColor,
|
|
456
|
+
strokeWeight: options.lineSize,
|
|
457
|
+
strokeOpacity: options.lineOpacity,
|
|
458
|
+
fillColor: options.fillColor,
|
|
459
|
+
fillOpacity: options.fillOpacity
|
|
460
|
+
});
|
|
461
|
+
options.editable !== undefined && polygon.native.setEditable(options.editable);
|
|
462
|
+
}
|
|
463
|
+
};
|
|
464
|
+
|
|
465
|
+
NaverMintMapController.prototype.createMarker = function (marker) {
|
|
466
|
+
var _this = this;
|
|
467
|
+
|
|
468
|
+
var _a;
|
|
469
|
+
|
|
470
|
+
if (this.map) {
|
|
471
|
+
var options = {
|
|
472
|
+
map: this.map,
|
|
473
|
+
position: marker.options.position,
|
|
474
|
+
visible: marker.options.visible === undefined || marker.options.visible
|
|
475
|
+
};
|
|
476
|
+
marker.element && (options.icon = {
|
|
477
|
+
content: marker.element,
|
|
478
|
+
anchor: marker.options.anchor
|
|
479
|
+
});
|
|
480
|
+
var naverMarker_1 = new naver.maps.Marker(options);
|
|
481
|
+
marker.native = naverMarker_1;
|
|
482
|
+
((_a = marker.options) === null || _a === void 0 ? void 0 : _a.event) && marker.options.event.forEach(function (handler, key) {
|
|
483
|
+
if (_this.markerEvents.includes(key)) {
|
|
484
|
+
naver.maps.Event.addListener(naverMarker_1, key, handler);
|
|
485
|
+
}
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
};
|
|
489
|
+
|
|
490
|
+
NaverMintMapController.prototype.updateMarker = function (marker, options) {
|
|
491
|
+
if (marker && marker.native && marker.native instanceof naver.maps.Marker) {
|
|
492
|
+
var map = marker.native.getMap();
|
|
493
|
+
|
|
494
|
+
if (map) {
|
|
495
|
+
var newOption = {
|
|
496
|
+
map: map,
|
|
497
|
+
position: options.position instanceof Position ? options.position : marker.native.getPosition(),
|
|
498
|
+
visible: options.visible === undefined || options.visible
|
|
499
|
+
};
|
|
500
|
+
|
|
501
|
+
if (options.anchor) {
|
|
502
|
+
newOption.icon = __assign(__assign({}, marker.native.getIcon()), {
|
|
503
|
+
anchor: options.anchor
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
marker.native.setOptions({
|
|
508
|
+
map: map,
|
|
509
|
+
position: options.position instanceof Position ? options.position : marker.native.getPosition(),
|
|
510
|
+
visible: options.visible === undefined || options.visible,
|
|
511
|
+
icon: __assign(__assign({}, marker.native.getIcon()), {
|
|
512
|
+
anchor: options.anchor
|
|
513
|
+
})
|
|
514
|
+
});
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
};
|
|
518
|
+
|
|
519
|
+
NaverMintMapController.prototype.getMaxZIndex = function (increment) {
|
|
520
|
+
if (increment === void 0) {
|
|
521
|
+
increment = 0;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
if (this.map) {
|
|
525
|
+
var targetPane = this.map.getPanes().overlayImage;
|
|
526
|
+
var max = 0;
|
|
527
|
+
|
|
528
|
+
for (var i = 0; i < targetPane.childElementCount; i++) {
|
|
529
|
+
var elem = targetPane.children[i];
|
|
530
|
+
|
|
531
|
+
if (elem instanceof HTMLElement) {
|
|
532
|
+
var index = Number(elem.style.zIndex);
|
|
533
|
+
|
|
534
|
+
if (!isNaN(index) && index > max) {
|
|
535
|
+
max = index;
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
this.markerMaxZIndex = max + increment;
|
|
541
|
+
return this.markerMaxZIndex;
|
|
542
|
+
} else {
|
|
543
|
+
return this.markerMaxZIndex || 1;
|
|
544
|
+
}
|
|
545
|
+
};
|
|
546
|
+
|
|
547
|
+
NaverMintMapController.prototype.markerToTheTop = function (marker) {
|
|
548
|
+
if (this.map && marker.element && marker.element instanceof HTMLElement) {
|
|
549
|
+
var parent_1 = marker.element.parentElement;
|
|
550
|
+
|
|
551
|
+
if (parent_1) {
|
|
552
|
+
parent_1.style.zIndex = String(this.getMaxZIndex(1));
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
};
|
|
556
|
+
|
|
557
|
+
NaverMintMapController.prototype.clearDrawable = function (drawable) {
|
|
558
|
+
if (drawable && drawable.native && drawable.native instanceof naver.maps.OverlayView) {
|
|
559
|
+
drawable.native.setMap(null);
|
|
560
|
+
return true;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
return false;
|
|
564
|
+
};
|
|
565
|
+
|
|
566
|
+
NaverMintMapController.prototype.isMapDragged = function () {
|
|
567
|
+
return this.dragged;
|
|
568
|
+
};
|
|
569
|
+
|
|
570
|
+
NaverMintMapController.prototype.setMapDragged = function (value) {
|
|
571
|
+
this.dragged = false;
|
|
572
|
+
};
|
|
573
|
+
|
|
574
|
+
NaverMintMapController.prototype.loadMapApi = function () {
|
|
575
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
576
|
+
var _this = this;
|
|
577
|
+
|
|
578
|
+
return __generator(this, function (_a) {
|
|
579
|
+
return [2, new Promise(function (resolve) {
|
|
580
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
581
|
+
var callbackName, loaded, params, ok;
|
|
582
|
+
return __generator(this, function (_a) {
|
|
583
|
+
switch (_a.label) {
|
|
584
|
+
case 0:
|
|
585
|
+
callbackName = "load".concat(new Date().getTime());
|
|
586
|
+
loaded = false;
|
|
587
|
+
|
|
588
|
+
window[callbackName] = function () {
|
|
589
|
+
console.log('naver api loaded');
|
|
590
|
+
loaded = true;
|
|
591
|
+
delete window[callbackName];
|
|
592
|
+
};
|
|
593
|
+
|
|
594
|
+
params = {
|
|
595
|
+
ncpClientId: this.mapProps.mapKey,
|
|
596
|
+
submodules: this.scriptModules.join(','),
|
|
597
|
+
callback: callbackName
|
|
598
|
+
};
|
|
599
|
+
return [4, this.loadScript(this.buildUrl(this.scriptUrl, params), 'naverscript')];
|
|
600
|
+
|
|
601
|
+
case 1:
|
|
602
|
+
_a.sent();
|
|
603
|
+
|
|
604
|
+
return [4, waiting(function () {
|
|
605
|
+
return loaded;
|
|
606
|
+
})];
|
|
607
|
+
|
|
608
|
+
case 2:
|
|
609
|
+
ok = _a.sent();
|
|
610
|
+
|
|
611
|
+
if (!ok) {
|
|
612
|
+
throw new Error('naver script api load failed!!');
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
this.mapApiLoaded = true;
|
|
616
|
+
resolve(true);
|
|
617
|
+
console.log("".concat(this.type, " map script loaded"));
|
|
618
|
+
return [2];
|
|
619
|
+
}
|
|
620
|
+
});
|
|
621
|
+
});
|
|
622
|
+
})];
|
|
623
|
+
});
|
|
624
|
+
});
|
|
625
|
+
};
|
|
626
|
+
|
|
627
|
+
NaverMintMapController.prototype.initializingMap = function (divElement) {
|
|
628
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
629
|
+
var _this = this;
|
|
630
|
+
|
|
631
|
+
return __generator(this, function (_a) {
|
|
632
|
+
return [2, new Promise(function (resolve) {
|
|
633
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
634
|
+
var map;
|
|
635
|
+
|
|
636
|
+
var _this = this;
|
|
637
|
+
|
|
638
|
+
var _a, _b;
|
|
639
|
+
|
|
640
|
+
return __generator(this, function (_c) {
|
|
641
|
+
switch (_c.label) {
|
|
642
|
+
case 0:
|
|
643
|
+
if (this.mapInitialized && this.map) {
|
|
644
|
+
if (this.map.getElement() === divElement) {
|
|
645
|
+
resolve(this.map);
|
|
646
|
+
return [2];
|
|
647
|
+
} else {
|
|
648
|
+
this.map.destroy();
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
if (!!this.mapApiLoaded) return [3, 2];
|
|
653
|
+
return [4, this.loadMapApi()];
|
|
654
|
+
|
|
655
|
+
case 1:
|
|
656
|
+
_c.sent();
|
|
657
|
+
|
|
658
|
+
_c.label = 2;
|
|
659
|
+
|
|
660
|
+
case 2:
|
|
661
|
+
map = new naver.maps.Map(divElement, {
|
|
662
|
+
center: (_a = this.mapProps.base) === null || _a === void 0 ? void 0 : _a.center,
|
|
663
|
+
zoom: (_b = this.mapProps.base) === null || _b === void 0 ? void 0 : _b.zoomLevel,
|
|
664
|
+
logoControl: false,
|
|
665
|
+
mapDataControl: false,
|
|
666
|
+
mapTypeControl: false,
|
|
667
|
+
scaleControl: false
|
|
668
|
+
});
|
|
669
|
+
map.addListener('dragstart', function (e) {
|
|
670
|
+
_this.dragStartPoint[0] = e.domEvent.clientX;
|
|
671
|
+
_this.dragStartPoint[1] = e.domEvent.clientY;
|
|
672
|
+
});
|
|
673
|
+
map.addListener('dragend', function (e) {
|
|
674
|
+
if (_this.dragStartPoint[0] === e.domEvent.clientX && _this.dragStartPoint[1] === e.domEvent.clientY) {
|
|
675
|
+
_this.dragged = false;
|
|
676
|
+
} else {
|
|
677
|
+
_this.dragged = true;
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
_this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
|
|
681
|
+
});
|
|
682
|
+
map.addListener('zoom_changed', function () {
|
|
683
|
+
_this.map && _this.mapProps.onZoomChanged && _this.mapProps.onZoomChanged(_this.map.getZoom());
|
|
684
|
+
_this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
|
|
685
|
+
});
|
|
686
|
+
map.addListener('click', function (e) {
|
|
687
|
+
console.log('map click', e);
|
|
688
|
+
var pos = new Position(e.coord.y, e.coord.x);
|
|
689
|
+
pos.offset = new Offset(e.offset.x, e.offset.y);
|
|
690
|
+
_this.mapProps.onClick && _this.mapProps.onClick(pos);
|
|
691
|
+
});
|
|
692
|
+
this.map = map;
|
|
693
|
+
this.mapInitialized = true;
|
|
694
|
+
console.log("".concat(this.type, " map script initialized"), divElement);
|
|
695
|
+
resolve(map);
|
|
696
|
+
return [2];
|
|
697
|
+
}
|
|
698
|
+
});
|
|
699
|
+
});
|
|
700
|
+
})];
|
|
701
|
+
});
|
|
702
|
+
});
|
|
703
|
+
};
|
|
704
|
+
|
|
705
|
+
NaverMintMapController.prototype.destroyMap = function () {
|
|
706
|
+
console.log("".concat(this.type, " map destroyed"));
|
|
707
|
+
|
|
708
|
+
try {
|
|
709
|
+
this.map && this.map.destroy();
|
|
710
|
+
} catch (e) {
|
|
711
|
+
console.log('naver map destroy error', e);
|
|
712
|
+
}
|
|
713
|
+
};
|
|
714
|
+
|
|
715
|
+
NaverMintMapController.prototype.getCurrBounds = function () {
|
|
716
|
+
if (!this.map) {
|
|
717
|
+
throw new Error('Map is not initialized!!');
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
var bounds = this.map.getBounds();
|
|
721
|
+
return new Bounds(new Position(bounds.getMin().y, bounds.getMin().x), new Position(bounds.getMax().y, bounds.getMax().x));
|
|
722
|
+
};
|
|
723
|
+
|
|
724
|
+
NaverMintMapController.prototype.panningTo = function (targetCenter) {
|
|
725
|
+
var _a;
|
|
726
|
+
|
|
727
|
+
(_a = this.map) === null || _a === void 0 ? void 0 : _a.panTo(targetCenter, {
|
|
728
|
+
duration: 1000
|
|
729
|
+
});
|
|
730
|
+
};
|
|
731
|
+
|
|
732
|
+
NaverMintMapController.prototype.getZoomLevel = function () {
|
|
733
|
+
var _a;
|
|
734
|
+
|
|
735
|
+
return ((_a = this.map) === null || _a === void 0 ? void 0 : _a.getZoom()) || 13;
|
|
736
|
+
};
|
|
737
|
+
|
|
738
|
+
return NaverMintMapController;
|
|
739
|
+
}(MintMapController);
|
|
740
|
+
|
|
741
|
+
var GoogleMintMapController = function (_super) {
|
|
742
|
+
__extends(GoogleMintMapController, _super);
|
|
743
|
+
|
|
744
|
+
function GoogleMintMapController(props) {
|
|
745
|
+
var _this = _super.call(this, props) || this;
|
|
746
|
+
|
|
747
|
+
_this.type = 'google';
|
|
748
|
+
_this.map = null;
|
|
749
|
+
_this.scriptUrl = 'https://maps.googleapis.com/maps/api/js';
|
|
750
|
+
_this.scriptModules = ['marker'];
|
|
751
|
+
_this.polylineEvents = ['mouseover', 'mouseout'];
|
|
752
|
+
_this.polygonEvents = ['mouseover', 'mouseout'];
|
|
753
|
+
_this.markerEvents = ['click', 'mouseover', 'mouseout'];
|
|
754
|
+
_this.dragged = false;
|
|
755
|
+
|
|
756
|
+
_this.destroyMap = function () {
|
|
757
|
+
console.log("".concat(_this.type, " map destroy feature is not supported"));
|
|
758
|
+
};
|
|
759
|
+
|
|
760
|
+
console.log("".concat(_this.type, " controller loadded"));
|
|
761
|
+
return _this;
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
GoogleMintMapController.prototype.createPolyline = function (polyline) {
|
|
765
|
+
var _this = this;
|
|
766
|
+
|
|
767
|
+
var _a = polyline.options,
|
|
768
|
+
position = _a.position,
|
|
769
|
+
_b = _a.lineColor,
|
|
770
|
+
lineColor = _b === void 0 ? 'blue' : _b,
|
|
771
|
+
_c = _a.lineSize,
|
|
772
|
+
lineSize = _c === void 0 ? 1 : _c,
|
|
773
|
+
_d = _a.lineOpacity,
|
|
774
|
+
lineOpacity = _d === void 0 ? 1 : _d,
|
|
775
|
+
_e = _a.visible,
|
|
776
|
+
visible = _e === void 0 ? true : _e,
|
|
777
|
+
_f = _a.editable,
|
|
778
|
+
editable = _f === void 0 ? false : _f,
|
|
779
|
+
event = _a.event;
|
|
780
|
+
|
|
781
|
+
if (this.map && Array.isArray(position)) {
|
|
782
|
+
var path = position.map(function (elem) {
|
|
783
|
+
return Array.isArray(elem) ? new Position(elem[1], elem[0]) : elem;
|
|
784
|
+
});
|
|
785
|
+
var pol_1 = new google.maps.Polyline({
|
|
786
|
+
map: this.map,
|
|
787
|
+
path: path,
|
|
788
|
+
strokeColor: lineColor,
|
|
789
|
+
strokeWeight: lineSize,
|
|
790
|
+
strokeOpacity: lineOpacity,
|
|
791
|
+
clickable: true,
|
|
792
|
+
visible: visible,
|
|
793
|
+
editable: editable
|
|
794
|
+
});
|
|
795
|
+
polyline.native = pol_1;
|
|
796
|
+
event && event.forEach(function (handler, key) {
|
|
797
|
+
if (_this.polylineEvents.includes(key)) {
|
|
798
|
+
pol_1.addListener(key, handler);
|
|
799
|
+
}
|
|
800
|
+
});
|
|
801
|
+
}
|
|
802
|
+
};
|
|
803
|
+
|
|
804
|
+
GoogleMintMapController.prototype.updatePolyline = function (polyline, options) {
|
|
805
|
+
if (polyline && polyline.native && polyline.native instanceof google.maps.Polyline) {
|
|
806
|
+
var polylineOption = this.getValidOptions(options);
|
|
807
|
+
|
|
808
|
+
if (this.map && Array.isArray(options.position)) {
|
|
809
|
+
var path = options.position.map(function (elem) {
|
|
810
|
+
return Array.isArray(elem) ? new Position(elem[1], elem[0]) : elem;
|
|
811
|
+
});
|
|
812
|
+
polylineOption.path = path;
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
polyline.native.setOptions(polylineOption);
|
|
816
|
+
}
|
|
817
|
+
};
|
|
818
|
+
|
|
819
|
+
GoogleMintMapController.prototype.createPolygon = function (polygon) {
|
|
820
|
+
var _this = this;
|
|
821
|
+
|
|
822
|
+
var _a = polygon.options,
|
|
823
|
+
position = _a.position,
|
|
824
|
+
innerPositions = _a.innerPositions,
|
|
825
|
+
_b = _a.lineColor,
|
|
826
|
+
lineColor = _b === void 0 ? 'green' : _b,
|
|
827
|
+
_c = _a.lineSize,
|
|
828
|
+
lineSize = _c === void 0 ? 1 : _c,
|
|
829
|
+
_d = _a.lineOpacity,
|
|
830
|
+
lineOpacity = _d === void 0 ? 1 : _d,
|
|
831
|
+
_e = _a.fillColor,
|
|
832
|
+
fillColor = _e === void 0 ? 'lightgreen' : _e,
|
|
833
|
+
_f = _a.fillOpacity,
|
|
834
|
+
fillOpacity = _f === void 0 ? 0.5 : _f,
|
|
835
|
+
_g = _a.visible,
|
|
836
|
+
visible = _g === void 0 ? true : _g,
|
|
837
|
+
_h = _a.editable,
|
|
838
|
+
editable = _h === void 0 ? false : _h,
|
|
839
|
+
event = _a.event;
|
|
840
|
+
|
|
841
|
+
if (this.map && Array.isArray(position)) {
|
|
842
|
+
var outLine = position.map(function (elem) {
|
|
843
|
+
return Array.isArray(elem) ? new Position(elem[1], elem[0]) : elem;
|
|
844
|
+
});
|
|
845
|
+
var paths = innerPositions ? __spreadArray([outLine], innerPositions, true) : [outLine];
|
|
846
|
+
var pol_2 = new google.maps.Polygon({
|
|
847
|
+
map: this.map,
|
|
848
|
+
paths: paths,
|
|
849
|
+
strokeColor: lineColor,
|
|
850
|
+
strokeWeight: lineSize,
|
|
851
|
+
strokeOpacity: lineOpacity,
|
|
852
|
+
fillColor: fillColor,
|
|
853
|
+
fillOpacity: fillOpacity,
|
|
854
|
+
clickable: true,
|
|
855
|
+
visible: visible,
|
|
856
|
+
editable: editable
|
|
857
|
+
});
|
|
858
|
+
polygon.native = pol_2;
|
|
859
|
+
event && event.forEach(function (handler, key) {
|
|
860
|
+
if (_this.polygonEvents.includes(key)) {
|
|
861
|
+
pol_2.addListener(key, handler);
|
|
862
|
+
}
|
|
863
|
+
});
|
|
864
|
+
}
|
|
865
|
+
};
|
|
866
|
+
|
|
867
|
+
GoogleMintMapController.prototype.updatePolygon = function (polygon, options) {
|
|
868
|
+
if (polygon && polygon.native && polygon.native instanceof google.maps.Polygon) {
|
|
869
|
+
var polygonOption = this.getValidOptions(options);
|
|
870
|
+
polygon.native.setOptions(polygonOption);
|
|
871
|
+
}
|
|
872
|
+
};
|
|
873
|
+
|
|
874
|
+
GoogleMintMapController.prototype.getValidOptions = function (options) {
|
|
875
|
+
var target = {};
|
|
876
|
+
|
|
877
|
+
for (var _i = 0, _a = Object.getOwnPropertyNames(options); _i < _a.length; _i++) {
|
|
878
|
+
var name_1 = _a[_i];
|
|
879
|
+
|
|
880
|
+
if (options[name_1] !== undefined) {
|
|
881
|
+
target[name_1] = options[name_1];
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
return target;
|
|
886
|
+
};
|
|
887
|
+
|
|
888
|
+
GoogleMintMapController.prototype.createMarker = function (marker) {
|
|
889
|
+
var _this = this;
|
|
890
|
+
|
|
891
|
+
var _a;
|
|
892
|
+
|
|
893
|
+
if (this.map) {
|
|
894
|
+
var googleMarker_1;
|
|
895
|
+
|
|
896
|
+
if (marker.element) {
|
|
897
|
+
var options = {
|
|
898
|
+
map: this.map,
|
|
899
|
+
position: marker.options.position
|
|
900
|
+
};
|
|
901
|
+
options.content = marker.element;
|
|
902
|
+
googleMarker_1 = new google.maps.marker.AdvancedMarkerView(options);
|
|
903
|
+
} else {
|
|
904
|
+
var options = {
|
|
905
|
+
map: this.map,
|
|
906
|
+
position: marker.options.position,
|
|
907
|
+
visible: marker.options.visible === undefined || marker.options.visible,
|
|
908
|
+
anchorPoint: marker.options.anchor
|
|
909
|
+
};
|
|
910
|
+
googleMarker_1 = new google.maps.Marker(options);
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
marker.native = googleMarker_1;
|
|
914
|
+
((_a = marker.options) === null || _a === void 0 ? void 0 : _a.event) && marker.options.event.forEach(function (handler, key) {
|
|
915
|
+
if (_this.markerEvents.includes(key)) {
|
|
916
|
+
googleMarker_1.addListener(key, handler);
|
|
917
|
+
}
|
|
918
|
+
});
|
|
919
|
+
}
|
|
920
|
+
};
|
|
921
|
+
|
|
922
|
+
GoogleMintMapController.prototype.updateMarker = function (marker, options) {
|
|
923
|
+
var _a, _b;
|
|
924
|
+
|
|
925
|
+
if (marker && marker.native) {
|
|
926
|
+
if (marker.native instanceof google.maps.Marker) {
|
|
927
|
+
var map = marker.native.getMap();
|
|
928
|
+
|
|
929
|
+
if (map) {
|
|
930
|
+
marker.native.setOptions({
|
|
931
|
+
map: map,
|
|
932
|
+
position: options.position instanceof Position ? options.position : marker.native.getPosition(),
|
|
933
|
+
visible: options.visible === undefined || options.visible
|
|
934
|
+
});
|
|
935
|
+
}
|
|
936
|
+
} else if (marker.native instanceof google.maps.marker.AdvancedMarkerView) {
|
|
937
|
+
if (options.visible !== undefined && marker.native.element) {
|
|
938
|
+
marker.native.element.style.visibility = options.visible ? 'visible' : 'hidden';
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
if (options.position instanceof Position && (((_a = marker.native.position) === null || _a === void 0 ? void 0 : _a.lat) != options.position.lat || ((_b = marker.native.position) === null || _b === void 0 ? void 0 : _b.lng) != options.position.lng)) {
|
|
942
|
+
marker.native.position = options.position;
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
};
|
|
947
|
+
|
|
948
|
+
GoogleMintMapController.prototype.getMaxZIndex = function (increment, parent) {
|
|
949
|
+
if (increment === void 0) {
|
|
950
|
+
increment = 0;
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
if (this.map) {
|
|
954
|
+
var targetPane = parent;
|
|
955
|
+
var max = 0;
|
|
956
|
+
|
|
957
|
+
for (var i = 0; i < targetPane.childElementCount; i++) {
|
|
958
|
+
var elem = targetPane.children[i];
|
|
959
|
+
|
|
960
|
+
if (elem instanceof HTMLElement) {
|
|
961
|
+
var index = Number(elem.style.zIndex);
|
|
962
|
+
|
|
963
|
+
if (!isNaN(index) && index > max) {
|
|
964
|
+
max = index;
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
this.markerMaxZIndex = max + increment;
|
|
970
|
+
return this.markerMaxZIndex;
|
|
971
|
+
} else {
|
|
972
|
+
return this.markerMaxZIndex || 1;
|
|
973
|
+
}
|
|
974
|
+
};
|
|
975
|
+
|
|
976
|
+
GoogleMintMapController.prototype.markerToTheTop = function (marker) {
|
|
977
|
+
if (this.map && marker.element && marker.element instanceof HTMLElement) {
|
|
978
|
+
var parent_1 = marker.element.parentElement;
|
|
979
|
+
|
|
980
|
+
if (parent_1) {
|
|
981
|
+
parent_1.style.zIndex = String(this.getMaxZIndex(1, parent_1));
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
};
|
|
985
|
+
|
|
986
|
+
GoogleMintMapController.prototype.clearDrawable = function (drawable) {
|
|
987
|
+
if (drawable && drawable.native) {
|
|
988
|
+
if (drawable.native instanceof google.maps.Marker || drawable.native instanceof google.maps.Polygon || drawable.native instanceof google.maps.Polyline) {
|
|
989
|
+
drawable.native.setMap(null);
|
|
990
|
+
return true;
|
|
991
|
+
} else if (drawable.native instanceof google.maps.marker.AdvancedMarkerView) {
|
|
992
|
+
drawable.native.map = null;
|
|
993
|
+
return true;
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
return false;
|
|
998
|
+
};
|
|
999
|
+
|
|
1000
|
+
GoogleMintMapController.prototype.isMapDragged = function () {
|
|
1001
|
+
return this.dragged;
|
|
1002
|
+
};
|
|
1003
|
+
|
|
1004
|
+
GoogleMintMapController.prototype.setMapDragged = function (value) {
|
|
1005
|
+
this.dragged = false;
|
|
1006
|
+
};
|
|
1007
|
+
|
|
1008
|
+
GoogleMintMapController.prototype.loadMapApi = function () {
|
|
1009
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1010
|
+
var _this = this;
|
|
1011
|
+
|
|
1012
|
+
return __generator(this, function (_a) {
|
|
1013
|
+
return [2, new Promise(function (resolve) {
|
|
1014
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
1015
|
+
var callbackName, loaded, params, ok;
|
|
1016
|
+
return __generator(this, function (_a) {
|
|
1017
|
+
switch (_a.label) {
|
|
1018
|
+
case 0:
|
|
1019
|
+
callbackName = "load".concat(new Date().getTime());
|
|
1020
|
+
loaded = false;
|
|
1021
|
+
|
|
1022
|
+
window[callbackName] = function () {
|
|
1023
|
+
console.log('google api loaded');
|
|
1024
|
+
loaded = true;
|
|
1025
|
+
delete window[callbackName];
|
|
1026
|
+
};
|
|
1027
|
+
|
|
1028
|
+
params = {
|
|
1029
|
+
key: this.mapProps.mapKey,
|
|
1030
|
+
libraries: this.scriptModules.join(','),
|
|
1031
|
+
v: 'beta',
|
|
1032
|
+
callback: callbackName
|
|
1033
|
+
};
|
|
1034
|
+
return [4, this.loadScript(this.buildUrl(this.scriptUrl, params), 'googlescript')];
|
|
1035
|
+
|
|
1036
|
+
case 1:
|
|
1037
|
+
_a.sent();
|
|
1038
|
+
|
|
1039
|
+
return [4, waiting(function () {
|
|
1040
|
+
return loaded;
|
|
1041
|
+
})];
|
|
1042
|
+
|
|
1043
|
+
case 2:
|
|
1044
|
+
ok = _a.sent();
|
|
1045
|
+
|
|
1046
|
+
if (!ok) {
|
|
1047
|
+
throw new Error('google script api load failed!!');
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
this.mapApiLoaded = true;
|
|
1051
|
+
resolve(true);
|
|
1052
|
+
console.log("".concat(this.type, " map script api loaded"));
|
|
1053
|
+
return [2];
|
|
1054
|
+
}
|
|
1055
|
+
});
|
|
1056
|
+
});
|
|
1057
|
+
})];
|
|
1058
|
+
});
|
|
1059
|
+
});
|
|
1060
|
+
};
|
|
1061
|
+
|
|
1062
|
+
GoogleMintMapController.prototype.initializingMap = function (divElement) {
|
|
1063
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1064
|
+
var _this = this;
|
|
1065
|
+
|
|
1066
|
+
return __generator(this, function (_a) {
|
|
1067
|
+
return [2, new Promise(function (resolve) {
|
|
1068
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
1069
|
+
var map;
|
|
1070
|
+
|
|
1071
|
+
var _this = this;
|
|
1072
|
+
|
|
1073
|
+
var _a, _b;
|
|
1074
|
+
|
|
1075
|
+
return __generator(this, function (_c) {
|
|
1076
|
+
switch (_c.label) {
|
|
1077
|
+
case 0:
|
|
1078
|
+
if (this.mapInitialized && this.map) {
|
|
1079
|
+
if (this.map.getDiv() === divElement) {
|
|
1080
|
+
resolve(this.map);
|
|
1081
|
+
return [2];
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
if (!!this.mapApiLoaded) return [3, 2];
|
|
1086
|
+
return [4, this.loadMapApi()];
|
|
1087
|
+
|
|
1088
|
+
case 1:
|
|
1089
|
+
_c.sent();
|
|
1090
|
+
|
|
1091
|
+
_c.label = 2;
|
|
1092
|
+
|
|
1093
|
+
case 2:
|
|
1094
|
+
map = new google.maps.Map(divElement, {
|
|
1095
|
+
mapId: this.mapProps.mapId,
|
|
1096
|
+
center: (_a = this.mapProps.base) === null || _a === void 0 ? void 0 : _a.center,
|
|
1097
|
+
maxZoom: 21,
|
|
1098
|
+
minZoom: 1,
|
|
1099
|
+
zoom: (_b = this.mapProps.base) === null || _b === void 0 ? void 0 : _b.zoomLevel
|
|
1100
|
+
});
|
|
1101
|
+
map.addListener('dragend', function () {
|
|
1102
|
+
console.log('map dragend');
|
|
1103
|
+
_this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
|
|
1104
|
+
});
|
|
1105
|
+
map.addListener('zoom_changed', function () {
|
|
1106
|
+
console.log('zoom_changed');
|
|
1107
|
+
_this.map && _this.mapProps.onZoomChanged && _this.mapProps.onZoomChanged(_this.map.getZoom());
|
|
1108
|
+
_this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
|
|
1109
|
+
});
|
|
1110
|
+
map.addListener('click', function (e) {
|
|
1111
|
+
console.log('map click', e);
|
|
1112
|
+
var pos = new Position(e.latLng.lat(), e.latLng.lng());
|
|
1113
|
+
pos.offset = new Offset(e.pixel.x, e.pixel.y);
|
|
1114
|
+
_this.mapProps.onClick && _this.mapProps.onClick(pos);
|
|
1115
|
+
});
|
|
1116
|
+
this.map = map;
|
|
1117
|
+
this.mapInitialized = true;
|
|
1118
|
+
console.log("".concat(this.type, " map script initialized"), divElement);
|
|
1119
|
+
resolve(map);
|
|
1120
|
+
return [2];
|
|
1121
|
+
}
|
|
1122
|
+
});
|
|
1123
|
+
});
|
|
1124
|
+
})];
|
|
1125
|
+
});
|
|
1126
|
+
});
|
|
1127
|
+
};
|
|
1128
|
+
|
|
1129
|
+
GoogleMintMapController.prototype.fromGoogleBounds = function (bounds) {
|
|
1130
|
+
return new Bounds(new Position(bounds.getSouthWest().lat(), bounds.getSouthWest().lng()), new Position(bounds.getNorthEast().lat(), bounds.getNorthEast().lng()));
|
|
1131
|
+
};
|
|
1132
|
+
|
|
1133
|
+
GoogleMintMapController.prototype.getCurrBounds = function () {
|
|
1134
|
+
if (!this.map) {
|
|
1135
|
+
throw new Error('Map is not initialized!!');
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
var bounds = this.map.getBounds();
|
|
1139
|
+
|
|
1140
|
+
if (bounds) {
|
|
1141
|
+
return this.fromGoogleBounds(bounds);
|
|
1142
|
+
} else {
|
|
1143
|
+
throw new Error('bounds is not found!!!');
|
|
1144
|
+
}
|
|
1145
|
+
};
|
|
1146
|
+
|
|
1147
|
+
GoogleMintMapController.prototype.panningTo = function (targetCenter) {
|
|
1148
|
+
var _a;
|
|
1149
|
+
|
|
1150
|
+
(_a = this.map) === null || _a === void 0 ? void 0 : _a.panTo(targetCenter);
|
|
1151
|
+
};
|
|
1152
|
+
|
|
1153
|
+
GoogleMintMapController.prototype.getZoomLevel = function () {
|
|
1154
|
+
var _a;
|
|
1155
|
+
|
|
1156
|
+
return ((_a = this.map) === null || _a === void 0 ? void 0 : _a.getZoom()) || 13;
|
|
1157
|
+
};
|
|
1158
|
+
|
|
1159
|
+
return GoogleMintMapController;
|
|
1160
|
+
}(MintMapController);
|
|
1161
|
+
|
|
1162
|
+
var Position = function () {
|
|
248
1163
|
function Position(lat, lng) {
|
|
249
1164
|
this.lat = 0;
|
|
250
1165
|
this.lng = 0;
|
|
@@ -252,7 +1167,57 @@ var MintMap.Position = function () {
|
|
|
252
1167
|
this.lng = lng;
|
|
253
1168
|
}
|
|
254
1169
|
|
|
255
|
-
return Position;
|
|
1170
|
+
return Position;
|
|
1171
|
+
}();
|
|
1172
|
+
|
|
1173
|
+
var Bounds = function () {
|
|
1174
|
+
function Bounds(nw, se) {
|
|
1175
|
+
this.nw = nw;
|
|
1176
|
+
this.se = se;
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
Bounds.prototype.getCenter = function () {
|
|
1180
|
+
return new Position(this.nw.lat + (this.se.lat - this.nw.lat) / 2, this.nw.lng + (this.se.lng - this.nw.lng) / 2);
|
|
1181
|
+
};
|
|
1182
|
+
|
|
1183
|
+
Bounds.prototype.includes = function (positions) {
|
|
1184
|
+
for (var _i = 0, positions_1 = positions; _i < positions_1.length; _i++) {
|
|
1185
|
+
var pos = positions_1[_i];
|
|
1186
|
+
|
|
1187
|
+
if (this.nw.lat > pos.lat || this.se.lat < pos.lat || this.nw.lng > pos.lng || this.se.lng < pos.lng) {
|
|
1188
|
+
return false;
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
return true;
|
|
1193
|
+
};
|
|
1194
|
+
|
|
1195
|
+
Bounds.prototype.includesOnlyOnePoint = function (positions) {
|
|
1196
|
+
for (var _i = 0, positions_2 = positions; _i < positions_2.length; _i++) {
|
|
1197
|
+
var pos = positions_2[_i];
|
|
1198
|
+
|
|
1199
|
+
if (!(this.nw.lat > pos.lat || this.se.lat < pos.lat || this.nw.lng > pos.lng || this.se.lng < pos.lng)) {
|
|
1200
|
+
return true;
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
return false;
|
|
1205
|
+
};
|
|
1206
|
+
|
|
1207
|
+
Bounds.prototype.intersects = function (positions) {
|
|
1208
|
+
return PolygonCalculator.intersects([this.nw, this.se], positions);
|
|
1209
|
+
};
|
|
1210
|
+
|
|
1211
|
+
return Bounds;
|
|
1212
|
+
}();
|
|
1213
|
+
|
|
1214
|
+
var Offset = function () {
|
|
1215
|
+
function Offset(x, y) {
|
|
1216
|
+
this.x = x;
|
|
1217
|
+
this.y = y;
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
return Offset;
|
|
256
1221
|
}();
|
|
257
1222
|
|
|
258
1223
|
var Drawable = function () {
|
|
@@ -261,7 +1226,7 @@ var Drawable = function () {
|
|
|
261
1226
|
return Drawable;
|
|
262
1227
|
}();
|
|
263
1228
|
|
|
264
|
-
var
|
|
1229
|
+
var Marker = function (_super) {
|
|
265
1230
|
__extends(Marker, _super);
|
|
266
1231
|
|
|
267
1232
|
function Marker(options) {
|
|
@@ -274,7 +1239,7 @@ var MintMap.Marker = function (_super) {
|
|
|
274
1239
|
return Marker;
|
|
275
1240
|
}(Drawable);
|
|
276
1241
|
|
|
277
|
-
var
|
|
1242
|
+
var Polyline = function (_super) {
|
|
278
1243
|
__extends(Polyline, _super);
|
|
279
1244
|
|
|
280
1245
|
function Polyline(options) {
|
|
@@ -287,7 +1252,7 @@ var MintMap.Polyline = function (_super) {
|
|
|
287
1252
|
return Polyline;
|
|
288
1253
|
}(Drawable);
|
|
289
1254
|
|
|
290
|
-
var
|
|
1255
|
+
var Polygon = function (_super) {
|
|
291
1256
|
__extends(Polygon, _super);
|
|
292
1257
|
|
|
293
1258
|
function Polygon(options) {
|
|
@@ -300,7 +1265,7 @@ var MintMap.Polygon = function (_super) {
|
|
|
300
1265
|
Polygon.prototype.getCenter = function () {
|
|
301
1266
|
if (Array.isArray(this.options.position) && this.options.position.length > 0) {
|
|
302
1267
|
var paths = this.options.position.map(function (elem) {
|
|
303
|
-
return elem instanceof
|
|
1268
|
+
return elem instanceof Position ? elem : new Position(elem[0], elem[1]);
|
|
304
1269
|
});
|
|
305
1270
|
return PolygonCalculator.getCenter(paths);
|
|
306
1271
|
}
|
|
@@ -312,8 +1277,6 @@ var MintMap.Polygon = function (_super) {
|
|
|
312
1277
|
}(Drawable);
|
|
313
1278
|
var cn$1 = classNames.bind(styles$2);
|
|
314
1279
|
function MintMap(_a) {
|
|
315
|
-
var _this = this;
|
|
316
|
-
|
|
317
1280
|
var mapType = _a.mapType,
|
|
318
1281
|
children = _a.children,
|
|
319
1282
|
props = __rest(_a, ["mapType", "children"]);
|
|
@@ -325,29 +1288,19 @@ function MintMap(_a) {
|
|
|
325
1288
|
useEffect(function () {
|
|
326
1289
|
if (mapType && mapType.length > 0) {
|
|
327
1290
|
setController(undefined);
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
case 1:
|
|
339
|
-
controllerModule = _a.sent();
|
|
340
|
-
newController = new controllerModule.default(__assign({
|
|
341
|
-
mapType: mapType
|
|
342
|
-
}, props));
|
|
343
|
-
newController.loadMapApi().then(function () {
|
|
344
|
-
setController(newController);
|
|
345
|
-
});
|
|
346
|
-
return [2];
|
|
347
|
-
}
|
|
348
|
-
});
|
|
1291
|
+
var newController_1 = mapType === 'naver' ? new NaverMintMapController(__assign({
|
|
1292
|
+
mapType: mapType
|
|
1293
|
+
}, props)) : mapType === 'google' ? new GoogleMintMapController(__assign({
|
|
1294
|
+
mapType: mapType
|
|
1295
|
+
}, props)) : null;
|
|
1296
|
+
|
|
1297
|
+
if (newController_1) {
|
|
1298
|
+
newController_1.loadMapApi().then(function () {
|
|
1299
|
+
setController(newController_1);
|
|
349
1300
|
});
|
|
350
|
-
}
|
|
1301
|
+
} else {
|
|
1302
|
+
throw new Error("Not Supported Map type ".concat(mapType));
|
|
1303
|
+
}
|
|
351
1304
|
} else {
|
|
352
1305
|
setController(undefined);
|
|
353
1306
|
}
|
|
@@ -405,130 +1358,6 @@ function PointLoading(_a) {
|
|
|
405
1358
|
}, "".concat(text, " ").concat(pointString)));
|
|
406
1359
|
}
|
|
407
1360
|
|
|
408
|
-
var getMapModulePrefix = function (mapType) {
|
|
409
|
-
return mapType.substring(0, 1).toUpperCase() + mapType.substring(1).toLowerCase();
|
|
410
|
-
};
|
|
411
|
-
|
|
412
|
-
var MintMapController = function () {
|
|
413
|
-
function MintMapController(props) {
|
|
414
|
-
this.mapApiLoaded = false;
|
|
415
|
-
this.mapInitialized = false;
|
|
416
|
-
this.mapProps = props;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
MintMapController.prototype.getMap = function () {
|
|
420
|
-
return this.map;
|
|
421
|
-
};
|
|
422
|
-
|
|
423
|
-
MintMapController.prototype.getMapType = function () {
|
|
424
|
-
return this.type;
|
|
425
|
-
};
|
|
426
|
-
|
|
427
|
-
MintMapController.prototype.loadScript = function (url, id) {
|
|
428
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
429
|
-
return __generator(this, function (_a) {
|
|
430
|
-
return [2, new Promise(function (resolve) {
|
|
431
|
-
if (id && document.getElementById(id)) {
|
|
432
|
-
console.log("already loaded script => ".concat(id));
|
|
433
|
-
resolve();
|
|
434
|
-
return;
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
var script = document.createElement('script');
|
|
438
|
-
script.src = url;
|
|
439
|
-
script.async = true;
|
|
440
|
-
script.defer = true;
|
|
441
|
-
script.addEventListener('load', function () {
|
|
442
|
-
resolve();
|
|
443
|
-
});
|
|
444
|
-
document.body.appendChild(script);
|
|
445
|
-
})];
|
|
446
|
-
});
|
|
447
|
-
});
|
|
448
|
-
};
|
|
449
|
-
|
|
450
|
-
MintMapController.prototype.buildUrl = function (baseUrl, param) {
|
|
451
|
-
var params = Object.entries(param).map(function (_a) {
|
|
452
|
-
var key = _a[0],
|
|
453
|
-
value = _a[1];
|
|
454
|
-
var temp = encodeURIComponent(Array.isArray(value) ? value.join(',') : value);
|
|
455
|
-
return "".concat(key, "=").concat(temp);
|
|
456
|
-
}).join('&');
|
|
457
|
-
return "".concat(baseUrl, "?").concat(params);
|
|
458
|
-
};
|
|
459
|
-
|
|
460
|
-
return MintMapController;
|
|
461
|
-
}();
|
|
462
|
-
|
|
463
|
-
var css_248z = ".MintMapWrapper-module_mint-map-control-wrapper__DDb4y {\n position: absolute;\n z-index: 101;\n}\n\n.MintMapWrapper-module_mint-map-overlay-wrapper__Jn4wV {\n position: absolute;\n z-index: 1;\n}";
|
|
464
|
-
var styles = {"mint-map-control-wrapper":"MintMapWrapper-module_mint-map-control-wrapper__DDb4y","mint-map-overlay-wrapper":"MintMapWrapper-module_mint-map-overlay-wrapper__Jn4wV"};
|
|
465
|
-
styleInject(css_248z);
|
|
466
|
-
|
|
467
|
-
var cn = classNames.bind(styles);
|
|
468
|
-
|
|
469
|
-
var getSizeString = function (size) {
|
|
470
|
-
return typeof size === 'string' ? size.replace(/ /g, '') : "".concat(size, "px");
|
|
471
|
-
};
|
|
472
|
-
|
|
473
|
-
var getAlignPosition = function (value, align) {
|
|
474
|
-
if (typeof value === 'string') {
|
|
475
|
-
var trimmed = value.replace(/ /g, '');
|
|
476
|
-
console.log('trimmed:', trimmed);
|
|
477
|
-
var isPercent = trimmed.endsWith('%');
|
|
478
|
-
|
|
479
|
-
if (!isPercent && !trimmed.endsWith('px')) {
|
|
480
|
-
throw new Error("Size [".concat(value, "] is not valid string value."));
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
var numberPart = isPercent ? trimmed.substring(0, trimmed.length - 2) : trimmed.substring(0, trimmed.length - 3);
|
|
484
|
-
var unit = isPercent ? '%' : 'px';
|
|
485
|
-
var numberValue = Number(numberPart);
|
|
486
|
-
|
|
487
|
-
if (isNaN(numberValue)) {
|
|
488
|
-
throw new Error("Size [".concat(value, "] is not valid % or pixel number value."));
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
if (align === 'center') {
|
|
492
|
-
return "calc(50% - ".concat(numberValue / 2).concat(unit, ")");
|
|
493
|
-
} else if (align === 'right' || align === 'bottom') {
|
|
494
|
-
return "calc(100% - ".concat(numberValue).concat(unit, ")");
|
|
495
|
-
} else {
|
|
496
|
-
return '0px';
|
|
497
|
-
}
|
|
498
|
-
} else if (typeof value === 'number') {
|
|
499
|
-
if (align === 'center') {
|
|
500
|
-
return "calc(50% - ".concat(value / 2, "px)");
|
|
501
|
-
} else if (align === 'right' || align === 'bottom') {
|
|
502
|
-
return "calc(100% - ".concat(value, "px)");
|
|
503
|
-
} else {
|
|
504
|
-
return '0px';
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
throw new Error("Size [".concat(value, "] is not valid. (Should be % or pixel number)"));
|
|
509
|
-
};
|
|
510
|
-
|
|
511
|
-
function MapControlWrapper(_a) {
|
|
512
|
-
var _b = _a.width,
|
|
513
|
-
width = _b === void 0 ? 100 : _b,
|
|
514
|
-
_c = _a.height,
|
|
515
|
-
height = _c === void 0 ? 40 : _c,
|
|
516
|
-
_d = _a.positionHorizontal,
|
|
517
|
-
positionHorizontal = _d === void 0 ? 'left' : _d,
|
|
518
|
-
_e = _a.positionVertical,
|
|
519
|
-
positionVertical = _e === void 0 ? 'top' : _e,
|
|
520
|
-
children = _a.children;
|
|
521
|
-
return React.createElement("div", {
|
|
522
|
-
className: cn('mint-map-control-wrapper'),
|
|
523
|
-
style: {
|
|
524
|
-
width: getSizeString(width),
|
|
525
|
-
height: getSizeString(height),
|
|
526
|
-
left: getAlignPosition(width, positionHorizontal),
|
|
527
|
-
top: getAlignPosition(height, positionVertical)
|
|
528
|
-
}
|
|
529
|
-
}, children);
|
|
530
|
-
}
|
|
531
|
-
|
|
532
1361
|
var AnimationPlayer = function () {
|
|
533
1362
|
function AnimationPlayer(drawFunction, fps) {
|
|
534
1363
|
this.prevtime = 0;
|
|
@@ -621,7 +1450,7 @@ function useMarkerMoving(_a) {
|
|
|
621
1450
|
velocity = _h === void 0 ? 10 : _h,
|
|
622
1451
|
onMovingStart = _a.onMovingStart,
|
|
623
1452
|
onMovingEnd = _a.onMovingEnd;
|
|
624
|
-
var controller =
|
|
1453
|
+
var controller = useMintMapController();
|
|
625
1454
|
useEffect(function () {
|
|
626
1455
|
contextRef.current && (contextRef.current.velocityKmh = velocity);
|
|
627
1456
|
}, [velocity]);
|
|
@@ -650,7 +1479,7 @@ function useMarkerMoving(_a) {
|
|
|
650
1479
|
context_1.elapsedTimeMs = frameGapTime;
|
|
651
1480
|
|
|
652
1481
|
while (true) {
|
|
653
|
-
|
|
1482
|
+
GeoCalulator.computeNextPositionAndDistances(context_1);
|
|
654
1483
|
|
|
655
1484
|
if (context_1.nextPos === context_1.pos2) {
|
|
656
1485
|
if (currTargetIndex_1 === startPositionIndex) {
|
|
@@ -746,7 +1575,7 @@ function MapMarkerWrapper(_a) {
|
|
|
746
1575
|
children = _a.children,
|
|
747
1576
|
options = __rest(_a, ["startAnimationClassName", "endAnimationClassName", "topOnClick", "topOnHover", "movingAnimation", "children"]);
|
|
748
1577
|
|
|
749
|
-
var controller =
|
|
1578
|
+
var controller = useMintMapController();
|
|
750
1579
|
var divRef = useRef(document.createElement('div'));
|
|
751
1580
|
var divElement = divRef.current;
|
|
752
1581
|
var divCloneRef = useRef();
|
|
@@ -842,7 +1671,7 @@ function MapMarkerWrapper(_a) {
|
|
|
842
1671
|
controller.updateMarker(markerRef.current, options);
|
|
843
1672
|
offsetCalibration(controller.getMapType(), divElement, options);
|
|
844
1673
|
} else {
|
|
845
|
-
markerRef.current = new
|
|
1674
|
+
markerRef.current = new Marker(options);
|
|
846
1675
|
markerRef.current.element = divElement;
|
|
847
1676
|
controller.createMarker(markerRef.current);
|
|
848
1677
|
offsetCalibration(controller.getMapType(), divElement, options);
|
|
@@ -886,7 +1715,7 @@ function MapPolygonWrapper(_a) {
|
|
|
886
1715
|
var children = _a.children,
|
|
887
1716
|
options = __rest(_a, ["children"]);
|
|
888
1717
|
|
|
889
|
-
var controller =
|
|
1718
|
+
var controller = useMintMapController();
|
|
890
1719
|
useEffect(function () {
|
|
891
1720
|
return function () {
|
|
892
1721
|
if (polygonRef.current) {
|
|
@@ -900,7 +1729,7 @@ function MapPolygonWrapper(_a) {
|
|
|
900
1729
|
if (polygonRef.current) {
|
|
901
1730
|
controller.updatePolygon(polygonRef.current, options);
|
|
902
1731
|
} else {
|
|
903
|
-
var polygon = new
|
|
1732
|
+
var polygon = new Polygon(options);
|
|
904
1733
|
polygonRef.current = polygon;
|
|
905
1734
|
controller.createPolygon(polygon);
|
|
906
1735
|
}
|
|
@@ -909,33 +1738,6 @@ function MapPolygonWrapper(_a) {
|
|
|
909
1738
|
return React.createElement(React.Fragment, null, options && children);
|
|
910
1739
|
}
|
|
911
1740
|
|
|
912
|
-
function MapPolylineWrapper(_a) {
|
|
913
|
-
var children = _a.children,
|
|
914
|
-
options = __rest(_a, ["children"]);
|
|
915
|
-
|
|
916
|
-
var controller = MintMapProvider.useMintMapController();
|
|
917
|
-
useEffect(function () {
|
|
918
|
-
return function () {
|
|
919
|
-
if (polylineRef.current) {
|
|
920
|
-
console.log('polyline cleared', controller.clearDrawable(polylineRef.current));
|
|
921
|
-
}
|
|
922
|
-
};
|
|
923
|
-
}, []);
|
|
924
|
-
var polylineRef = useRef();
|
|
925
|
-
useEffect(function () {
|
|
926
|
-
if (options) {
|
|
927
|
-
if (polylineRef.current) {
|
|
928
|
-
controller.updatePolyline(polylineRef.current, options);
|
|
929
|
-
} else {
|
|
930
|
-
var polyline = new MintMap.Polyline(options);
|
|
931
|
-
polylineRef.current = polyline;
|
|
932
|
-
controller.createPolyline(polyline);
|
|
933
|
-
}
|
|
934
|
-
}
|
|
935
|
-
}, [options]);
|
|
936
|
-
return React.createElement(React.Fragment, null, options && children);
|
|
937
|
-
}
|
|
938
|
-
|
|
939
1741
|
function getMaxLat(items) {
|
|
940
1742
|
var max;
|
|
941
1743
|
|
|
@@ -1004,12 +1806,12 @@ function MapBuildingProjection(props) {
|
|
|
1004
1806
|
position: basePolygonPath
|
|
1005
1807
|
};
|
|
1006
1808
|
var height = numberOfFloor * heightOfFloor;
|
|
1007
|
-
var projectionHeight =
|
|
1809
|
+
var projectionHeight = GeoCalulator.convertMeterToLatitudeValue(height);
|
|
1008
1810
|
var roofPaths = [];
|
|
1009
1811
|
|
|
1010
1812
|
for (var _i = 0, basePolygonPath_1 = basePolygonPath; _i < basePolygonPath_1.length; _i++) {
|
|
1011
1813
|
var pos = basePolygonPath_1[_i];
|
|
1012
|
-
roofPaths.push(new
|
|
1814
|
+
roofPaths.push(new Position(pos.lat + projectionHeight, pos.lng));
|
|
1013
1815
|
}
|
|
1014
1816
|
|
|
1015
1817
|
roofPolygon.current = {
|
|
@@ -1041,7 +1843,7 @@ function MapBuildingProjection(props) {
|
|
|
1041
1843
|
var minLng = getLngMinMax(minLngPos.position, false);
|
|
1042
1844
|
var mid = minLng.lng + (maxLng.lng - minLng.lng) / 2;
|
|
1043
1845
|
titlePosition.current = {
|
|
1044
|
-
position: new
|
|
1846
|
+
position: new Position(maxPos.lat, mid)
|
|
1045
1847
|
};
|
|
1046
1848
|
} else {
|
|
1047
1849
|
titlePosition.current = undefined;
|
|
@@ -1093,4 +1895,100 @@ function MapBuildingProjection(props) {
|
|
|
1093
1895
|
}, "".concat(title, " (").concat(numberOfFloor, "\uCE35)")))));
|
|
1094
1896
|
}
|
|
1095
1897
|
|
|
1096
|
-
|
|
1898
|
+
var css_248z = ".MintMapWrapper-module_mint-map-control-wrapper__DDb4y {\n position: absolute;\n z-index: 101;\n}\n\n.MintMapWrapper-module_mint-map-overlay-wrapper__Jn4wV {\n position: absolute;\n z-index: 1;\n}";
|
|
1899
|
+
var styles = {"mint-map-control-wrapper":"MintMapWrapper-module_mint-map-control-wrapper__DDb4y","mint-map-overlay-wrapper":"MintMapWrapper-module_mint-map-overlay-wrapper__Jn4wV"};
|
|
1900
|
+
styleInject(css_248z);
|
|
1901
|
+
|
|
1902
|
+
var cn = classNames.bind(styles);
|
|
1903
|
+
|
|
1904
|
+
var getSizeString = function (size) {
|
|
1905
|
+
return typeof size === 'string' ? size.replace(/ /g, '') : "".concat(size, "px");
|
|
1906
|
+
};
|
|
1907
|
+
|
|
1908
|
+
var getAlignPosition = function (value, align) {
|
|
1909
|
+
if (typeof value === 'string') {
|
|
1910
|
+
var trimmed = value.replace(/ /g, '');
|
|
1911
|
+
console.log('trimmed:', trimmed);
|
|
1912
|
+
var isPercent = trimmed.endsWith('%');
|
|
1913
|
+
|
|
1914
|
+
if (!isPercent && !trimmed.endsWith('px')) {
|
|
1915
|
+
throw new Error("Size [".concat(value, "] is not valid string value."));
|
|
1916
|
+
}
|
|
1917
|
+
|
|
1918
|
+
var numberPart = isPercent ? trimmed.substring(0, trimmed.length - 2) : trimmed.substring(0, trimmed.length - 3);
|
|
1919
|
+
var unit = isPercent ? '%' : 'px';
|
|
1920
|
+
var numberValue = Number(numberPart);
|
|
1921
|
+
|
|
1922
|
+
if (isNaN(numberValue)) {
|
|
1923
|
+
throw new Error("Size [".concat(value, "] is not valid % or pixel number value."));
|
|
1924
|
+
}
|
|
1925
|
+
|
|
1926
|
+
if (align === 'center') {
|
|
1927
|
+
return "calc(50% - ".concat(numberValue / 2).concat(unit, ")");
|
|
1928
|
+
} else if (align === 'right' || align === 'bottom') {
|
|
1929
|
+
return "calc(100% - ".concat(numberValue).concat(unit, ")");
|
|
1930
|
+
} else {
|
|
1931
|
+
return '0px';
|
|
1932
|
+
}
|
|
1933
|
+
} else if (typeof value === 'number') {
|
|
1934
|
+
if (align === 'center') {
|
|
1935
|
+
return "calc(50% - ".concat(value / 2, "px)");
|
|
1936
|
+
} else if (align === 'right' || align === 'bottom') {
|
|
1937
|
+
return "calc(100% - ".concat(value, "px)");
|
|
1938
|
+
} else {
|
|
1939
|
+
return '0px';
|
|
1940
|
+
}
|
|
1941
|
+
}
|
|
1942
|
+
|
|
1943
|
+
throw new Error("Size [".concat(value, "] is not valid. (Should be % or pixel number)"));
|
|
1944
|
+
};
|
|
1945
|
+
|
|
1946
|
+
function MapControlWrapper(_a) {
|
|
1947
|
+
var _b = _a.width,
|
|
1948
|
+
width = _b === void 0 ? 100 : _b,
|
|
1949
|
+
_c = _a.height,
|
|
1950
|
+
height = _c === void 0 ? 40 : _c,
|
|
1951
|
+
_d = _a.positionHorizontal,
|
|
1952
|
+
positionHorizontal = _d === void 0 ? 'left' : _d,
|
|
1953
|
+
_e = _a.positionVertical,
|
|
1954
|
+
positionVertical = _e === void 0 ? 'top' : _e,
|
|
1955
|
+
children = _a.children;
|
|
1956
|
+
return React.createElement("div", {
|
|
1957
|
+
className: cn('mint-map-control-wrapper'),
|
|
1958
|
+
style: {
|
|
1959
|
+
width: getSizeString(width),
|
|
1960
|
+
height: getSizeString(height),
|
|
1961
|
+
left: getAlignPosition(width, positionHorizontal),
|
|
1962
|
+
top: getAlignPosition(height, positionVertical)
|
|
1963
|
+
}
|
|
1964
|
+
}, children);
|
|
1965
|
+
}
|
|
1966
|
+
|
|
1967
|
+
function MapPolylineWrapper(_a) {
|
|
1968
|
+
var children = _a.children,
|
|
1969
|
+
options = __rest(_a, ["children"]);
|
|
1970
|
+
|
|
1971
|
+
var controller = useMintMapController();
|
|
1972
|
+
useEffect(function () {
|
|
1973
|
+
return function () {
|
|
1974
|
+
if (polylineRef.current) {
|
|
1975
|
+
console.log('polyline cleared', controller.clearDrawable(polylineRef.current));
|
|
1976
|
+
}
|
|
1977
|
+
};
|
|
1978
|
+
}, []);
|
|
1979
|
+
var polylineRef = useRef();
|
|
1980
|
+
useEffect(function () {
|
|
1981
|
+
if (options) {
|
|
1982
|
+
if (polylineRef.current) {
|
|
1983
|
+
controller.updatePolyline(polylineRef.current, options);
|
|
1984
|
+
} else {
|
|
1985
|
+
var polyline = new Polyline(options);
|
|
1986
|
+
polylineRef.current = polyline;
|
|
1987
|
+
controller.createPolyline(polyline);
|
|
1988
|
+
}
|
|
1989
|
+
}
|
|
1990
|
+
}, [options]);
|
|
1991
|
+
return React.createElement(React.Fragment, null, options && children);
|
|
1992
|
+
}
|
|
1993
|
+
|
|
1994
|
+
export { AnimationPlayer, Bounds, Drawable, GeoCalulator, GoogleMintMapController, MapBuildingProjection, MapControlWrapper, MapMarkerWrapper, MapPolygonWrapper, MapPolylineWrapper, Marker, MintMap, MintMapController, MintMapCore, MintMapProvider, NaverMintMapController, Offset, Polygon, PolygonCalculator, Polyline, Position, useMarkerMoving, useMintMapController, waiting };
|