@mint-ui/map 0.5.3-beta → 0.5.5-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/core/advanced/MapBuildingProjection.js +2 -2
- package/dist/components/mint-map/core/advanced/shapes/CircleMarker.js +3 -2
- package/dist/components/mint-map/core/advanced/shapes/PolygonMarker.js +36 -46
- package/dist/components/mint-map/core/advanced/shapes/base/SVGPolygon.js +5 -5
- package/dist/components/mint-map/core/hooks/MarkerMovingHook.js +2 -2
- package/dist/components/mint-map/core/util/{calculate.d.ts → geo.d.ts} +0 -28
- package/dist/components/mint-map/core/util/geo.js +159 -0
- package/dist/components/mint-map/core/util/index.d.ts +2 -1
- package/dist/components/mint-map/core/util/polygon.d.ts +40 -0
- package/dist/components/mint-map/core/util/{calculate.js → polygon.js} +13 -159
- package/dist/components/mint-map/core/wrapper/MapCanvasWrapper.js +2 -2
- package/dist/components/mint-map/google/GoogleMintMapController.js +1 -1
- package/dist/components/mint-map/kakao/KakaoMintMapController.js +1 -1
- package/dist/components/mint-map/naver/NaverMintMapController.d.ts +2 -1
- package/dist/components/mint-map/naver/NaverMintMapController.js +10 -1
- package/dist/components/mint-map/types/MapDrawables.js +2 -2
- package/dist/components/mint-map/types/MapTypes.js +2 -2
- package/dist/index.es.js +215 -211
- package/dist/index.js +4 -3
- package/dist/index.umd.js +215 -211
- package/package.json +1 -1
|
@@ -460,7 +460,7 @@ function (_super) {
|
|
|
460
460
|
center: (_a = this.mapProps.base) === null || _a === void 0 ? void 0 : _a.center,
|
|
461
461
|
maxZoom: (_b = this.mapProps.base) === null || _b === void 0 ? void 0 : _b.maxZoomLevel,
|
|
462
462
|
minZoom: (_c = this.mapProps.base) === null || _c === void 0 ? void 0 : _c.minZoomLevel,
|
|
463
|
-
zoom: (_d = this.mapProps.base) === null || _d === void 0 ? void 0 : _d.zoomLevel,
|
|
463
|
+
zoom: ((_d = this.mapProps.base) === null || _d === void 0 ? void 0 : _d.zoomLevel) || this.getBaseToMapZoom(15),
|
|
464
464
|
disableDefaultUI: true,
|
|
465
465
|
gestureHandling: this.mapProps.draggable === false ? 'none' : 'greedy',
|
|
466
466
|
keyboardShortcuts: this.mapProps.keyboardShortcuts === false ? false : true,
|
|
@@ -452,7 +452,7 @@ function (_super) {
|
|
|
452
452
|
case 2:
|
|
453
453
|
options = {
|
|
454
454
|
center: this.positionToLatLng((_a = this.mapProps.base) === null || _a === void 0 ? void 0 : _a.center),
|
|
455
|
-
level: this.getBaseToMapZoom(((_b = this.mapProps.base) === null || _b === void 0 ? void 0 : _b.zoomLevel) ||
|
|
455
|
+
level: this.getBaseToMapZoom(((_b = this.mapProps.base) === null || _b === void 0 ? void 0 : _b.zoomLevel) || 15),
|
|
456
456
|
draggable: this.mapProps.draggable === false ? false : true,
|
|
457
457
|
scrollWheel: this.mapProps.draggable === false ? false : true,
|
|
458
458
|
keyboardShortcuts: this.mapProps.keyboardShortcuts === false ? false : true
|
|
@@ -3,7 +3,7 @@ import { MintMapController } from "../core/MintMapController";
|
|
|
3
3
|
import { ObjectPool } from '@mint-ui/tools';
|
|
4
4
|
import { MapType, MapVendorType } from "../types/CommonTypes";
|
|
5
5
|
import { Drawable, Marker, MarkerOptions, Polygon, PolygonOptions, Polyline, PolylineOptions } from "../types/MapDrawables";
|
|
6
|
-
import { Bounds, Position } from "../types/MapTypes";
|
|
6
|
+
import { Bounds, Offset, Position } from "../types/MapTypes";
|
|
7
7
|
import { MintMapProps } from "../types/MintMapProps";
|
|
8
8
|
import { EventCallback, EventParamType, MapEvent, MapEventName, MapUIEvent } from "../types/MapEventTypes";
|
|
9
9
|
export declare class NaverMintMapController extends MintMapController {
|
|
@@ -45,6 +45,7 @@ export declare class NaverMintMapController extends MintMapController {
|
|
|
45
45
|
setZoomLevel(zoom: number): void;
|
|
46
46
|
getCenter(): Position;
|
|
47
47
|
setCenter(position: Position): void;
|
|
48
|
+
naverPositionToOffset(position: Position): Offset;
|
|
48
49
|
private eventMap;
|
|
49
50
|
addEventListener(eventName: MapEventName, callback: EventCallback<EventParamType>): void;
|
|
50
51
|
removeEventListener(eventName: MapEventName, callback: EventCallback<EventParamType>): void;
|
|
@@ -481,7 +481,7 @@ function (_super) {
|
|
|
481
481
|
case 2:
|
|
482
482
|
options = {
|
|
483
483
|
center: (_a = this.mapProps.base) === null || _a === void 0 ? void 0 : _a.center,
|
|
484
|
-
zoom: (_b = this.mapProps.base) === null || _b === void 0 ? void 0 : _b.zoomLevel,
|
|
484
|
+
zoom: ((_b = this.mapProps.base) === null || _b === void 0 ? void 0 : _b.zoomLevel) || this.getBaseToMapZoom(15),
|
|
485
485
|
draggable: this.mapProps.draggable === false ? false : true,
|
|
486
486
|
scrollWheel: this.mapProps.draggable === false ? false : true,
|
|
487
487
|
keyboardShortcuts: this.mapProps.keyboardShortcuts === false ? false : true,
|
|
@@ -632,6 +632,15 @@ function (_super) {
|
|
|
632
632
|
(_a = this.map) === null || _a === void 0 ? void 0 : _a.setCenter(position);
|
|
633
633
|
};
|
|
634
634
|
|
|
635
|
+
NaverMintMapController.prototype.naverPositionToOffset = function (position) {
|
|
636
|
+
if (!this.map) {
|
|
637
|
+
return new MapTypes.Offset(0, 0);
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
var offset = this.map.getProjection().fromCoordToOffset(new naver.maps.LatLng(position.lat, position.lng));
|
|
641
|
+
return new MapTypes.Offset(offset.x, offset.y);
|
|
642
|
+
};
|
|
643
|
+
|
|
635
644
|
NaverMintMapController.prototype.addEventListener = function (eventName, callback) {
|
|
636
645
|
var _this = this;
|
|
637
646
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var tslib = require('tslib');
|
|
6
|
-
var
|
|
6
|
+
var polygon = require('../core/util/polygon.js');
|
|
7
7
|
var MapTypes = require('./MapTypes.js');
|
|
8
8
|
|
|
9
9
|
var Drawable =
|
|
@@ -77,7 +77,7 @@ function (_super) {
|
|
|
77
77
|
var paths = this.options.position.map(function (elem) {
|
|
78
78
|
return elem instanceof MapTypes.Position ? elem : new MapTypes.Position(elem[0], elem[1]);
|
|
79
79
|
});
|
|
80
|
-
return
|
|
80
|
+
return polygon.PolygonCalculator.getCenter(paths);
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
throw new Error('center 를 찾을 수 없습니다.');
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var polygon = require('../core/util/polygon.js');
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* 좌표값
|
|
@@ -123,7 +123,7 @@ function () {
|
|
|
123
123
|
};
|
|
124
124
|
|
|
125
125
|
Bounds.prototype.intersects = function (positions) {
|
|
126
|
-
return
|
|
126
|
+
return polygon.PolygonCalculator.intersects([this.nw, this.se], positions);
|
|
127
127
|
};
|
|
128
128
|
|
|
129
129
|
return Bounds;
|
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.
|
|
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
|
|
251
|
-
var y = point
|
|
252
|
-
var x1 = lineStart
|
|
253
|
-
var y1 = lineStart
|
|
254
|
-
var x2 = lineEnd
|
|
255
|
-
var y2 = lineEnd
|
|
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 =
|
|
293
|
-
PolygonCalculator.TOLERANCE_GOOGLE_STYLE =
|
|
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.naverPositionToOffset = 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) ||
|
|
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:
|
|
3452
|
-
containerTop:
|
|
3453
|
-
containerWidth:
|
|
3454
|
-
containerHeight:
|
|
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: "
|
|
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]; //
|
|
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,44 @@ 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
|
-
|
|
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 (
|
|
4435
|
-
|
|
4436
|
-
|
|
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
|
+
} //offset 계산 정확도를 위해 네이버 맵은 전용 projection 베이스의 function 을 사용한다.
|
|
4444
4437
|
|
|
4445
|
-
setInnerOffsets(innerPath);
|
|
4446
|
-
} //start point
|
|
4447
4438
|
|
|
4439
|
+
return controller instanceof NaverMintMapController ? controller.naverPositionToOffset(pos) : controller.positionToOffset(pos);
|
|
4440
|
+
});
|
|
4441
|
+
var simplified = simplifyPath ? PolygonCalculator.simplifyPoints(offsets, simplifyTolerance, lastReapeated) : offsets;
|
|
4442
|
+
setOffsets(simplified); //inner path
|
|
4448
4443
|
|
|
4449
|
-
|
|
4450
|
-
var startPosition = regionInfo.maxLat && regionInfo.minLng ? new Position(regionInfo.maxLat, regionInfo.minLng) : undefined;
|
|
4451
|
-
setPolygonStart(startPosition); //cache set
|
|
4444
|
+
var innerPath = [];
|
|
4452
4445
|
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4446
|
+
if (innerPositions) {
|
|
4447
|
+
for (var _i = 0, innerPositions_1 = innerPositions; _i < innerPositions_1.length; _i++) {
|
|
4448
|
+
var innerPosition = innerPositions_1[_i];
|
|
4449
|
+
var offsets_1 = innerPosition.map(function (pos) {
|
|
4450
|
+
//offset 계산 정확도를 위해 네이버 맵은 전용 projection 베이스의 function 을 사용한다.
|
|
4451
|
+
return controller instanceof NaverMintMapController ? controller.naverPositionToOffset(pos) : controller.positionToOffset(pos);
|
|
4452
|
+
});
|
|
4453
|
+
var simplified_1 = simplifyPath ? PolygonCalculator.simplifyPoints(offsets_1, simplifyTolerance, lastReapeated) : offsets_1;
|
|
4454
|
+
innerPath.push(simplified_1);
|
|
4455
|
+
}
|
|
4456
|
+
|
|
4457
|
+
setInnerOffsets(innerPath);
|
|
4458
|
+
} //start point
|
|
4459
|
+
|
|
4460
|
+
|
|
4461
|
+
var startPosition = maxLat && minLng ? new Position(maxLat, minLng) : undefined;
|
|
4462
|
+
setPolygonStart(startPosition);
|
|
4459
4463
|
}, []);
|
|
4460
4464
|
return React.createElement(React.Fragment, null, polygonStart && React.createElement(MapMarkerWrapper, {
|
|
4461
4465
|
position: polygonStart,
|
|
@@ -5188,7 +5192,7 @@ function MapCanvasWrapper(_a) {
|
|
|
5188
5192
|
|
|
5189
5193
|
if (map) {
|
|
5190
5194
|
// const center = controller.getCenter()
|
|
5191
|
-
// center.offset =
|
|
5195
|
+
// center.offset = positionToOffset(center)
|
|
5192
5196
|
// if(center.offset){
|
|
5193
5197
|
// prevX.current = center.offset.x
|
|
5194
5198
|
// prevY.current = center.offset.y
|
|
@@ -5208,7 +5212,7 @@ function MapCanvasWrapper(_a) {
|
|
|
5208
5212
|
|
|
5209
5213
|
if (containerRef.current) {
|
|
5210
5214
|
// const pos = controller.getCenter()
|
|
5211
|
-
// pos.offset =
|
|
5215
|
+
// pos.offset = positionToOffset(pos)
|
|
5212
5216
|
// const deltaX = prevX.current - pos.offset.x
|
|
5213
5217
|
// const deltaY = prevY.current - pos.offset.y
|
|
5214
5218
|
// offsetProvider.current.x += deltaX
|
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
|
|
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 =
|
|
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;
|