@mint-ui/map 0.5.3-beta → 0.5.4-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/index.es.js CHANGED
@@ -10,6 +10,160 @@ var css_248z$2 = ".MintMap-module_loading-point-container__znk6l {\n display: f
10
10
  var styles$2 = {"loading-point-container":"MintMap-module_loading-point-container__znk6l","ani-blink":"MintMap-module_ani-blink__K89JK","blink":"MintMap-module_blink__mqfeV","ani-fade-in":"MintMap-module_ani-fade-in__lpHuy","fade-in":"MintMap-module_fade-in__jHpv1","ani-fade-out":"MintMap-module_ani-fade-out__5-esw","fade-out":"MintMap-module_fade-out__CIjGe","ani-expansion":"MintMap-module_ani-expansion__S2vOZ","expansion":"MintMap-module_expansion__WMo5-"};
11
11
  styleInject(css_248z$2);
12
12
 
13
+ var PositionMirror$1 =
14
+ /** @class */
15
+ function () {
16
+ function PositionMirror(lat, lng) {
17
+ this.lat = lat;
18
+ this.lng = lng;
19
+ }
20
+
21
+ return PositionMirror;
22
+ }();
23
+
24
+ var GeoCalulator =
25
+ /** @class */
26
+ function () {
27
+ function GeoCalulator() {}
28
+
29
+ GeoCalulator.computeDistanceKiloMeter = function (pos1, pos2) {
30
+ var dLat = this.deg2rad(pos2.lat - pos1.lat);
31
+ var dLon = this.deg2rad(pos2.lng - pos1.lng);
32
+ var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(this.deg2rad(pos1.lat)) * Math.cos(this.deg2rad(pos2.lat)) * Math.sin(dLon / 2) * Math.sin(dLon / 2);
33
+ var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
34
+ var d = this.EARTH_EQUATORIAL_RADIUS_KM * c; // Distance in km
35
+
36
+ return d;
37
+ };
38
+
39
+ GeoCalulator.deg2rad = function (deg) {
40
+ return deg * (Math.PI / 180);
41
+ };
42
+
43
+ GeoCalulator.convertMeterToLatitudeValue = function (meter) {
44
+ return meter * this.LATITUDE_POSITION_VALUE_PER_METER;
45
+ };
46
+
47
+ GeoCalulator.convertLatitudeToMeterValue = function (lat) {
48
+ return lat * this.METER_VALUE_PER_LATITUDE;
49
+ };
50
+
51
+ GeoCalulator.convertLongitudeToMeterValue = function (lat, lng) {
52
+ return lng * this.calculateLongitudeValueWithLatitudeInMeter(lat);
53
+ };
54
+
55
+ GeoCalulator.getCacheUnitOfLongitudeValueWithLatitudeInMeter = function (lat) {
56
+ return lat.toFixed(2);
57
+ };
58
+
59
+ GeoCalulator.getCacheOfLongitudeValueWithLatitudeInMeter = function (latUnit) {
60
+ return this.CACHE_OF_LNG_PER_METER.get(latUnit);
61
+ };
62
+
63
+ GeoCalulator.setCacheOfLongitudeValueWithLatitudeInMeter = function (latUnit, lngValue) {
64
+ if (this.CACHE_OF_LNG_PER_METER.size > 10) {
65
+ this.CACHE_OF_LNG_PER_METER.clear();
66
+ }
67
+
68
+ this.CACHE_OF_LNG_PER_METER.set(latUnit, lngValue);
69
+ };
70
+
71
+ GeoCalulator.calculateLongitudeValueWithLatitudeInMeter = function (lat) {
72
+ // const t = Date.now()
73
+ // Cache check
74
+ var latUnit = this.getCacheUnitOfLongitudeValueWithLatitudeInMeter(lat);
75
+ var fromCache = this.getCacheOfLongitudeValueWithLatitudeInMeter(latUnit);
76
+
77
+ if (fromCache !== undefined) {
78
+ // console.log(`cache hit!! ${Date.now() - t} ms`, fromCache, latUnit, this.CACHE_OF_LNG_PER_METER.size);
79
+ return fromCache;
80
+ } // Convert latitude and longitude to radians
81
+
82
+
83
+ var latRad = lat * Math.PI / 180; // Calculate Earth's radius at the given latitude
84
+
85
+ var radius = this.EARTH_EQUATORIAL_RADIUS * Math.sqrt(1 - Math.pow(this.EARTH_ECCENTRICITY * Math.sin(latRad), 2)); // Calculate the length of one degree of longitude in meters
86
+
87
+ var distance = 2 * Math.PI * radius * Math.cos(latRad) / 360; // Cache set
88
+
89
+ this.setCacheOfLongitudeValueWithLatitudeInMeter(latUnit, distance); // console.log(`calculated ${Date.now() - t} ms`)
90
+
91
+ return distance;
92
+ };
93
+
94
+ GeoCalulator.computeNextPositionAndDistances = function (context) {
95
+ var pos1 = context.pos1,
96
+ pos2 = context.pos2,
97
+ prevPos2 = context.prevPos2,
98
+ velocityKmh = context.velocityKmh,
99
+ prevVelocityKmh = context.prevVelocityKmh,
100
+ elapsedTimeMs = context.elapsedTimeMs; // console.log('velocityKmh / elapsedTimeMs',velocityKmh , elapsedTimeMs);
101
+ //총 가야할 거리 (km)
102
+
103
+ if (pos2 !== prevPos2) {
104
+ //목표가 바뀌면 거리 및 비율 재계산
105
+ context.totalDistance = this.computeDistanceKiloMeter(pos1, pos2);
106
+ context.currDistance = 0;
107
+ context.prevPos2 = pos2;
108
+ }
109
+
110
+ var totalDistance = context.totalDistance; // console.log('totalDistance', totalDistance);
111
+ //ms 속으로 환산
112
+
113
+ if (velocityKmh !== prevVelocityKmh) {
114
+ //속도가 바뀌면 재계산
115
+ context.vPerMs = velocityKmh / this.MS_FROM_HOUR;
116
+ context.prevVelocityKmh = velocityKmh;
117
+ }
118
+
119
+ var vPerMs = context.vPerMs; //console.log('vPerMs', vPerMs);
120
+ //실제 가는 거리 계산
121
+
122
+ var nextDistance = context.distanceRemain ? context.distanceRemain : context.currDistance + elapsedTimeMs * vPerMs; //console.log('nextDistance', nextDistance);
123
+ //목표점까지 이동 후에도 남는 거리
124
+
125
+ context.currDistance = nextDistance;
126
+
127
+ if (totalDistance < context.currDistance) {
128
+ //이동 거리가 현재 목표점을 넘어가는 경우
129
+ context.distanceRemain = context.currDistance - totalDistance;
130
+ context.nextPos = pos2;
131
+ return context;
132
+ } else {
133
+ context.distanceRemain = 0;
134
+ } //각 축으로 나가야할 비율
135
+
136
+
137
+ var ratio = nextDistance / totalDistance; //console.log('ratio', ratio);
138
+ //방향값 체크
139
+
140
+ var latCalib = pos2.lat > pos1.lat ? 1 : -1;
141
+ var lngCalib = pos2.lng > pos1.lng ? 1 : -1; //각 축에 보정된 새로운 지점 리턴
142
+
143
+ var newPos = new PositionMirror$1(pos1.lat + (pos2.lat - pos1.lat) * ratio, pos1.lng + (pos2.lng - pos1.lng) * ratio);
144
+
145
+ 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)) {
146
+ newPos = pos2;
147
+ } // console.log('newPos', newPos);
148
+ //console.log('==============================================================\n');
149
+
150
+
151
+ context.nextPos = newPos;
152
+ return context;
153
+ };
154
+
155
+ GeoCalulator.EARTH_EQUATORIAL_RADIUS = 6378137; //meter (6,378,137 m)
156
+
157
+ GeoCalulator.EARTH_EQUATORIAL_RADIUS_KM = GeoCalulator.EARTH_EQUATORIAL_RADIUS / 1000;
158
+ GeoCalulator.EARTH_ECCENTRICITY = 0.08181919;
159
+ GeoCalulator.METER_VALUE_PER_LATITUDE = 110.32 * 1000; //위도 기준 1도는 110.32km
160
+
161
+ GeoCalulator.LATITUDE_POSITION_VALUE_PER_METER = 1 / GeoCalulator.METER_VALUE_PER_LATITUDE;
162
+ GeoCalulator.CACHE_OF_LNG_PER_METER = new Map();
163
+ GeoCalulator.MS_FROM_HOUR = 60 * 60 * 1000;
164
+ return GeoCalulator;
165
+ }();
166
+
13
167
  var LinePoints =
14
168
  /** @class */
15
169
  function () {
@@ -209,11 +363,7 @@ function () {
209
363
 
210
364
  PolygonCalculator.simplifyPoints = function (polygon, tolerance, lastRepeated) {
211
365
  var target = lastRepeated ? polygon.slice(0, polygon.length - 1) : polygon;
212
- return this.simplify(target.map(function (position) {
213
- return [position.lng, position.lat];
214
- }), tolerance !== undefined ? tolerance : this.TOLERANCE_NAVER_STYLE).map(function (point) {
215
- return new PositionMirror(point[1], point[0]);
216
- });
366
+ return this.simplify(target, tolerance !== undefined ? tolerance : this.TOLERANCE_NAVER_STYLE);
217
367
  };
218
368
 
219
369
  PolygonCalculator.simplify = function (points, tolerance) {
@@ -247,12 +397,12 @@ function () {
247
397
 
248
398
 
249
399
  PolygonCalculator.perpendicularDistance = function (point, lineStart, lineEnd) {
250
- var x = point[0];
251
- var y = point[1];
252
- var x1 = lineStart[0];
253
- var y1 = lineStart[1];
254
- var x2 = lineEnd[0];
255
- var y2 = lineEnd[1];
400
+ var x = point.x;
401
+ var y = point.y;
402
+ var x1 = lineStart.x;
403
+ var y1 = lineStart.y;
404
+ var x2 = lineEnd.x;
405
+ var y2 = lineEnd.y;
256
406
  var numerator = Math.abs((y2 - y1) * x - (x2 - x1) * y + x2 * y1 - y2 * x1);
257
407
  var denominator = Math.sqrt(Math.pow(y2 - y1, 2) + Math.pow(x2 - x1, 2));
258
408
  return numerator / denominator;
@@ -289,154 +439,11 @@ function () {
289
439
  return area;
290
440
  };
291
441
 
292
- PolygonCalculator.TOLERANCE_NAVER_STYLE = 0.0001;
293
- PolygonCalculator.TOLERANCE_GOOGLE_STYLE = 0.00001;
442
+ PolygonCalculator.TOLERANCE_NAVER_STYLE = 1;
443
+ PolygonCalculator.TOLERANCE_GOOGLE_STYLE = 1;
294
444
  return PolygonCalculator;
295
445
  }();
296
446
 
297
- var GeoCalulator =
298
- /** @class */
299
- function () {
300
- function GeoCalulator() {}
301
-
302
- GeoCalulator.computeDistanceKiloMeter = function (pos1, pos2) {
303
- var dLat = this.deg2rad(pos2.lat - pos1.lat);
304
- var dLon = this.deg2rad(pos2.lng - pos1.lng);
305
- var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(this.deg2rad(pos1.lat)) * Math.cos(this.deg2rad(pos2.lat)) * Math.sin(dLon / 2) * Math.sin(dLon / 2);
306
- var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
307
- var d = this.EARTH_EQUATORIAL_RADIUS_KM * c; // Distance in km
308
-
309
- return d;
310
- };
311
-
312
- GeoCalulator.deg2rad = function (deg) {
313
- return deg * (Math.PI / 180);
314
- };
315
-
316
- GeoCalulator.convertMeterToLatitudeValue = function (meter) {
317
- return meter * this.LATITUDE_POSITION_VALUE_PER_METER;
318
- };
319
-
320
- GeoCalulator.convertLatitudeToMeterValue = function (lat) {
321
- return lat * this.METER_VALUE_PER_LATITUDE;
322
- };
323
-
324
- GeoCalulator.convertLongitudeToMeterValue = function (lat, lng) {
325
- return lng * this.calculateLongitudeValueWithLatitudeInMeter(lat);
326
- };
327
-
328
- GeoCalulator.getCacheUnitOfLongitudeValueWithLatitudeInMeter = function (lat) {
329
- return lat.toFixed(2);
330
- };
331
-
332
- GeoCalulator.getCacheOfLongitudeValueWithLatitudeInMeter = function (latUnit) {
333
- return this.CACHE_OF_LNG_PER_METER.get(latUnit);
334
- };
335
-
336
- GeoCalulator.setCacheOfLongitudeValueWithLatitudeInMeter = function (latUnit, lngValue) {
337
- if (this.CACHE_OF_LNG_PER_METER.size > 10) {
338
- this.CACHE_OF_LNG_PER_METER.clear();
339
- }
340
-
341
- this.CACHE_OF_LNG_PER_METER.set(latUnit, lngValue);
342
- };
343
-
344
- GeoCalulator.calculateLongitudeValueWithLatitudeInMeter = function (lat) {
345
- // const t = Date.now()
346
- // Cache check
347
- var latUnit = this.getCacheUnitOfLongitudeValueWithLatitudeInMeter(lat);
348
- var fromCache = this.getCacheOfLongitudeValueWithLatitudeInMeter(latUnit);
349
-
350
- if (fromCache !== undefined) {
351
- // console.log(`cache hit!! ${Date.now() - t} ms`, fromCache, latUnit, this.CACHE_OF_LNG_PER_METER.size);
352
- return fromCache;
353
- } // Convert latitude and longitude to radians
354
-
355
-
356
- var latRad = lat * Math.PI / 180; // Calculate Earth's radius at the given latitude
357
-
358
- var radius = this.EARTH_EQUATORIAL_RADIUS * Math.sqrt(1 - Math.pow(this.EARTH_ECCENTRICITY * Math.sin(latRad), 2)); // Calculate the length of one degree of longitude in meters
359
-
360
- var distance = 2 * Math.PI * radius * Math.cos(latRad) / 360; // Cache set
361
-
362
- this.setCacheOfLongitudeValueWithLatitudeInMeter(latUnit, distance); // console.log(`calculated ${Date.now() - t} ms`)
363
-
364
- return distance;
365
- };
366
-
367
- GeoCalulator.computeNextPositionAndDistances = function (context) {
368
- var pos1 = context.pos1,
369
- pos2 = context.pos2,
370
- prevPos2 = context.prevPos2,
371
- velocityKmh = context.velocityKmh,
372
- prevVelocityKmh = context.prevVelocityKmh,
373
- elapsedTimeMs = context.elapsedTimeMs; // console.log('velocityKmh / elapsedTimeMs',velocityKmh , elapsedTimeMs);
374
- //총 가야할 거리 (km)
375
-
376
- if (pos2 !== prevPos2) {
377
- //목표가 바뀌면 거리 및 비율 재계산
378
- context.totalDistance = this.computeDistanceKiloMeter(pos1, pos2);
379
- context.currDistance = 0;
380
- context.prevPos2 = pos2;
381
- }
382
-
383
- var totalDistance = context.totalDistance; // console.log('totalDistance', totalDistance);
384
- //ms 속으로 환산
385
-
386
- if (velocityKmh !== prevVelocityKmh) {
387
- //속도가 바뀌면 재계산
388
- context.vPerMs = velocityKmh / this.MS_FROM_HOUR;
389
- context.prevVelocityKmh = velocityKmh;
390
- }
391
-
392
- var vPerMs = context.vPerMs; //console.log('vPerMs', vPerMs);
393
- //실제 가는 거리 계산
394
-
395
- var nextDistance = context.distanceRemain ? context.distanceRemain : context.currDistance + elapsedTimeMs * vPerMs; //console.log('nextDistance', nextDistance);
396
- //목표점까지 이동 후에도 남는 거리
397
-
398
- context.currDistance = nextDistance;
399
-
400
- if (totalDistance < context.currDistance) {
401
- //이동 거리가 현재 목표점을 넘어가는 경우
402
- context.distanceRemain = context.currDistance - totalDistance;
403
- context.nextPos = pos2;
404
- return context;
405
- } else {
406
- context.distanceRemain = 0;
407
- } //각 축으로 나가야할 비율
408
-
409
-
410
- var ratio = nextDistance / totalDistance; //console.log('ratio', ratio);
411
- //방향값 체크
412
-
413
- var latCalib = pos2.lat > pos1.lat ? 1 : -1;
414
- var lngCalib = pos2.lng > pos1.lng ? 1 : -1; //각 축에 보정된 새로운 지점 리턴
415
-
416
- var newPos = new PositionMirror(pos1.lat + (pos2.lat - pos1.lat) * ratio, pos1.lng + (pos2.lng - pos1.lng) * ratio);
417
-
418
- 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)) {
419
- newPos = pos2;
420
- } // console.log('newPos', newPos);
421
- //console.log('==============================================================\n');
422
-
423
-
424
- context.nextPos = newPos;
425
- return context;
426
- };
427
-
428
- GeoCalulator.EARTH_EQUATORIAL_RADIUS = 6378137; //meter (6,378,137 m)
429
-
430
- GeoCalulator.EARTH_EQUATORIAL_RADIUS_KM = GeoCalulator.EARTH_EQUATORIAL_RADIUS / 1000;
431
- GeoCalulator.EARTH_ECCENTRICITY = 0.08181919;
432
- GeoCalulator.METER_VALUE_PER_LATITUDE = 110.32 * 1000; //위도 기준 1도는 110.32km
433
-
434
- GeoCalulator.LATITUDE_POSITION_VALUE_PER_METER = 1 / GeoCalulator.METER_VALUE_PER_LATITUDE;
435
- GeoCalulator.CACHE_OF_LNG_PER_METER = new Map();
436
- GeoCalulator.MS_FROM_HOUR = 60 * 60 * 1000;
437
- return GeoCalulator;
438
- }();
439
-
440
447
  /**
441
448
  * 좌표값
442
449
  * @description 위도/경도, DOM 상의 X/Y 좌표
@@ -1610,7 +1617,7 @@ function (_super) {
1610
1617
  case 2:
1611
1618
  options = {
1612
1619
  center: (_a = this.mapProps.base) === null || _a === void 0 ? void 0 : _a.center,
1613
- zoom: (_b = this.mapProps.base) === null || _b === void 0 ? void 0 : _b.zoomLevel,
1620
+ zoom: ((_b = this.mapProps.base) === null || _b === void 0 ? void 0 : _b.zoomLevel) || this.getBaseToMapZoom(15),
1614
1621
  draggable: this.mapProps.draggable === false ? false : true,
1615
1622
  scrollWheel: this.mapProps.draggable === false ? false : true,
1616
1623
  keyboardShortcuts: this.mapProps.keyboardShortcuts === false ? false : true,
@@ -1761,6 +1768,15 @@ function (_super) {
1761
1768
  (_a = this.map) === null || _a === void 0 ? void 0 : _a.setCenter(position);
1762
1769
  };
1763
1770
 
1771
+ NaverMintMapController.prototype.positionToOffset = function (position) {
1772
+ if (!this.map) {
1773
+ return new Offset(0, 0);
1774
+ }
1775
+
1776
+ var offset = this.map.getProjection().fromCoordToOffset(new naver.maps.LatLng(position.lat, position.lng));
1777
+ return new Offset(offset.x, offset.y);
1778
+ };
1779
+
1764
1780
  NaverMintMapController.prototype.addEventListener = function (eventName, callback) {
1765
1781
  var _this = this;
1766
1782
 
@@ -2309,7 +2325,7 @@ function (_super) {
2309
2325
  center: (_a = this.mapProps.base) === null || _a === void 0 ? void 0 : _a.center,
2310
2326
  maxZoom: (_b = this.mapProps.base) === null || _b === void 0 ? void 0 : _b.maxZoomLevel,
2311
2327
  minZoom: (_c = this.mapProps.base) === null || _c === void 0 ? void 0 : _c.minZoomLevel,
2312
- zoom: (_d = this.mapProps.base) === null || _d === void 0 ? void 0 : _d.zoomLevel,
2328
+ zoom: ((_d = this.mapProps.base) === null || _d === void 0 ? void 0 : _d.zoomLevel) || this.getBaseToMapZoom(15),
2313
2329
  disableDefaultUI: true,
2314
2330
  gestureHandling: this.mapProps.draggable === false ? 'none' : 'greedy',
2315
2331
  keyboardShortcuts: this.mapProps.keyboardShortcuts === false ? false : true,
@@ -2970,7 +2986,7 @@ function (_super) {
2970
2986
  case 2:
2971
2987
  options = {
2972
2988
  center: this.positionToLatLng((_a = this.mapProps.base) === null || _a === void 0 ? void 0 : _a.center),
2973
- level: this.getBaseToMapZoom(((_b = this.mapProps.base) === null || _b === void 0 ? void 0 : _b.zoomLevel) || 10),
2989
+ level: this.getBaseToMapZoom(((_b = this.mapProps.base) === null || _b === void 0 ? void 0 : _b.zoomLevel) || 15),
2974
2990
  draggable: this.mapProps.draggable === false ? false : true,
2975
2991
  scrollWheel: this.mapProps.draggable === false ? false : true,
2976
2992
  keyboardShortcuts: this.mapProps.keyboardShortcuts === false ? false : true
@@ -3448,10 +3464,10 @@ function SVGPolygon(_a) {
3448
3464
  var width = maxX - minX;
3449
3465
  var height = maxY - minY;
3450
3466
  return {
3451
- containerLeft: Math.floor(minX),
3452
- containerTop: Math.floor(minY),
3453
- containerWidth: Math.floor(width),
3454
- containerHeight: Math.floor(height)
3467
+ containerLeft: minX,
3468
+ containerTop: minY,
3469
+ containerWidth: width,
3470
+ containerHeight: height
3455
3471
  };
3456
3472
  }, []);
3457
3473
  var getD = useCallback(function (_a) {
@@ -3525,7 +3541,7 @@ function SVGPolygon(_a) {
3525
3541
  height: height,
3526
3542
  fill: mode === 'POLYLINE' ? 'none' : background,
3527
3543
  stroke: mode === 'POLYLINE' ? 'black' : 'green',
3528
- strokeLinejoin: "round",
3544
+ strokeLinejoin: "miter",
3529
3545
  strokeLinecap: "butt",
3530
3546
  d: d
3531
3547
  }, shapeProperties))), React.createElement("div", {
@@ -4372,11 +4388,9 @@ function PolygonMarker(_a) {
4372
4388
 
4373
4389
  var _l = useState([]),
4374
4390
  innerOffsets = _l[0],
4375
- setInnerOffsets = _l[1]; //offset cache
4391
+ setInnerOffsets = _l[1]; //polygon props ref
4376
4392
 
4377
4393
 
4378
- var offsetCache = useRef(new Map()); //polygon props ref
4379
-
4380
4394
  var polygonPropsRef = useRef({
4381
4395
  position: position,
4382
4396
  innerPositions: innerPositions,
@@ -4387,7 +4401,6 @@ function PolygonMarker(_a) {
4387
4401
 
4388
4402
  useEffect(function () {
4389
4403
  // console.log('polygon changed');
4390
- offsetCache.current.clear();
4391
4404
  polygonPropsRef.current = {
4392
4405
  position: position,
4393
4406
  innerPositions: innerPositions,
@@ -4409,53 +4422,42 @@ function PolygonMarker(_a) {
4409
4422
  innerPositions = _a.innerPositions,
4410
4423
  simplifyPath = _a.simplifyPath,
4411
4424
  simplifyTolerance = _a.simplifyTolerance,
4412
- lastReapeated = _a.lastReapeated;
4413
- var prevCache = offsetCache.current.get(zoomLevel.current);
4414
-
4415
- if (prevCache) {
4416
- var offsets_1 = [];
4417
- offsets_1.push.apply(offsets_1, prevCache.offsets);
4418
- setOffsets(offsets_1);
4419
- var innerOffsets_1 = [];
4420
- innerOffsets_1.push.apply(innerOffsets_1, prevCache.innerOffsets);
4421
- setInnerOffsets(innerOffsets_1);
4422
- setPolygonStart(prevCache.start);
4423
- } else {
4424
- // path
4425
- var simplified = simplifyPath ? PolygonCalculator.simplifyPoints(position, simplifyTolerance, lastReapeated) : position;
4426
- var offsets_2 = simplified.map(function (pos) {
4427
- var off = controller.positionToOffset(pos);
4428
- return new Offset(Math.floor(off.x), Math.floor(off.y));
4429
- });
4430
- setOffsets(offsets_2); //inner path
4425
+ lastReapeated = _a.lastReapeated; // path
4431
4426
 
4432
- var innerPath = [];
4427
+ var maxLat = undefined;
4428
+ var minLng = undefined;
4429
+ var offsets = position.map(function (pos) {
4430
+ if (maxLat === undefined || maxLat < pos.lat) {
4431
+ maxLat = pos.lat;
4432
+ }
4433
4433
 
4434
- if (innerPositions) {
4435
- for (var _i = 0, innerPositions_1 = innerPositions; _i < innerPositions_1.length; _i++) {
4436
- var innerPosition = innerPositions_1[_i];
4437
- var simplified_1 = simplifyPath ? PolygonCalculator.simplifyPoints(innerPosition, simplifyTolerance, lastReapeated) : innerPosition;
4438
- var offsets_3 = simplified_1.map(function (pos) {
4439
- var off = controller.positionToOffset(pos);
4440
- return new Offset(Math.floor(off.x), Math.floor(off.y));
4441
- });
4442
- innerPath.push(offsets_3);
4443
- }
4434
+ if (minLng === undefined || minLng > pos.lng) {
4435
+ minLng = pos.lng;
4436
+ }
4444
4437
 
4445
- setInnerOffsets(innerPath);
4446
- } //start point
4438
+ return controller.positionToOffset(pos);
4439
+ });
4440
+ var simplified = simplifyPath ? PolygonCalculator.simplifyPoints(offsets, simplifyTolerance, lastReapeated) : offsets;
4441
+ setOffsets(simplified); //inner path
4447
4442
 
4443
+ var innerPath = [];
4448
4444
 
4449
- var regionInfo = PolygonCalculator.getRegionInfo(simplified);
4450
- var startPosition = regionInfo.maxLat && regionInfo.minLng ? new Position(regionInfo.maxLat, regionInfo.minLng) : undefined;
4451
- setPolygonStart(startPosition); //cache set
4445
+ if (innerPositions) {
4446
+ for (var _i = 0, innerPositions_1 = innerPositions; _i < innerPositions_1.length; _i++) {
4447
+ var innerPosition = innerPositions_1[_i];
4448
+ var offsets_1 = innerPosition.map(function (pos) {
4449
+ return controller.positionToOffset(pos);
4450
+ });
4451
+ var simplified_1 = simplifyPath ? PolygonCalculator.simplifyPoints(offsets_1, simplifyTolerance, lastReapeated) : offsets_1;
4452
+ innerPath.push(simplified_1);
4453
+ }
4452
4454
 
4453
- offsetCache.current.set(zoomLevel.current, {
4454
- start: startPosition,
4455
- offsets: offsets_2,
4456
- innerOffsets: innerPath
4457
- });
4458
- }
4455
+ setInnerOffsets(innerPath);
4456
+ } //start point
4457
+
4458
+
4459
+ var startPosition = maxLat && minLng ? new Position(maxLat, minLng) : undefined;
4460
+ setPolygonStart(startPosition);
4459
4461
  }, []);
4460
4462
  return React.createElement(React.Fragment, null, polygonStart && React.createElement(MapMarkerWrapper, {
4461
4463
  position: polygonStart,
@@ -5155,7 +5157,7 @@ function MapCanvasWrapper(_a) {
5155
5157
  var pos = item.position; // console.log('canvas mouseevent check', pos.offset);
5156
5158
 
5157
5159
  if (pos && !pos.offset) {
5158
- pos.offset = controller.positionToOffset(pos);
5160
+ pos.offset = positionToOffset(pos);
5159
5161
  }
5160
5162
 
5161
5163
  if (!pos || !pos.offset || !includes(clickedOffset, pos.offset, item.boxWidth, item.boxHeight)) {
@@ -5188,7 +5190,7 @@ function MapCanvasWrapper(_a) {
5188
5190
 
5189
5191
  if (map) {
5190
5192
  // const center = controller.getCenter()
5191
- // center.offset = controller.positionToOffset(center)
5193
+ // center.offset = positionToOffset(center)
5192
5194
  // if(center.offset){
5193
5195
  // prevX.current = center.offset.x
5194
5196
  // prevY.current = center.offset.y
@@ -5208,7 +5210,7 @@ function MapCanvasWrapper(_a) {
5208
5210
 
5209
5211
  if (containerRef.current) {
5210
5212
  // const pos = controller.getCenter()
5211
- // pos.offset = controller.positionToOffset(pos)
5213
+ // pos.offset = positionToOffset(pos)
5212
5214
  // const deltaX = prevX.current - pos.offset.x
5213
5215
  // const deltaY = prevY.current - pos.offset.y
5214
5216
  // offsetProvider.current.x += deltaX
@@ -5234,7 +5236,7 @@ function MapCanvasWrapper(_a) {
5234
5236
 
5235
5237
  map.addListener('mousemove', function (e) {
5236
5238
  var clickPosition = parseClickParamToPosition(controller.getMapType(), e);
5237
- var clickedOffset = controller.positionToOffset(clickPosition); // console.log('canvas mousemove', clickedOffset);
5239
+ var clickedOffset = positionToOffset(clickPosition); // console.log('canvas mousemove', clickedOffset);
5238
5240
 
5239
5241
  var hitSet = processMouseEvent(clickedOffset, 'onMouseOver'); //mouse out 처리
5240
5242
 
@@ -5248,7 +5250,7 @@ function MapCanvasWrapper(_a) {
5248
5250
 
5249
5251
  map.addListener('click', function (e) {
5250
5252
  var clickPosition = parseClickParamToPosition(controller.getMapType(), e);
5251
- var clickedOffset = controller.positionToOffset(clickPosition);
5253
+ var clickedOffset = positionToOffset(clickPosition);
5252
5254
  processMouseEvent(clickedOffset, 'onClick');
5253
5255
  });
5254
5256
  }
@@ -5319,7 +5321,7 @@ function MapCanvasWrapper(_a) {
5319
5321
  if (item.visible === undefined || item.visible) {
5320
5322
  var pos = item.position; //위치 변환
5321
5323
 
5322
- pos.offset = controller.positionToOffset(pos);
5324
+ pos.offset = positionToOffset(pos);
5323
5325
 
5324
5326
  if (item.anchor) {
5325
5327
  pos.offset.x += item.anchor.x;
@@ -5348,6 +5350,22 @@ function MapCanvasWrapper(_a) {
5348
5350
  }, []); //render!!!
5349
5351
 
5350
5352
  renderMain();
5353
+
5354
+ var positionToOffset = useCallback(function (position) {
5355
+ var div = controller.mapDivElement;
5356
+ var w = div === null || div === void 0 ? void 0 : div.offsetWidth;
5357
+ var h = div === null || div === void 0 ? void 0 : div.offsetHeight;
5358
+ var bounds = controller.getCurrBounds();
5359
+ var maxLng = bounds.ne.lng;
5360
+ var minLng = bounds.sw.lng;
5361
+ var lng = Math.abs(maxLng - minLng);
5362
+ var x = w * (position.lng - minLng) / lng;
5363
+ var maxLat = bounds.ne.lat;
5364
+ var minLat = bounds.sw.lat;
5365
+ var lat = Math.abs(maxLat - minLat);
5366
+ var y = h * (maxLat - position.lat) / lat;
5367
+ return new Offset(x, y);
5368
+ }, []);
5351
5369
  return React.createElement("div", {
5352
5370
  ref: containerRef,
5353
5371
  style: {
package/dist/index.js CHANGED
@@ -16,9 +16,10 @@ var MapLoadingComponents = require('./components/mint-map/core/advanced/MapLoadi
16
16
  var MarkerMovingHook = require('./components/mint-map/core/hooks/MarkerMovingHook.js');
17
17
  var MintMapProvider = require('./components/mint-map/core/provider/MintMapProvider.js');
18
18
  var animation = require('./components/mint-map/core/util/animation.js');
19
- var calculate = require('./components/mint-map/core/util/calculate.js');
19
+ var geo = require('./components/mint-map/core/util/geo.js');
20
20
  var waiting = require('./components/mint-map/core/util/waiting.js');
21
21
  var cluster = require('./components/mint-map/core/util/cluster.js');
22
+ var polygon = require('./components/mint-map/core/util/polygon.js');
22
23
  var MapControlWrapper = require('./components/mint-map/core/wrapper/MapControlWrapper.js');
23
24
  var MapMarkerWrapper = require('./components/mint-map/core/wrapper/MapMarkerWrapper.js');
24
25
  var MapPolygonWrapper = require('./components/mint-map/core/wrapper/MapPolygonWrapper.js');
@@ -49,10 +50,10 @@ exports.useMarkerMoving = MarkerMovingHook.useMarkerMoving;
49
50
  exports.MintMapProvider = MintMapProvider.MintMapProvider;
50
51
  exports.useMintMapController = MintMapProvider.useMintMapController;
51
52
  exports.AnimationPlayer = animation.AnimationPlayer;
52
- exports.GeoCalulator = calculate.GeoCalulator;
53
- exports.PolygonCalculator = calculate.PolygonCalculator;
53
+ exports.GeoCalulator = geo.GeoCalulator;
54
54
  exports.waiting = waiting.waiting;
55
55
  exports.getClusterInfo = cluster.getClusterInfo;
56
+ exports.PolygonCalculator = polygon.PolygonCalculator;
56
57
  exports.MapControlWrapper = MapControlWrapper.MapControlWrapper;
57
58
  exports.MapMarkerWrapper = MapMarkerWrapper.MapMarkerWrapper;
58
59
  exports.MapPolygonWrapper = MapPolygonWrapper.MapPolygonWrapper;