@mint-ui/map 0.4.6-beta → 0.5.1-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.
Files changed (34) hide show
  1. package/dist/components/mint-map/core/MintMapController.d.ts +6 -0
  2. package/dist/components/mint-map/core/advanced/index.d.ts +1 -0
  3. package/dist/components/mint-map/core/advanced/shapes/CircleMarker.d.ts +20 -0
  4. package/dist/components/mint-map/core/advanced/shapes/CircleMarker.js +137 -0
  5. package/dist/components/mint-map/core/advanced/shapes/PolygonMarker.d.ts +23 -0
  6. package/dist/components/mint-map/core/advanced/shapes/PolygonMarker.js +188 -0
  7. package/dist/components/mint-map/core/advanced/shapes/base/SVGCircle.d.ts +8 -0
  8. package/dist/components/mint-map/core/advanced/shapes/base/SVGCircle.js +54 -0
  9. package/dist/components/mint-map/core/advanced/shapes/base/SVGPolygon.d.ts +12 -0
  10. package/dist/components/mint-map/core/advanced/shapes/base/SVGPolygon.js +152 -0
  11. package/dist/components/mint-map/core/advanced/shapes/base/SVGRect.d.ts +10 -0
  12. package/dist/components/mint-map/core/advanced/shapes/base/SVGRect.js +60 -0
  13. package/dist/components/mint-map/core/advanced/shapes/base/index.d.ts +3 -0
  14. package/dist/components/mint-map/core/advanced/shapes/index.d.ts +3 -0
  15. package/dist/components/mint-map/core/hooks/MarkerMovingHook.js +4 -1
  16. package/dist/components/mint-map/core/util/calculate.d.ts +28 -1
  17. package/dist/components/mint-map/core/util/calculate.js +174 -7
  18. package/dist/components/mint-map/core/wrapper/MapMarkerWrapper.d.ts +2 -1
  19. package/dist/components/mint-map/core/wrapper/MapMarkerWrapper.js +25 -6
  20. package/dist/components/mint-map/google/GoogleMintMapController.d.ts +9 -0
  21. package/dist/components/mint-map/google/GoogleMintMapController.js +134 -0
  22. package/dist/components/mint-map/kakao/KakaoMintMapController.d.ts +8 -0
  23. package/dist/components/mint-map/kakao/KakaoMintMapController.js +118 -1
  24. package/dist/components/mint-map/naver/NaverMintMapController.d.ts +8 -0
  25. package/dist/components/mint-map/naver/NaverMintMapController.js +101 -1
  26. package/dist/components/mint-map/types/MapEventTypes.d.ts +41 -0
  27. package/dist/components/mint-map/types/MapEventTypes.js +57 -0
  28. package/dist/components/mint-map/types/MapTypes.d.ts +1 -0
  29. package/dist/components/mint-map/types/MapTypes.js +4 -0
  30. package/dist/components/mint-map/types/index.d.ts +1 -0
  31. package/dist/index.es.js +1438 -334
  32. package/dist/index.js +13 -0
  33. package/dist/index.umd.js +1444 -333
  34. package/package.json +1 -1
@@ -0,0 +1,60 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var tslib = require('tslib');
6
+ var React = require('react');
7
+
8
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
+
10
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
11
+
12
+ function SVGRect(_a) {
13
+ var _b = _a.width,
14
+ width = _b === void 0 ? 100 : _b,
15
+ _c = _a.height,
16
+ height = _c === void 0 ? 100 : _c,
17
+ _d = _a.background,
18
+ background = _d === void 0 ? 'lightblue' : _d,
19
+ _e = _a.svgProperties,
20
+ svgProperties = _e === void 0 ? {} : _e,
21
+ _f = _a.shapeProperties,
22
+ shapeProperties = _f === void 0 ? {} : _f,
23
+ children = _a.children;
24
+ var getViewHeight = React.useCallback(function (width, height) {
25
+ return Number((100 * height / width).toFixed(0));
26
+ }, []);
27
+ var viewWidth = React.useRef(100);
28
+
29
+ var _g = React.useState(getViewHeight(width, height)),
30
+ viewHeight = _g[0],
31
+ setViewHeight = _g[1];
32
+
33
+ React.useEffect(function () {
34
+ setViewHeight(getViewHeight(width, height));
35
+ }, [width, height]);
36
+ return React__default["default"].createElement(React__default["default"].Fragment, null, React__default["default"].createElement("svg", tslib.__assign({
37
+ pointerEvents: "none",
38
+ width: width,
39
+ height: height,
40
+ viewBox: "0 0 ".concat(viewWidth.current, " ").concat(viewHeight)
41
+ }, svgProperties), React__default["default"].createElement("rect", tslib.__assign({
42
+ pointerEvents: "visiblepainted",
43
+ x: "0",
44
+ y: "0",
45
+ width: viewWidth.current,
46
+ height: viewHeight,
47
+ fill: background
48
+ }, shapeProperties))), React__default["default"].createElement("div", {
49
+ style: {
50
+ pointerEvents: 'none',
51
+ position: 'absolute',
52
+ left: '0px',
53
+ top: '0px',
54
+ width: "".concat(width, "px"),
55
+ height: "".concat(height, "px")
56
+ }
57
+ }, children));
58
+ }
59
+
60
+ exports.SVGRect = SVGRect;
@@ -0,0 +1,3 @@
1
+ export * from './SVGCircle';
2
+ export * from './SVGPolygon';
3
+ export * from './SVGRect';
@@ -0,0 +1,3 @@
1
+ export * from './base';
2
+ export * from './CircleMarker';
3
+ export * from './PolygonMarker';
@@ -6,6 +6,9 @@ var React = require('react');
6
6
  var MintMapProvider = require('../provider/MintMapProvider.js');
7
7
  var animation = require('../util/animation.js');
8
8
  var calculate = require('../util/calculate.js');
9
+ require('../../types/MapDrawables.js');
10
+ var MapTypes = require('../../types/MapTypes.js');
11
+ require('../../types/MapEventTypes.js');
9
12
 
10
13
  function nextIndex(array, currIdx) {
11
14
  var next = currIdx + 1;
@@ -98,7 +101,7 @@ function useMarkerMoving(_a) {
98
101
  }
99
102
  }
100
103
 
101
- nextOption_1.position = context_1.nextPos;
104
+ nextOption_1.position = new MapTypes.Position(context_1.nextPos.lat, context_1.nextPos.lng);
102
105
  marker.options.position = nextOption_1.position;
103
106
  controller.updateMarker(marker, nextOption_1);
104
107
 
@@ -4,6 +4,16 @@ declare class PositionMirror {
4
4
  constructor(lat: number, lng: number);
5
5
  }
6
6
  export declare class PolygonCalculator {
7
+ static getRegionInfo(positions: PositionMirror[]): {
8
+ maxLat: number | undefined;
9
+ minLat: number | undefined;
10
+ maxLng: number | undefined;
11
+ minLng: number | undefined;
12
+ centerLat: number | undefined;
13
+ centerLng: number | undefined;
14
+ };
15
+ static getRegionStart(positions: PositionMirror[]): PositionMirror;
16
+ static getRegionEnd(positions: PositionMirror[]): PositionMirror;
7
17
  static getCenter(positions: PositionMirror[]): PositionMirror;
8
18
  static intersects(positions1: PositionMirror[], positions2: PositionMirror[]): boolean;
9
19
  static getIncludedPositions(polygon: PositionMirror[], position: PositionMirror | PositionMirror[]): PositionMirror[];
@@ -13,6 +23,13 @@ export declare class PolygonCalculator {
13
23
  private static toFixedPosition;
14
24
  private static getCrossPointAll;
15
25
  private static findCrossPoint;
26
+ static readonly TOLERANCE_NAVER_STYLE = 0.0001;
27
+ static readonly TOLERANCE_GOOGLE_STYLE = 0.00001;
28
+ static simplifyPoints(polygon: PositionMirror[], tolerance?: number, lastRepeated?: boolean): PositionMirror[];
29
+ private static simplify;
30
+ private static perpendicularDistance;
31
+ static calculatePolygonSize(polygon: PositionMirror[], innerPolygons?: PositionMirror[][]): number;
32
+ private static calculatePolygonSizeMain;
16
33
  }
17
34
  export interface NextPositionContext {
18
35
  pos1: PositionMirror;
@@ -28,11 +45,21 @@ export interface NextPositionContext {
28
45
  nextPos: PositionMirror;
29
46
  }
30
47
  export declare class GeoCalulator {
31
- private static readonly EARTH_RADIUS;
48
+ private static readonly EARTH_EQUATORIAL_RADIUS;
49
+ private static readonly EARTH_EQUATORIAL_RADIUS_KM;
50
+ private static readonly EARTH_ECCENTRICITY;
51
+ private static readonly METER_VALUE_PER_LATITUDE;
32
52
  private static readonly LATITUDE_POSITION_VALUE_PER_METER;
33
53
  static computeDistanceKiloMeter(pos1: PositionMirror, pos2: PositionMirror): number;
34
54
  private static deg2rad;
35
55
  static convertMeterToLatitudeValue(meter: number): number;
56
+ static convertLatitudeToMeterValue(lat: number): number;
57
+ static convertLongitudeToMeterValue(lat: number, lng: number): number;
58
+ private static readonly CACHE_OF_LNG_PER_METER;
59
+ private static getCacheUnitOfLongitudeValueWithLatitudeInMeter;
60
+ private static getCacheOfLongitudeValueWithLatitudeInMeter;
61
+ private static setCacheOfLongitudeValueWithLatitudeInMeter;
62
+ static calculateLongitudeValueWithLatitudeInMeter(lat: number): number;
36
63
  private static readonly MS_FROM_HOUR;
37
64
  static computeNextPositionAndDistances(context: NextPositionContext): NextPositionContext;
38
65
  }
@@ -31,7 +31,7 @@ var PolygonCalculator =
31
31
  function () {
32
32
  function PolygonCalculator() {}
33
33
 
34
- PolygonCalculator.getCenter = function (positions) {
34
+ PolygonCalculator.getRegionInfo = function (positions) {
35
35
  var maxX, minX, maxY, minY;
36
36
 
37
37
  for (var _i = 0, positions_1 = positions; _i < positions_1.length; _i++) {
@@ -52,11 +52,43 @@ function () {
52
52
  if (minY === undefined || pos.lng < minY) {
53
53
  minY = pos.lng;
54
54
  }
55
- } //console.log('center min max => ', maxX, minX, maxY, minY)
55
+ }
56
+
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
+ };
56
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);
57
89
 
58
- if (maxX && minX && maxY && minY) {
59
- return new PositionMirror(minX + (maxX - minX) / 2, minY + (maxY - minY) / 2);
90
+ if (info.centerLat && info.centerLng) {
91
+ return new PositionMirror(info.centerLat, info.centerLng);
60
92
  }
61
93
 
62
94
  throw new Error('Calculate Center Error!!!');
@@ -167,6 +199,90 @@ function () {
167
199
  return false;
168
200
  };
169
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;
170
286
  return PolygonCalculator;
171
287
  }();
172
288
 
@@ -180,7 +296,7 @@ function () {
180
296
  var dLon = this.deg2rad(pos2.lng - pos1.lng);
181
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);
182
298
  var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
183
- var d = this.EARTH_RADIUS * c; // Distance in km
299
+ var d = this.EARTH_EQUATORIAL_RADIUS_KM * c; // Distance in km
184
300
 
185
301
  return d;
186
302
  };
@@ -193,6 +309,53 @@ function () {
193
309
  return meter * this.LATITUDE_POSITION_VALUE_PER_METER;
194
310
  };
195
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
+
196
359
  GeoCalulator.computeNextPositionAndDistances = function (context) {
197
360
  var pos1 = context.pos1,
198
361
  pos2 = context.pos2,
@@ -254,10 +417,14 @@ function () {
254
417
  return context;
255
418
  };
256
419
 
257
- GeoCalulator.EARTH_RADIUS = 6371; //in km (6,371.230 km)
420
+ GeoCalulator.EARTH_EQUATORIAL_RADIUS = 6378137; //meter (6,378,137 m)
258
421
 
259
- GeoCalulator.LATITUDE_POSITION_VALUE_PER_METER = 1 / (110 * 1000); //위도 기준 1도는 110km
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
260
425
 
426
+ GeoCalulator.LATITUDE_POSITION_VALUE_PER_METER = 1 / GeoCalulator.METER_VALUE_PER_LATITUDE;
427
+ GeoCalulator.CACHE_OF_LNG_PER_METER = new Map();
261
428
  GeoCalulator.MS_FROM_HOUR = 60 * 60 * 1000;
262
429
  return GeoCalulator;
263
430
  }();
@@ -20,6 +20,7 @@ export interface MapMarkerWrapperProps extends MarkerOptions {
20
20
  startAnimationClassName?: string;
21
21
  endAnimationClassName?: string;
22
22
  movingAnimation?: MapMarkerMoving;
23
+ disablePointerEvent?: boolean;
23
24
  }
24
25
  /**
25
26
  * Mint Map 컴포넌트
@@ -28,4 +29,4 @@ export interface MapMarkerWrapperProps extends MarkerOptions {
28
29
  *
29
30
  * @returns {JSX.Element} JSX
30
31
  */
31
- export declare function MapMarkerWrapper({ startAnimationClassName, endAnimationClassName, topOnClick, topOnHover, movingAnimation, children, ...options }: PropsWithChildren<MapMarkerWrapperProps>): JSX.Element;
32
+ export declare function MapMarkerWrapper({ startAnimationClassName, endAnimationClassName, topOnClick, topOnHover, movingAnimation, disablePointerEvent, children, ...options }: PropsWithChildren<MapMarkerWrapperProps>): JSX.Element;
@@ -34,8 +34,10 @@ function MapMarkerWrapper(_a) {
34
34
  _c = _a.topOnHover,
35
35
  topOnHover = _c === void 0 ? false : _c,
36
36
  movingAnimation = _a.movingAnimation,
37
+ _d = _a.disablePointerEvent,
38
+ disablePointerEvent = _d === void 0 ? false : _d,
37
39
  children = _a.children,
38
- options = tslib.__rest(_a, ["startAnimationClassName", "endAnimationClassName", "topOnClick", "topOnHover", "movingAnimation", "children"]); //controller
40
+ options = tslib.__rest(_a, ["startAnimationClassName", "endAnimationClassName", "topOnClick", "topOnHover", "movingAnimation", "disablePointerEvent", "children"]); //controller
39
41
 
40
42
 
41
43
  var controller = MintMapProvider.useMintMapController(); //element
@@ -47,9 +49,9 @@ function MapMarkerWrapper(_a) {
47
49
 
48
50
  var markerRef = React.useRef(); //moving animation
49
51
 
50
- var _d = React.useState({}),
51
- movingState = _d[0],
52
- setMovingState = _d[1];
52
+ var _e = React.useState({}),
53
+ movingState = _e[0],
54
+ setMovingState = _e[1];
53
55
 
54
56
  React.useEffect(function () {
55
57
  // console.log('movingState', movingState);
@@ -110,6 +112,11 @@ function MapMarkerWrapper(_a) {
110
112
 
111
113
  React.useEffect(function () {
112
114
  // console.log('drawable created')
115
+ divElement.style.display = 'flex';
116
+ divElement.style.justifyContent = 'flex-start';
117
+ divElement.style.alignItems = 'flex-start';
118
+ divElement.style.flexDirection = 'column';
119
+ divElement.style.pointerEvents = disablePointerEvent ? 'none' : '';
113
120
  divElement.addEventListener('click', onClickHandler);
114
121
  divElement.addEventListener('mouseover', onMouseOverHandler);
115
122
  return function () {
@@ -147,7 +154,13 @@ function MapMarkerWrapper(_a) {
147
154
  if (options) {
148
155
  if (markerRef.current) {
149
156
  //console.log('update Marker')
150
- controller.updateMarker(markerRef.current, options); //marker offset 보정
157
+ controller.updateMarker(markerRef.current, options); //disablePointerEvent 처리
158
+
159
+ if (divElement.parentElement) {
160
+ divElement.style.pointerEvents = disablePointerEvent ? 'none' : '';
161
+ divElement.parentElement.style.pointerEvents = disablePointerEvent ? 'none' : '';
162
+ } //marker offset 보정
163
+
151
164
 
152
165
  offsetCalibration(controller.getMapType(), divElement, options); //z-index 처리
153
166
 
@@ -158,7 +171,13 @@ function MapMarkerWrapper(_a) {
158
171
  //console.log('create Marker')
159
172
  markerRef.current = new MapDrawables.Marker(options);
160
173
  markerRef.current.element = divElement;
161
- controller.createMarker(markerRef.current); //marker offset 보정
174
+ controller.createMarker(markerRef.current); //disablePointerEvent 처리
175
+
176
+ if (divElement.parentElement) {
177
+ divElement.style.pointerEvents = disablePointerEvent ? 'none' : '';
178
+ divElement.parentElement.style.pointerEvents = disablePointerEvent ? 'none' : '';
179
+ } //marker offset 보정
180
+
162
181
 
163
182
  offsetCalibration(controller.getMapType(), divElement, options); //z-index 처리
164
183
 
@@ -2,6 +2,7 @@
2
2
  import { MintMapController } from "../core/MintMapController";
3
3
  import { MapType, MapVendorType } from "../types/CommonTypes";
4
4
  import { Drawable, Marker, MarkerOptions, Polygon, PolygonOptions, Polyline, PolylineOptions } from "../types/MapDrawables";
5
+ import { EventCallback, EventParamType, MapEvent, MapEventName, MapUIEvent } from "../types/MapEventTypes";
5
6
  import { Bounds, Position } from "../types/MapTypes";
6
7
  import { MintMapProps } from "../types/MintMapProps";
7
8
  export declare class GoogleMintMapController extends MintMapController {
@@ -9,6 +10,8 @@ export declare class GoogleMintMapController extends MintMapController {
9
10
  map: google.maps.Map | null;
10
11
  scriptUrl: string;
11
12
  scriptModules: string[];
13
+ protected mapEvent: MapEvent;
14
+ protected mapUIEvent: MapUIEvent;
12
15
  constructor(props: MintMapProps);
13
16
  polylineEvents: string[];
14
17
  createPolyline(polyline: Polyline): void;
@@ -30,6 +33,7 @@ export declare class GoogleMintMapController extends MintMapController {
30
33
  setMapDragged(value: boolean): void;
31
34
  private checkLoaded;
32
35
  loadMapApi(): Promise<boolean>;
36
+ lastMousePosition: Position | null;
33
37
  initializingMap(divElement: HTMLDivElement): Promise<MapVendorType>;
34
38
  destroyMap: () => void;
35
39
  private fromGoogleBounds;
@@ -39,4 +43,9 @@ export declare class GoogleMintMapController extends MintMapController {
39
43
  setZoomLevel(zoom: number): void;
40
44
  getCenter(): Position;
41
45
  setCenter(position: Position): void;
46
+ private eventMap;
47
+ addEventListener(eventName: MapEventName, callback: EventCallback<EventParamType>): void;
48
+ removeEventListener(eventName: MapEventName, callback: EventCallback<EventParamType>): void;
49
+ removeAllEventListener(eventName?: MapEventName | undefined): void;
50
+ private clearEventListener;
42
51
  }
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var tslib = require('tslib');
6
6
  var MintMapController = require('../core/MintMapController.js');
7
7
  var waiting = require('../core/util/waiting.js');
8
+ var MapEventTypes = require('../types/MapEventTypes.js');
8
9
  var MapTypes = require('../types/MapTypes.js');
9
10
 
10
11
  var GoogleMintMapController =
@@ -20,13 +21,18 @@ function (_super) {
20
21
  _this.scriptUrl = 'https://maps.googleapis.com/maps/api/js';
21
22
  _this.scriptModules = ['marker']; //'drawing' , 'geometry' , 'journeySharing' , 'localContext' , 'places' , 'visualization']
22
23
 
24
+ _this.mapEvent = new MapEventTypes.MapEvent();
25
+ _this.mapUIEvent = new MapEventTypes.MapUIEvent();
23
26
  _this.polylineEvents = ['mouseover', 'mouseout'];
24
27
  _this.polygonEvents = ['mouseover', 'mouseout'];
25
28
  _this.markerEvents = ['click', 'mouseover', 'mouseout'];
26
29
  _this.dragged = false;
30
+ _this.lastMousePosition = null;
27
31
 
28
32
  _this.destroyMap = function () {
29
33
  try {
34
+ _this.removeAllEventListener();
35
+
30
36
  _this.map && google.maps.event.clearInstanceListeners(_this.map);
31
37
  } catch (e) {
32
38
  console.log('google map destroy error', e);
@@ -34,6 +40,12 @@ function (_super) {
34
40
 
35
41
  };
36
42
 
43
+ _this.eventMap = new Map(); //google 은 zoomstart 가 없으므로 zoom_changed 로 대체 (하지만 zooming 되는 내내 여러번 호출됨)
44
+ //나중에 naver 와 마찬가지로 zoomstart 1번 zoom_changed 1번 호출되도록 바꾸는것 고려중
45
+
46
+ _this.mapEvent.ZOOMSTART = 'zoom_changed';
47
+ Object.freeze(_this.mapEvent);
48
+ Object.freeze(_this.mapUIEvent);
37
49
  return _this; // console.log(`${this.type} controller loadded`);
38
50
  }
39
51
 
@@ -473,6 +485,20 @@ function (_super) {
473
485
  pos.offset = new MapTypes.Offset(e.pixel.x, e.pixel.y);
474
486
 
475
487
  _this.mapProps.onClick(pos);
488
+ }); //@ts-ignore
489
+
490
+ map.addListener('mousedown', function (e) {
491
+ // console.log('map click', e)
492
+ var pos = new MapTypes.Position(e.latLng.lat(), e.latLng.lng());
493
+ pos.offset = new MapTypes.Offset(e.pixel.x, e.pixel.y);
494
+ _this.lastMousePosition = pos;
495
+ }); //@ts-ignore
496
+
497
+ map.addListener('mouseup', function (e) {
498
+ // console.log('map click', e)
499
+ var pos = new MapTypes.Position(e.latLng.lat(), e.latLng.lng());
500
+ pos.offset = new MapTypes.Offset(e.pixel.x, e.pixel.y);
501
+ _this.lastMousePosition = pos;
476
502
  });
477
503
  map.addListener('mousemove', function (e) {
478
504
  if (!_this.mapProps.onMouseMove) return;
@@ -541,6 +567,114 @@ function (_super) {
541
567
  (_a = this.map) === null || _a === void 0 ? void 0 : _a.setCenter(position);
542
568
  };
543
569
 
570
+ GoogleMintMapController.prototype.addEventListener = function (eventName, callback) {
571
+ var _this = this;
572
+
573
+ if (!this.map) {
574
+ return;
575
+ }
576
+
577
+ var googleEventName = this.mapEvent.get(eventName) || this.mapUIEvent.get(eventName);
578
+
579
+ if (!googleEventName) {
580
+ console.warn("MapEventName ".concat(eventName, " is not supported"));
581
+ return;
582
+ } // console.log(`${eventName} add`);
583
+
584
+
585
+ var map = this.eventMap.get(eventName);
586
+
587
+ if (!map) {
588
+ map = new Map();
589
+ this.eventMap.set(eventName, map);
590
+ }
591
+
592
+ var wrappingCallback = function (e) {
593
+ if (eventName in _this.mapEvent) {
594
+ var bounds = _this.getCurrBounds();
595
+
596
+ var param = {
597
+ name: eventName,
598
+ mapType: 'google',
599
+ vendorEventName: googleEventName,
600
+ param: {
601
+ bounds: bounds,
602
+ center: bounds.getCenter(),
603
+ zoomLevel: _this.getZoomLevel()
604
+ }
605
+ };
606
+ callback(param);
607
+ } else if (eventName in _this.mapUIEvent) {
608
+ if (eventName.startsWith('DRAG')) console.log(eventName, e);
609
+ var position = null;
610
+
611
+ if (e) {
612
+ position = new MapTypes.Position(e.latLng.lat(), e.latLng.lng());
613
+ position.offset = new MapTypes.Offset(e.pixel.x, e.pixel.y);
614
+ } else {
615
+ position = _this.lastMousePosition;
616
+ }
617
+
618
+ var param = {
619
+ name: eventName,
620
+ mapType: 'google',
621
+ vendorEventName: googleEventName,
622
+ param: {
623
+ position: position,
624
+ offset: position === null || position === void 0 ? void 0 : position.offset
625
+ }
626
+ };
627
+ callback(param);
628
+ }
629
+ };
630
+
631
+ var googleEventListener = this.map.addListener(googleEventName, wrappingCallback);
632
+ map.set(callback, googleEventListener);
633
+ };
634
+
635
+ GoogleMintMapController.prototype.removeEventListener = function (eventName, callback) {
636
+ var map = this.eventMap.get(eventName);
637
+
638
+ if (map) {
639
+ var listenerMap = this.eventMap.get(eventName);
640
+
641
+ if (listenerMap) {
642
+ var googleEventListener = listenerMap.get(callback);
643
+
644
+ if (googleEventListener) {
645
+ // console.log(`${eventName} remove`);
646
+ google.maps.event.removeListener(googleEventListener);
647
+ listenerMap.delete(callback);
648
+ }
649
+ }
650
+ }
651
+ };
652
+
653
+ GoogleMintMapController.prototype.removeAllEventListener = function (eventName) {
654
+ var _this = this;
655
+
656
+ if (eventName) {
657
+ this.clearEventListener(eventName);
658
+ } else {
659
+ this.eventMap.forEach(function (_map, eventName) {
660
+ _this.clearEventListener(eventName);
661
+ });
662
+ this.eventMap.clear();
663
+ }
664
+ };
665
+
666
+ GoogleMintMapController.prototype.clearEventListener = function (eventName) {
667
+ var map = this.eventMap.get(eventName);
668
+
669
+ if (map) {
670
+ map.forEach(function (googleEventListener) {
671
+ // console.log(`${eventName} remove`);
672
+ google.maps.event.removeListener(googleEventListener);
673
+ });
674
+ this.eventMap.delete(eventName);
675
+ }
676
+ };
677
+
544
678
  return GoogleMintMapController;
545
679
  }(MintMapController.MintMapController);
546
680
 
@@ -5,11 +5,14 @@ import { MapType, MapVendorType } from "../types/CommonTypes";
5
5
  import { Drawable, Marker, MarkerOptions, Polygon, PolygonOptions, Polyline, PolylineOptions } from "../types/MapDrawables";
6
6
  import { Bounds, Position } from "../types/MapTypes";
7
7
  import { MintMapProps } from "../types/MintMapProps";
8
+ import { EventCallback, EventParamType, MapEvent, MapEventName, MapUIEvent } from "../types/MapEventTypes";
8
9
  export declare class KakaoMintMapController extends MintMapController {
9
10
  type: MapType;
10
11
  map: kakao.maps.Map | null;
11
12
  scriptUrl: string;
12
13
  scriptModules: string[];
14
+ protected mapEvent: MapEvent;
15
+ protected mapUIEvent: MapUIEvent;
13
16
  markerPool?: ObjectPool<kakao.maps.CustomOverlay>;
14
17
  constructor(props: MintMapProps);
15
18
  private initMarkerPool;
@@ -45,4 +48,9 @@ export declare class KakaoMintMapController extends MintMapController {
45
48
  setCenter(position: Position): void;
46
49
  private positionToLatLng;
47
50
  private latLngToPosition;
51
+ private eventMap;
52
+ addEventListener(eventName: MapEventName, callback: EventCallback<EventParamType>): void;
53
+ removeEventListener(eventName: MapEventName, callback: EventCallback<EventParamType>): void;
54
+ removeAllEventListener(eventName?: MapEventName | undefined): void;
55
+ private clearEventListener;
48
56
  }