@mint-ui/map 0.4.5-beta → 0.5.0-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/.eslintrc.js +109 -109
- package/LICENSE +21 -21
- package/README.md +73 -73
- package/dist/components/mint-map/MintMap.d.ts +10 -117
- package/dist/components/mint-map/MintMap.js +24 -421
- package/dist/components/mint-map/core/MintMapCanvasRenderer.d.ts +4 -4
- package/dist/components/mint-map/core/MintMapCanvasRenderer.js +3 -1
- package/dist/components/mint-map/core/MintMapController.d.ts +64 -44
- package/dist/components/mint-map/core/MintMapController.js +49 -15
- package/dist/components/mint-map/core/MintMapCore.d.ts +3 -3
- package/dist/components/mint-map/core/MintMapCore.js +22 -10
- package/dist/components/mint-map/core/advanced/MapBuildingProjection.d.ts +15 -15
- package/dist/components/mint-map/core/advanced/MapBuildingProjection.js +11 -7
- package/dist/components/mint-map/core/advanced/MapLoadingComponents.d.ts +17 -0
- package/dist/components/mint-map/core/advanced/MapLoadingComponents.js +257 -0
- package/dist/components/mint-map/core/advanced/index.d.ts +3 -1
- package/dist/components/mint-map/core/advanced/shapes/CircleMarker.d.ts +20 -0
- package/dist/components/mint-map/core/advanced/shapes/CircleMarker.js +137 -0
- package/dist/components/mint-map/core/advanced/shapes/PolygonMarker.d.ts +23 -0
- package/dist/components/mint-map/core/advanced/shapes/PolygonMarker.js +188 -0
- package/dist/components/mint-map/core/advanced/shapes/base/SVGCircle.d.ts +8 -0
- package/dist/components/mint-map/core/advanced/shapes/base/SVGCircle.js +54 -0
- package/dist/components/mint-map/core/advanced/shapes/base/SVGPolygon.d.ts +12 -0
- package/dist/components/mint-map/core/advanced/shapes/base/SVGPolygon.js +152 -0
- package/dist/components/mint-map/core/advanced/shapes/base/SVGRect.d.ts +10 -0
- package/dist/components/mint-map/core/advanced/shapes/base/SVGRect.js +60 -0
- package/dist/components/mint-map/core/advanced/shapes/base/index.d.ts +3 -0
- package/dist/components/mint-map/core/advanced/shapes/index.d.ts +3 -0
- package/dist/components/mint-map/core/hooks/MarkerMovingHook.d.ts +6 -6
- package/dist/components/mint-map/core/hooks/MarkerMovingHook.js +21 -9
- package/dist/components/mint-map/core/hooks/index.d.ts +1 -1
- package/dist/components/mint-map/core/index.d.ts +8 -8
- package/dist/components/mint-map/core/provider/MintMapProvider.d.ts +8 -8
- package/dist/components/mint-map/core/provider/index.d.ts +1 -1
- package/dist/components/mint-map/core/util/animation.d.ts +16 -16
- package/dist/components/mint-map/core/util/animation.js +14 -5
- package/dist/components/mint-map/core/util/calculate.d.ts +66 -34
- package/dist/components/mint-map/core/util/calculate.js +233 -27
- package/dist/components/mint-map/core/util/cluster.d.ts +18 -18
- package/dist/components/mint-map/core/util/cluster.js +14 -9
- package/dist/components/mint-map/core/util/index.d.ts +4 -4
- package/dist/components/mint-map/core/util/waiting.d.ts +1 -1
- package/dist/components/mint-map/core/util/waiting.js +6 -2
- package/dist/components/mint-map/core/wrapper/MapCanvasMarkerWrapper.d.ts +27 -19
- package/dist/components/mint-map/core/wrapper/MapCanvasMarkerWrapper.js +9 -0
- package/dist/components/mint-map/core/wrapper/MapCanvasWrapper.d.ts +11 -4
- package/dist/components/mint-map/core/wrapper/MapCanvasWrapper.js +107 -35
- package/dist/components/mint-map/core/wrapper/MapControlWrapper.d.ts +18 -11
- package/dist/components/mint-map/core/wrapper/MapControlWrapper.js +8 -0
- package/dist/components/mint-map/core/wrapper/MapMarkerWrapper.d.ts +32 -23
- package/dist/components/mint-map/core/wrapper/MapMarkerWrapper.js +76 -28
- package/dist/components/mint-map/core/wrapper/MapPolygonWrapper.d.ts +12 -5
- package/dist/components/mint-map/core/wrapper/MapPolygonWrapper.js +21 -6
- package/dist/components/mint-map/core/wrapper/MapPolylineWrapper.d.ts +12 -5
- package/dist/components/mint-map/core/wrapper/MapPolylineWrapper.js +21 -7
- package/dist/components/mint-map/core/wrapper/index.d.ts +6 -6
- package/dist/components/mint-map/google/GoogleMintMapController.d.ts +51 -39
- package/dist/components/mint-map/google/GoogleMintMapController.js +224 -44
- package/dist/components/mint-map/index.d.ts +5 -4
- package/dist/components/mint-map/kakao/KakaoMintMapController.d.ts +56 -44
- package/dist/components/mint-map/kakao/KakaoMintMapController.js +265 -66
- package/dist/components/mint-map/naver/NaverMintMapController.d.ts +53 -42
- package/dist/components/mint-map/naver/NaverMintMapController.js +237 -50
- package/dist/components/mint-map/types/CommonTypes.d.ts +11 -0
- package/dist/components/mint-map/types/MapDrawables.d.ts +110 -0
- package/dist/components/mint-map/types/MapDrawables.js +92 -0
- package/dist/components/mint-map/types/MapEventTypes.d.ts +41 -0
- package/dist/components/mint-map/types/MapEventTypes.js +57 -0
- package/dist/components/mint-map/types/MapTypes.d.ts +60 -0
- package/dist/components/mint-map/types/MapTypes.js +155 -0
- package/dist/components/mint-map/types/MintMapEvents.d.ts +25 -0
- package/dist/components/mint-map/types/MintMapProps.d.ts +92 -0
- package/dist/components/mint-map/types/index.d.ts +6 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.es.js +2638 -975
- package/dist/index.js +25 -9
- package/dist/index.umd.js +2644 -974
- package/package.json +77 -77
- package/test.ts +0 -7
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
var LinePoints =
|
|
6
|
+
/** @class */
|
|
7
|
+
function () {
|
|
8
8
|
function LinePoints(x1, y1, x2, y2) {
|
|
9
9
|
this.x1 = x1;
|
|
10
10
|
this.y1 = y1;
|
|
@@ -15,10 +15,23 @@ var LinePoints = function () {
|
|
|
15
15
|
return LinePoints;
|
|
16
16
|
}();
|
|
17
17
|
|
|
18
|
-
var
|
|
18
|
+
var PositionMirror =
|
|
19
|
+
/** @class */
|
|
20
|
+
function () {
|
|
21
|
+
function PositionMirror(lat, lng) {
|
|
22
|
+
this.lat = lat;
|
|
23
|
+
this.lng = lng;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return PositionMirror;
|
|
27
|
+
}();
|
|
28
|
+
|
|
29
|
+
var PolygonCalculator =
|
|
30
|
+
/** @class */
|
|
31
|
+
function () {
|
|
19
32
|
function PolygonCalculator() {}
|
|
20
33
|
|
|
21
|
-
PolygonCalculator.
|
|
34
|
+
PolygonCalculator.getRegionInfo = function (positions) {
|
|
22
35
|
var maxX, minX, maxY, minY;
|
|
23
36
|
|
|
24
37
|
for (var _i = 0, positions_1 = positions; _i < positions_1.length; _i++) {
|
|
@@ -41,8 +54,41 @@ var PolygonCalculator = function () {
|
|
|
41
54
|
}
|
|
42
55
|
}
|
|
43
56
|
|
|
44
|
-
|
|
45
|
-
|
|
57
|
+
return {
|
|
58
|
+
maxLat: maxX,
|
|
59
|
+
minLat: minX,
|
|
60
|
+
maxLng: maxY,
|
|
61
|
+
minLng: minY,
|
|
62
|
+
centerLat: minX && maxX ? minX + (maxX - minX) / 2 : undefined,
|
|
63
|
+
centerLng: minY && maxY ? minY + (maxY - minY) / 2 : undefined
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
PolygonCalculator.getRegionStart = function (positions) {
|
|
68
|
+
var info = this.getRegionInfo(positions);
|
|
69
|
+
|
|
70
|
+
if (info.minLat && info.minLng) {
|
|
71
|
+
return new PositionMirror(info.minLat, info.minLng);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
throw new Error('Calculate RegionStart Error!!!');
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
PolygonCalculator.getRegionEnd = function (positions) {
|
|
78
|
+
var info = this.getRegionInfo(positions);
|
|
79
|
+
|
|
80
|
+
if (info.maxLat && info.maxLng) {
|
|
81
|
+
return new PositionMirror(info.maxLat, info.maxLng);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
throw new Error('Calculate RegionEnd Error!!!');
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
PolygonCalculator.getCenter = function (positions) {
|
|
88
|
+
var info = this.getRegionInfo(positions);
|
|
89
|
+
|
|
90
|
+
if (info.centerLat && info.centerLng) {
|
|
91
|
+
return new PositionMirror(info.centerLat, info.centerLng);
|
|
46
92
|
}
|
|
47
93
|
|
|
48
94
|
throw new Error('Calculate Center Error!!!');
|
|
@@ -75,9 +121,10 @@ var PolygonCalculator = function () {
|
|
|
75
121
|
var lines = this.convertPolygonToLinePoints(polygon);
|
|
76
122
|
|
|
77
123
|
for (var _i = 0, targets_1 = targets; _i < targets_1.length; _i++) {
|
|
78
|
-
var target = targets_1[_i];
|
|
79
|
-
|
|
80
|
-
var
|
|
124
|
+
var target = targets_1[_i]; //x 축으로 긴 직선과 폴리곤 path 와의 교차 수 비교
|
|
125
|
+
|
|
126
|
+
var tempLine = this.convertPositionToPoints(target, new PositionMirror(target.lat, maxX));
|
|
127
|
+
var crossPoints = this.getCrossPointAll(lines, tempLine); // console.log('crossPoints',crossPoints);
|
|
81
128
|
|
|
82
129
|
if (crossPoints.length > 0 && crossPoints.length % 2 != 0) {
|
|
83
130
|
result.push(target);
|
|
@@ -99,16 +146,20 @@ var PolygonCalculator = function () {
|
|
|
99
146
|
|
|
100
147
|
PolygonCalculator.convertPositionToPoints = function (pos1, pos2) {
|
|
101
148
|
return new LinePoints(pos1.lng, pos1.lat, pos2.lng, pos2.lat);
|
|
102
|
-
};
|
|
149
|
+
}; //두 직선의 교점 구하기
|
|
150
|
+
|
|
103
151
|
|
|
104
152
|
PolygonCalculator.getCrossPoint = function (sr, tr) {
|
|
105
|
-
var p1 = (sr.x1 - sr.x2) * (tr.y1 - tr.y2) - (sr.y1 - sr.y2) * (tr.x1 - tr.x2);
|
|
153
|
+
var p1 = (sr.x1 - sr.x2) * (tr.y1 - tr.y2) - (sr.y1 - sr.y2) * (tr.x1 - tr.x2); //분모로 사용됨
|
|
154
|
+
// p1 ==0 이면 평행선 또는 일치 이므로 제외(분모)
|
|
106
155
|
|
|
107
156
|
if (p1 != 0) {
|
|
108
157
|
var x = ((sr.x1 * sr.y2 - sr.y1 * sr.x2) * (tr.x1 - tr.x2) - (sr.x1 - sr.x2) * (tr.x1 * tr.y2 - tr.y1 * tr.x2)) / p1;
|
|
109
158
|
var y = ((sr.x1 * sr.y2 - sr.y1 * sr.x2) * (tr.y1 - tr.y2) - (sr.y1 - sr.y2) * (tr.x1 * tr.y2 - tr.y1 * tr.x2)) / p1;
|
|
110
159
|
|
|
111
|
-
if (this.toFixedPosition((x - sr.x1) * (x - sr.x2)) <= 0 && this.toFixedPosition((y - sr.y1) * (y - sr.y2)) <= 0
|
|
160
|
+
if (this.toFixedPosition((x - sr.x1) * (x - sr.x2)) <= 0 && this.toFixedPosition((y - sr.y1) * (y - sr.y2)) <= 0 //교점이 1선분 위에 있고
|
|
161
|
+
&& this.toFixedPosition((x - tr.x1) * (x - tr.x2)) <= 0 && this.toFixedPosition((y - tr.y1) * (y - tr.y2)) <= 0 //교점이 2선분 위에 있을경우
|
|
162
|
+
) {
|
|
112
163
|
return {
|
|
113
164
|
x: x,
|
|
114
165
|
y: y
|
|
@@ -138,7 +189,7 @@ var PolygonCalculator = function () {
|
|
|
138
189
|
|
|
139
190
|
PolygonCalculator.findCrossPoint = function (sr, tr) {
|
|
140
191
|
for (var _i = 0, sr_2 = sr; _i < sr_2.length; _i++) {
|
|
141
|
-
var tmp = sr_2[_i];
|
|
192
|
+
var tmp = sr_2[_i]; //교점이 있으면 true
|
|
142
193
|
|
|
143
194
|
if (this.getCrossPoint(tmp, tr)) {
|
|
144
195
|
return true;
|
|
@@ -148,10 +199,96 @@ var PolygonCalculator = function () {
|
|
|
148
199
|
return false;
|
|
149
200
|
};
|
|
150
201
|
|
|
202
|
+
PolygonCalculator.simplifyPoints = function (polygon, tolerance, lastRepeated) {
|
|
203
|
+
var target = lastRepeated ? polygon.slice(0, polygon.length - 1) : polygon;
|
|
204
|
+
return this.simplify(target.map(function (position) {
|
|
205
|
+
return [position.lng, position.lat];
|
|
206
|
+
}), tolerance !== undefined ? tolerance : this.TOLERANCE_NAVER_STYLE).map(function (point) {
|
|
207
|
+
return new PositionMirror(point[1], point[0]);
|
|
208
|
+
});
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
PolygonCalculator.simplify = function (points, tolerance) {
|
|
212
|
+
if (points.length <= 2) {
|
|
213
|
+
return points;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
var dMax = 0;
|
|
217
|
+
var index = 0; // Find the point with the maximum distance from the line segment
|
|
218
|
+
|
|
219
|
+
for (var i = 1; i < points.length - 1; i++) {
|
|
220
|
+
var d = this.perpendicularDistance(points[i], points[0], points[points.length - 1]);
|
|
221
|
+
|
|
222
|
+
if (d > dMax) {
|
|
223
|
+
dMax = d;
|
|
224
|
+
index = i;
|
|
225
|
+
}
|
|
226
|
+
} // If the maximum distance is greater than the tolerance, recursively simplify
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
if (dMax > tolerance) {
|
|
230
|
+
var left = this.simplify(points.slice(0, index + 1), tolerance);
|
|
231
|
+
var right = this.simplify(points.slice(index), tolerance); // Concatenate the simplified left and right segments
|
|
232
|
+
|
|
233
|
+
return left.slice(0, left.length - 1).concat(right);
|
|
234
|
+
} else {
|
|
235
|
+
// If the maximum distance is less than or equal to the tolerance, return the endpoints
|
|
236
|
+
return [points[0], points[points.length - 1]];
|
|
237
|
+
}
|
|
238
|
+
}; // Calculate the perpendicular distance from a point to a line segment
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
PolygonCalculator.perpendicularDistance = function (point, lineStart, lineEnd) {
|
|
242
|
+
var x = point[0];
|
|
243
|
+
var y = point[1];
|
|
244
|
+
var x1 = lineStart[0];
|
|
245
|
+
var y1 = lineStart[1];
|
|
246
|
+
var x2 = lineEnd[0];
|
|
247
|
+
var y2 = lineEnd[1];
|
|
248
|
+
var numerator = Math.abs((y2 - y1) * x - (x2 - x1) * y + x2 * y1 - y2 * x1);
|
|
249
|
+
var denominator = Math.sqrt(Math.pow(y2 - y1, 2) + Math.pow(x2 - x1, 2));
|
|
250
|
+
return numerator / denominator;
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
PolygonCalculator.calculatePolygonSize = function (polygon, innerPolygons) {
|
|
254
|
+
var _this = this;
|
|
255
|
+
|
|
256
|
+
var outer = this.calculatePolygonSizeMain(polygon);
|
|
257
|
+
var inner = 0;
|
|
258
|
+
innerPolygons && innerPolygons.map(function (innerPolygon) {
|
|
259
|
+
inner += _this.calculatePolygonSizeMain(innerPolygon);
|
|
260
|
+
});
|
|
261
|
+
return outer - inner;
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
PolygonCalculator.calculatePolygonSizeMain = function (polygon) {
|
|
265
|
+
var vertices = polygon.map(function (pos) {
|
|
266
|
+
return {
|
|
267
|
+
x: GeoCalulator.convertLongitudeToMeterValue(pos.lat, pos.lng),
|
|
268
|
+
y: GeoCalulator.convertLatitudeToMeterValue(pos.lat)
|
|
269
|
+
};
|
|
270
|
+
});
|
|
271
|
+
var n = vertices.length;
|
|
272
|
+
var sum = 0;
|
|
273
|
+
|
|
274
|
+
for (var i = 0; i < n; i++) {
|
|
275
|
+
var currentVertex = vertices[i];
|
|
276
|
+
var nextVertex = vertices[(i + 1) % n];
|
|
277
|
+
sum += currentVertex.x * nextVertex.y - currentVertex.y * nextVertex.x;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
var area = Math.abs(sum) / 2;
|
|
281
|
+
return area;
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
PolygonCalculator.TOLERANCE_NAVER_STYLE = 0.0001;
|
|
285
|
+
PolygonCalculator.TOLERANCE_GOOGLE_STYLE = 0.00001;
|
|
151
286
|
return PolygonCalculator;
|
|
152
287
|
}();
|
|
153
288
|
|
|
154
|
-
var GeoCalulator =
|
|
289
|
+
var GeoCalulator =
|
|
290
|
+
/** @class */
|
|
291
|
+
function () {
|
|
155
292
|
function GeoCalulator() {}
|
|
156
293
|
|
|
157
294
|
GeoCalulator.computeDistanceKiloMeter = function (pos1, pos2) {
|
|
@@ -159,7 +296,8 @@ var GeoCalulator = function () {
|
|
|
159
296
|
var dLon = this.deg2rad(pos2.lng - pos1.lng);
|
|
160
297
|
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);
|
|
161
298
|
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
|
162
|
-
var d = this.
|
|
299
|
+
var d = this.EARTH_EQUATORIAL_RADIUS_KM * c; // Distance in km
|
|
300
|
+
|
|
163
301
|
return d;
|
|
164
302
|
};
|
|
165
303
|
|
|
@@ -171,54 +309,122 @@ var GeoCalulator = function () {
|
|
|
171
309
|
return meter * this.LATITUDE_POSITION_VALUE_PER_METER;
|
|
172
310
|
};
|
|
173
311
|
|
|
312
|
+
GeoCalulator.convertLatitudeToMeterValue = function (lat) {
|
|
313
|
+
return lat * this.METER_VALUE_PER_LATITUDE;
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
GeoCalulator.convertLongitudeToMeterValue = function (lat, lng) {
|
|
317
|
+
return lng * this.calculateLongitudeValueWithLatitudeInMeter(lat);
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
GeoCalulator.getCacheUnitOfLongitudeValueWithLatitudeInMeter = function (lat) {
|
|
321
|
+
return lat.toFixed(2);
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
GeoCalulator.getCacheOfLongitudeValueWithLatitudeInMeter = function (latUnit) {
|
|
325
|
+
return this.CACHE_OF_LNG_PER_METER.get(latUnit);
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
GeoCalulator.setCacheOfLongitudeValueWithLatitudeInMeter = function (latUnit, lngValue) {
|
|
329
|
+
if (this.CACHE_OF_LNG_PER_METER.size > 10) {
|
|
330
|
+
this.CACHE_OF_LNG_PER_METER.clear();
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
this.CACHE_OF_LNG_PER_METER.set(latUnit, lngValue);
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
GeoCalulator.calculateLongitudeValueWithLatitudeInMeter = function (lat) {
|
|
337
|
+
// const t = Date.now()
|
|
338
|
+
// Cache check
|
|
339
|
+
var latUnit = this.getCacheUnitOfLongitudeValueWithLatitudeInMeter(lat);
|
|
340
|
+
var fromCache = this.getCacheOfLongitudeValueWithLatitudeInMeter(latUnit);
|
|
341
|
+
|
|
342
|
+
if (fromCache !== undefined) {
|
|
343
|
+
// console.log(`cache hit!! ${Date.now() - t} ms`, fromCache, latUnit, this.CACHE_OF_LNG_PER_METER.size);
|
|
344
|
+
return fromCache;
|
|
345
|
+
} // Convert latitude and longitude to radians
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
var latRad = lat * Math.PI / 180; // Calculate Earth's radius at the given latitude
|
|
349
|
+
|
|
350
|
+
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
|
|
351
|
+
|
|
352
|
+
var distance = 2 * Math.PI * radius * Math.cos(latRad) / 360; // Cache set
|
|
353
|
+
|
|
354
|
+
this.setCacheOfLongitudeValueWithLatitudeInMeter(latUnit, distance); // console.log(`calculated ${Date.now() - t} ms`)
|
|
355
|
+
|
|
356
|
+
return distance;
|
|
357
|
+
};
|
|
358
|
+
|
|
174
359
|
GeoCalulator.computeNextPositionAndDistances = function (context) {
|
|
175
360
|
var pos1 = context.pos1,
|
|
176
361
|
pos2 = context.pos2,
|
|
177
362
|
prevPos2 = context.prevPos2,
|
|
178
363
|
velocityKmh = context.velocityKmh,
|
|
179
364
|
prevVelocityKmh = context.prevVelocityKmh,
|
|
180
|
-
elapsedTimeMs = context.elapsedTimeMs;
|
|
365
|
+
elapsedTimeMs = context.elapsedTimeMs; // console.log('velocityKmh / elapsedTimeMs',velocityKmh , elapsedTimeMs);
|
|
366
|
+
//총 가야할 거리 (km)
|
|
181
367
|
|
|
182
368
|
if (pos2 !== prevPos2) {
|
|
369
|
+
//목표가 바뀌면 거리 및 비율 재계산
|
|
183
370
|
context.totalDistance = this.computeDistanceKiloMeter(pos1, pos2);
|
|
184
371
|
context.currDistance = 0;
|
|
185
372
|
context.prevPos2 = pos2;
|
|
186
373
|
}
|
|
187
374
|
|
|
188
|
-
var totalDistance = context.totalDistance;
|
|
375
|
+
var totalDistance = context.totalDistance; // console.log('totalDistance', totalDistance);
|
|
376
|
+
//ms 속으로 환산
|
|
189
377
|
|
|
190
378
|
if (velocityKmh !== prevVelocityKmh) {
|
|
379
|
+
//속도가 바뀌면 재계산
|
|
191
380
|
context.vPerMs = velocityKmh / this.MS_FROM_HOUR;
|
|
192
381
|
context.prevVelocityKmh = velocityKmh;
|
|
193
382
|
}
|
|
194
383
|
|
|
195
|
-
var vPerMs = context.vPerMs;
|
|
196
|
-
|
|
384
|
+
var vPerMs = context.vPerMs; //console.log('vPerMs', vPerMs);
|
|
385
|
+
//실제 가는 거리 계산
|
|
386
|
+
|
|
387
|
+
var nextDistance = context.distanceRemain ? context.distanceRemain : context.currDistance + elapsedTimeMs * vPerMs; //console.log('nextDistance', nextDistance);
|
|
388
|
+
//목표점까지 이동 후에도 남는 거리
|
|
389
|
+
|
|
197
390
|
context.currDistance = nextDistance;
|
|
198
391
|
|
|
199
392
|
if (totalDistance < context.currDistance) {
|
|
393
|
+
//이동 거리가 현재 목표점을 넘어가는 경우
|
|
200
394
|
context.distanceRemain = context.currDistance - totalDistance;
|
|
201
395
|
context.nextPos = pos2;
|
|
202
396
|
return context;
|
|
203
397
|
} else {
|
|
204
398
|
context.distanceRemain = 0;
|
|
205
|
-
}
|
|
399
|
+
} //각 축으로 나가야할 비율
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
var ratio = nextDistance / totalDistance; //console.log('ratio', ratio);
|
|
403
|
+
//방향값 체크
|
|
206
404
|
|
|
207
|
-
var ratio = nextDistance / totalDistance;
|
|
208
405
|
var latCalib = pos2.lat > pos1.lat ? 1 : -1;
|
|
209
|
-
var lngCalib = pos2.lng > pos1.lng ? 1 : -1;
|
|
210
|
-
|
|
406
|
+
var lngCalib = pos2.lng > pos1.lng ? 1 : -1; //각 축에 보정된 새로운 지점 리턴
|
|
407
|
+
|
|
408
|
+
var newPos = new PositionMirror(pos1.lat + (pos2.lat - pos1.lat) * ratio, pos1.lng + (pos2.lng - pos1.lng) * ratio);
|
|
211
409
|
|
|
212
410
|
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)) {
|
|
213
411
|
newPos = pos2;
|
|
214
|
-
}
|
|
412
|
+
} // console.log('newPos', newPos);
|
|
413
|
+
//console.log('==============================================================\n');
|
|
414
|
+
|
|
215
415
|
|
|
216
416
|
context.nextPos = newPos;
|
|
217
417
|
return context;
|
|
218
418
|
};
|
|
219
419
|
|
|
220
|
-
GeoCalulator.
|
|
221
|
-
|
|
420
|
+
GeoCalulator.EARTH_EQUATORIAL_RADIUS = 6378137; //meter (6,378,137 m)
|
|
421
|
+
|
|
422
|
+
GeoCalulator.EARTH_EQUATORIAL_RADIUS_KM = GeoCalulator.EARTH_EQUATORIAL_RADIUS / 1000;
|
|
423
|
+
GeoCalulator.EARTH_ECCENTRICITY = 0.08181919;
|
|
424
|
+
GeoCalulator.METER_VALUE_PER_LATITUDE = 110.32 * 1000; //위도 기준 1도는 110.32km
|
|
425
|
+
|
|
426
|
+
GeoCalulator.LATITUDE_POSITION_VALUE_PER_METER = 1 / GeoCalulator.METER_VALUE_PER_LATITUDE;
|
|
427
|
+
GeoCalulator.CACHE_OF_LNG_PER_METER = new Map();
|
|
222
428
|
GeoCalulator.MS_FROM_HOUR = 60 * 60 * 1000;
|
|
223
429
|
return GeoCalulator;
|
|
224
430
|
}();
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { Bounds, Position } from "../../
|
|
2
|
-
export interface ClusterInfo {
|
|
3
|
-
bounds: Bounds;
|
|
4
|
-
checked: boolean;
|
|
5
|
-
center: boolean;
|
|
6
|
-
centerPosition: Position;
|
|
7
|
-
incList: any;
|
|
8
|
-
itemList: Position[];
|
|
9
|
-
size: number;
|
|
10
|
-
}
|
|
11
|
-
export interface ClusterStatus {
|
|
12
|
-
total: number;
|
|
13
|
-
average: number;
|
|
14
|
-
min: number;
|
|
15
|
-
max: number;
|
|
16
|
-
}
|
|
17
|
-
export declare type ClusterSizeCalculator = (info: ClusterInfo, status: ClusterStatus) => number;
|
|
18
|
-
export declare const getClusterInfo: (basePixelSize: number, mapBounds: Bounds, mapWidth: number, mapHeight: number, itemList: Position[], sizeFunction?: ClusterSizeCalculator) => ClusterInfo[];
|
|
1
|
+
import { Bounds, Position } from "../../types/MapTypes";
|
|
2
|
+
export interface ClusterInfo {
|
|
3
|
+
bounds: Bounds;
|
|
4
|
+
checked: boolean;
|
|
5
|
+
center: boolean;
|
|
6
|
+
centerPosition: Position;
|
|
7
|
+
incList: any;
|
|
8
|
+
itemList: Position[];
|
|
9
|
+
size: number;
|
|
10
|
+
}
|
|
11
|
+
export interface ClusterStatus {
|
|
12
|
+
total: number;
|
|
13
|
+
average: number;
|
|
14
|
+
min: number;
|
|
15
|
+
max: number;
|
|
16
|
+
}
|
|
17
|
+
export declare type ClusterSizeCalculator = (info: ClusterInfo, status: ClusterStatus) => number;
|
|
18
|
+
export declare const getClusterInfo: (basePixelSize: number, mapBounds: Bounds, mapWidth: number, mapHeight: number, itemList: Position[], sizeFunction?: ClusterSizeCalculator) => ClusterInfo[];
|
|
@@ -2,15 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var MapTypes = require('../../types/MapTypes.js');
|
|
6
6
|
|
|
7
7
|
var getClusterInfo = function (basePixelSize, mapBounds, mapWidth, mapHeight, itemList, sizeFunction) {
|
|
8
|
-
var _a;
|
|
8
|
+
var _a; //1. basePixelSize 기준으로 현재 지도 크기를 베이스로 영역 갯수 정하기
|
|
9
|
+
|
|
9
10
|
|
|
10
11
|
var rowCount = Number((mapWidth / basePixelSize).toFixed(0)) || 1;
|
|
11
|
-
var colCount = Number((mapHeight / basePixelSize).toFixed(0)) || 1;
|
|
12
|
+
var colCount = Number((mapHeight / basePixelSize).toFixed(0)) || 1; //console.log('rowCount', rowCount, 'colCount', colCount)
|
|
13
|
+
|
|
12
14
|
var boundsLineSizeX = Number(((mapBounds.ne.lng - mapBounds.nw.lng) / rowCount).toFixed(7));
|
|
13
|
-
var boundsLineSizeY = Number(((mapBounds.nw.lat - mapBounds.se.lat) / colCount).toFixed(7));
|
|
15
|
+
var boundsLineSizeY = Number(((mapBounds.nw.lat - mapBounds.se.lat) / colCount).toFixed(7)); //console.log('boundsLineSize', boundsLineSizeX, boundsLineSizeY)
|
|
14
16
|
var boundsPos = [];
|
|
15
17
|
var tempX1, tempY1, tempX2, tempY2;
|
|
16
18
|
|
|
@@ -23,7 +25,7 @@ var getClusterInfo = function (basePixelSize, mapBounds, mapWidth, mapHeight, it
|
|
|
23
25
|
for (var k = 0; k < colCount; k++) {
|
|
24
26
|
tempY2 = mapBounds.se.lat + boundsLineSizeY * k;
|
|
25
27
|
tempY1 = mapBounds.se.lat + boundsLineSizeY * (k + 1);
|
|
26
|
-
var thisBounds =
|
|
28
|
+
var thisBounds = MapTypes.Bounds.fromNWSE(new MapTypes.Position(tempY1, tempX1), new MapTypes.Position(tempY2, tempX2));
|
|
27
29
|
var includedList = thisBounds.getIncludedPositions(itemList);
|
|
28
30
|
rows.push({
|
|
29
31
|
bounds: thisBounds,
|
|
@@ -35,7 +37,8 @@ var getClusterInfo = function (basePixelSize, mapBounds, mapWidth, mapHeight, it
|
|
|
35
37
|
size: basePixelSize
|
|
36
38
|
});
|
|
37
39
|
}
|
|
38
|
-
}
|
|
40
|
+
} //좌표마다 검사해서 인접셀 병합 처리
|
|
41
|
+
|
|
39
42
|
|
|
40
43
|
var centerList = [];
|
|
41
44
|
var totalItemCount = 0;
|
|
@@ -46,7 +49,8 @@ var getClusterInfo = function (basePixelSize, mapBounds, mapWidth, mapHeight, it
|
|
|
46
49
|
for (var k = 0; k < boundsPos[i].length; k++) {
|
|
47
50
|
var curr = boundsPos[i][k];
|
|
48
51
|
if (curr.checked) continue;
|
|
49
|
-
curr.checked = true;
|
|
52
|
+
curr.checked = true; //현재기준 8방향 객체 모으기
|
|
53
|
+
|
|
50
54
|
var incList = [];
|
|
51
55
|
|
|
52
56
|
if (boundsPos[i]) {
|
|
@@ -88,7 +92,7 @@ var getClusterInfo = function (basePixelSize, mapBounds, mapWidth, mapHeight, it
|
|
|
88
92
|
var avrLng = calculateAverage(curr.itemList.map(function (item) {
|
|
89
93
|
return item.lng;
|
|
90
94
|
}));
|
|
91
|
-
curr.centerPosition = new
|
|
95
|
+
curr.centerPosition = new MapTypes.Position(avrLat, avrLng);
|
|
92
96
|
totalItemCount += curr.itemList.length;
|
|
93
97
|
|
|
94
98
|
if (!min || curr.itemList.length < min) {
|
|
@@ -118,7 +122,8 @@ var getClusterInfo = function (basePixelSize, mapBounds, mapWidth, mapHeight, it
|
|
|
118
122
|
for (var _b = 0, centerList_1 = centerList; _b < centerList_1.length; _b++) {
|
|
119
123
|
var center = centerList_1[_b];
|
|
120
124
|
center.size = sizeFunction(center, status);
|
|
121
|
-
}
|
|
125
|
+
} // console.log('centerList', centerList, status);
|
|
126
|
+
|
|
122
127
|
|
|
123
128
|
return centerList;
|
|
124
129
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './animation';
|
|
2
|
-
export * from './calculate';
|
|
3
|
-
export * from './waiting';
|
|
4
|
-
export * from './cluster';
|
|
1
|
+
export * from './animation';
|
|
2
|
+
export * from './calculate';
|
|
3
|
+
export * from './waiting';
|
|
4
|
+
export * from './cluster';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function waiting(evaluation: () => boolean, timeoutSeconds?: number): Promise<boolean>;
|
|
1
|
+
export declare function waiting(evaluation: () => boolean, timeoutSeconds?: number): Promise<boolean>;
|
|
@@ -9,16 +9,20 @@ function waiting(evaluation, timeoutSeconds) {
|
|
|
9
9
|
var max;
|
|
10
10
|
return tslib.__generator(this, function (_a) {
|
|
11
11
|
max = (timeoutSeconds || 5) * 1000;
|
|
12
|
-
return [2
|
|
12
|
+
return [2
|
|
13
|
+
/*return*/
|
|
14
|
+
, new Promise(function (resolve) {
|
|
13
15
|
var start = new Date().getTime();
|
|
14
16
|
var inter = setInterval(function () {
|
|
17
|
+
//타임아웃 체크
|
|
15
18
|
var time = new Date().getTime();
|
|
16
19
|
|
|
17
20
|
if (time - start > max) {
|
|
18
21
|
clearInterval(inter);
|
|
19
22
|
resolve(false);
|
|
20
23
|
return;
|
|
21
|
-
}
|
|
24
|
+
} //평가식 체크
|
|
25
|
+
|
|
22
26
|
|
|
23
27
|
if (evaluation()) {
|
|
24
28
|
clearInterval(inter);
|
|
@@ -1,19 +1,27 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { MarkerOptions
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { MarkerOptions } from "../../types/MapDrawables";
|
|
3
|
+
import { Offset } from "../../types/MapTypes";
|
|
4
|
+
import { MintMapCanvasRenderer } from "../MintMapCanvasRenderer";
|
|
5
|
+
export declare type CanvasMarkerRenderer<T> = (ctx: MintMapCanvasRenderer, offset: Offset, payload?: T) => void;
|
|
6
|
+
export interface CanvasMarkerMouseEvent {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
}
|
|
10
|
+
export declare type CanvasMarkerMouseEventCallback = (e: CanvasMarkerMouseEvent) => boolean | undefined | void;
|
|
11
|
+
export interface MapCanvasMarkerWrapperProps<T> extends MarkerOptions {
|
|
12
|
+
renderer: CanvasMarkerRenderer<T>;
|
|
13
|
+
payload?: T;
|
|
14
|
+
boxWidth: number;
|
|
15
|
+
boxHeight: number;
|
|
16
|
+
onClick?: CanvasMarkerMouseEventCallback;
|
|
17
|
+
onMouseOver?: CanvasMarkerMouseEventCallback;
|
|
18
|
+
onMouseOut?: CanvasMarkerMouseEventCallback;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Mint Map 컴포넌트
|
|
22
|
+
*
|
|
23
|
+
* @param {MapControlWrapperProps} MapControlWrapperProps
|
|
24
|
+
*
|
|
25
|
+
* @returns {JSX.Element} JSX
|
|
26
|
+
*/
|
|
27
|
+
export declare function MapCanvasMarkerWrapper<T>(_props: MapCanvasMarkerWrapperProps<T>): JSX.Element;
|
|
@@ -8,7 +8,16 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
8
8
|
|
|
9
9
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Mint Map 컴포넌트
|
|
13
|
+
*
|
|
14
|
+
* @param {MapControlWrapperProps} MapControlWrapperProps
|
|
15
|
+
*
|
|
16
|
+
* @returns {JSX.Element} JSX
|
|
17
|
+
*/
|
|
18
|
+
|
|
11
19
|
function MapCanvasMarkerWrapper(_props) {
|
|
20
|
+
//실제 렌더링처리는 MapCanvasWrapper 에서...
|
|
12
21
|
return React__default["default"].createElement(React__default["default"].Fragment, null);
|
|
13
22
|
}
|
|
14
23
|
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
export interface MapCanvasWrapperProps {
|
|
3
|
-
}
|
|
4
|
-
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface MapCanvasWrapperProps {
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Mint Map 컴포넌트
|
|
6
|
+
*
|
|
7
|
+
* @param {MapControlWrapperProps} MapControlWrapperProps
|
|
8
|
+
*
|
|
9
|
+
* @returns {JSX.Element} JSX
|
|
10
|
+
*/
|
|
11
|
+
export declare function MapCanvasWrapper<T>({ children, ...props }: React.PropsWithChildren<MapCanvasWrapperProps>): JSX.Element;
|