@mint-ui/map 0.5.10-beta → 0.5.11-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.
@@ -9,6 +9,7 @@ export interface CircleMarkerProps {
9
9
  zIndex?: number;
10
10
  svgProperties?: React.SVGProps<SVGSVGElement>;
11
11
  shapeProperties?: React.SVGProps<SVGCircleElement>;
12
+ debug?: boolean | undefined;
12
13
  debugLabel?: string;
13
14
  }
14
15
  /**
@@ -18,4 +19,4 @@ export interface CircleMarkerProps {
18
19
  *
19
20
  * @returns {JSX.Element} JSX
20
21
  */
21
- export declare function CircleMarker({ children, center, radius, radiusUnit, background, svgProperties, shapeProperties, visible, zIndex, debugLabel, }: PropsWithChildren<CircleMarkerProps>): JSX.Element;
22
+ export declare function CircleMarker({ children, center, radius, radiusUnit, background, svgProperties, shapeProperties, visible, zIndex, debug, debugLabel, }: PropsWithChildren<CircleMarkerProps>): JSX.Element;
@@ -42,6 +42,7 @@ function CircleMarker(_a) {
42
42
  _f = _a.visible,
43
43
  visible = _f === void 0 ? true : _f,
44
44
  zIndex = _a.zIndex,
45
+ debug = _a.debug,
45
46
  debugLabel = _a.debugLabel; //controller
46
47
 
47
48
  var controller = MintMapProvider.useMintMapController(); //zoom start event
@@ -127,6 +128,7 @@ function CircleMarker(_a) {
127
128
  visible: visible,
128
129
  disablePointerEvent: true,
129
130
  zIndex: zIndex,
131
+ debug: debug,
130
132
  debugLabel: debugLabel
131
133
  }, mapVisible && React__default["default"].createElement(SVGCircle.SVGCircle, {
132
134
  radius: computedRadius,
@@ -15,6 +15,7 @@ export interface PolygonMarkerProps {
15
15
  mode?: 'POLYGON' | 'POLYLINE';
16
16
  svgProperties?: React.SVGProps<SVGSVGElement>;
17
17
  shapeProperties?: React.SVGProps<SVGPathElement>;
18
+ debug?: boolean | undefined;
18
19
  debugLabel?: string;
19
20
  }
20
21
  /**
@@ -24,4 +25,4 @@ export interface PolygonMarkerProps {
24
25
  *
25
26
  * @returns {JSX.Element} JSX
26
27
  */
27
- export declare function PolygonMarker({ children, position, background, innerPositions, simplifyPath, simplifyTolerance, lastReapeated, svgProperties, shapeProperties, visible, zIndex, mode, debugLabel, }: PropsWithChildren<PolygonMarkerProps>): JSX.Element;
28
+ export declare function PolygonMarker({ children, position, background, innerPositions, simplifyPath, simplifyTolerance, lastReapeated, svgProperties, shapeProperties, visible, zIndex, mode, debug, debugLabel, }: PropsWithChildren<PolygonMarkerProps>): JSX.Element;
@@ -2,6 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var tslib = require('tslib');
5
6
  var React = require('react');
6
7
  var MintMapProvider = require('../../provider/MintMapProvider.js');
7
8
  var MapMarkerWrapper = require('../../wrapper/MapMarkerWrapper.js');
@@ -11,7 +12,6 @@ var MapTypes = require('../../../types/MapTypes.js');
11
12
  require('../../../types/MapEventTypes.js');
12
13
  require('../../util/animation.js');
13
14
  require('../../util/geo.js');
14
- require('tslib');
15
15
  var polygon = require('../../util/polygon.js');
16
16
  require('../../util/status.js');
17
17
  var NaverMintMapController = require('../../../naver/NaverMintMapController.js');
@@ -48,6 +48,7 @@ function PolygonMarker(_a) {
48
48
  zIndex = _a.zIndex,
49
49
  _h = _a.mode,
50
50
  mode = _h === void 0 ? 'POLYGON' : _h,
51
+ debug = _a.debug,
51
52
  debugLabel = _a.debugLabel; //controller
52
53
 
53
54
  var controller = MintMapProvider.useMintMapController(); //zoom start event
@@ -61,8 +62,11 @@ function PolygonMarker(_a) {
61
62
 
62
63
  if (zoomLevel.current !== newZoomLevel) {
63
64
  zoomLevel.current = newZoomLevel;
64
- renderPolygonBase();
65
- setMapVisible(true);
65
+ calculatePolygonBase();
66
+ setTimeout(function () {
67
+ setMapVisible(true);
68
+ renderPolygon();
69
+ }, 50);
66
70
  }
67
71
  }, []);
68
72
  var zoomLevel = React.useRef(controller.getZoomLevel());
@@ -99,7 +103,6 @@ function PolygonMarker(_a) {
99
103
  }); //polygon 생성 effect
100
104
 
101
105
  React.useEffect(function () {
102
- // console.log('polygon changed');
103
106
  polygonPropsRef.current = {
104
107
  position: position,
105
108
  innerPositions: innerPositions,
@@ -107,14 +110,19 @@ function PolygonMarker(_a) {
107
110
  simplifyTolerance: simplifyTolerance,
108
111
  lastReapeated: lastReapeated
109
112
  };
110
- renderPolygonBase();
113
+ calculatePolygonBase(true); // console.log('PolygonMarker useEffect');
111
114
  }, [position, innerPositions, simplifyPath, simplifyTolerance, lastReapeated]); //render
112
115
 
113
116
  var _m = React.useState(true),
114
117
  mapVisible = _m[0],
115
118
  setMapVisible = _m[1];
116
119
 
117
- var renderPolygonBase = React.useCallback(function () {
120
+ var renderInfoRef = React.useRef({
121
+ offset: [],
122
+ innerOffset: [],
123
+ startPosition: undefined
124
+ });
125
+ var calculatePolygonBase = React.useCallback(function (renderNow) {
118
126
  // console.log('renderPolygonBase');
119
127
  var _a = polygonPropsRef.current,
120
128
  position = _a.position,
@@ -138,7 +146,7 @@ function PolygonMarker(_a) {
138
146
  return controller instanceof NaverMintMapController.NaverMintMapController ? controller.naverPositionToOffset(pos) : controller.positionToOffset(pos);
139
147
  });
140
148
  var simplified = simplifyPath ? polygon.PolygonCalculator.simplifyPoints(offsets, simplifyTolerance, lastReapeated) : offsets;
141
- setOffsets(simplified); //inner path
149
+ renderInfoRef.current.offset = simplified; //inner path
142
150
 
143
151
  var innerPath = [];
144
152
 
@@ -152,27 +160,39 @@ function PolygonMarker(_a) {
152
160
  var simplified_1 = simplifyPath ? polygon.PolygonCalculator.simplifyPoints(offsets_1, simplifyTolerance, lastReapeated) : offsets_1;
153
161
  innerPath.push(simplified_1);
154
162
  }
163
+ }
155
164
 
156
- setInnerOffsets(innerPath);
157
- } //start point
158
-
165
+ renderInfoRef.current.innerOffset = innerPath; //start point
159
166
 
160
167
  var startPosition = maxLat && minLng ? new MapTypes.Position(maxLat, minLng) : undefined;
161
- setPolygonStart(startPosition);
168
+ renderInfoRef.current.startPosition = startPosition;
169
+
170
+ if (renderNow) {
171
+ renderPolygon();
172
+ }
173
+ }, []);
174
+ var renderPolygon = React.useCallback(function () {
175
+ // console.log('render', renderInfoRef.current.offset);
176
+ setOffsets(renderInfoRef.current.offset);
177
+ setInnerOffsets(renderInfoRef.current.innerOffset);
178
+ setPolygonStart(renderInfoRef.current.startPosition);
162
179
  }, []);
163
180
  return React__default["default"].createElement(React__default["default"].Fragment, null, polygonStart && React__default["default"].createElement(MapMarkerWrapper.MapMarkerWrapper, {
164
181
  position: polygonStart,
165
182
  visible: visible,
166
183
  disablePointerEvent: true,
167
184
  zIndex: zIndex,
185
+ debug: debug,
168
186
  debugLabel: debugLabel
169
- }, mapVisible && React__default["default"].createElement(SVGPolygon.SVGPolygon, {
187
+ }, React__default["default"].createElement(SVGPolygon.SVGPolygon, {
170
188
  path: offsets,
171
189
  innerPath: innerOffsets,
172
190
  mode: mode,
173
191
  background: background,
174
192
  shapeProperties: shapeProperties,
175
- svgProperties: svgProperties
193
+ svgProperties: tslib.__assign({
194
+ display: mapVisible ? '' : 'none'
195
+ }, svgProperties)
176
196
  }, children)));
177
197
  }
178
198
 
@@ -4,6 +4,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var tslib = require('tslib');
6
6
  var React = require('react');
7
+ require('../../../../types/MapDrawables.js');
8
+ var MapTypes = require('../../../../types/MapTypes.js');
9
+ require('../../../../types/MapEventTypes.js');
7
10
 
8
11
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
12
 
@@ -63,39 +66,33 @@ function SVGPolygon(_a) {
63
66
  containerHeight: height
64
67
  };
65
68
  }, []);
66
- var getD = React.useCallback(function (_a) {
67
- var path = _a.path,
68
- containerLeft = _a.containerLeft,
69
- containerTop = _a.containerTop,
70
- mode = _a.mode;
71
- var left = containerLeft;
72
- var top = containerTop;
69
+ var getD = React.useCallback(function (path, innerPath, mode) {
73
70
  var isPolygon = mode === 'POLYGON';
74
71
  var out = ''; //path
75
72
 
76
- out += getLine(path, left, top, isPolygon); //inner path
73
+ out += getLine(path, isPolygon); //inner path
77
74
 
78
75
  for (var _i = 0, innerPath_1 = innerPath; _i < innerPath_1.length; _i++) {
79
76
  var inner = innerPath_1[_i];
80
- out += ' ' + getLine(inner, left, top, isPolygon);
77
+ out += ' ' + getLine(inner, isPolygon);
81
78
  }
82
79
 
83
80
  return out;
84
81
  }, []);
85
- var getLine = React.useCallback(function (path, offsetLeft, offsetTop, closePath) {
82
+ var getLine = React.useCallback(function (path, isPolygon) {
86
83
  return path.map(function (offset, idx) {
87
84
  if (idx === 0) {
88
- return "M ".concat(offset.x - offsetLeft, ",").concat(offset.y - offsetTop);
85
+ return "M ".concat(offset.x, ",").concat(offset.y);
89
86
  } else if (idx === 1) {
90
- return "L ".concat(offset.x - offsetLeft, ",").concat(offset.y - offsetTop);
87
+ return "L ".concat(offset.x, ",").concat(offset.y);
91
88
  } else {
92
89
  if (offset.equals(path[idx - 1])) {
93
90
  return '';
94
91
  } else {
95
- return "".concat(offset.x - offsetLeft, ",").concat(offset.y - offsetTop);
92
+ return "".concat(offset.x, ",").concat(offset.y);
96
93
  }
97
94
  }
98
- }).join(' ') + " ".concat(closePath ? 'Z' : '');
95
+ }).join(' ') + " ".concat(isPolygon ? 'Z' : "".concat(path[0].x, ",").concat(path[0].y));
99
96
  }, []);
100
97
 
101
98
  var _g = React.useState(0),
@@ -110,28 +107,26 @@ function SVGPolygon(_a) {
110
107
  d = _j[0],
111
108
  setD = _j[1];
112
109
 
110
+ var _k = React.useState(new MapTypes.Offset(0, 0)),
111
+ polygonAreaInfo = _k[0],
112
+ setPolygonAreaInfo = _k[1];
113
+
113
114
  React.useEffect(function () {
114
115
  var info = getPolygonInfo(path);
116
+ setPolygonAreaInfo(new MapTypes.Offset(Math.round(info.containerLeft), Math.round(info.containerTop)));
115
117
  setWidth(Math.round(info.containerWidth));
116
118
  setHeight(Math.round(info.containerHeight));
117
- setD(getD(tslib.__assign(tslib.__assign({}, info), {
118
- path: path,
119
- innerPath: innerPath,
120
- mode: mode
121
- })));
122
- }, [path, innerPath]);
119
+ setD(getD(path, innerPath, mode));
120
+ }, [path, innerPath, mode]);
123
121
  return React__default["default"].createElement(React__default["default"].Fragment, null, React__default["default"].createElement("svg", tslib.__assign({
124
122
  pointerEvents: "none",
123
+ overflow: 'visible',
125
124
  width: width,
126
125
  height: height,
127
- viewBox: "0 0 ".concat(width, " ").concat(height)
126
+ viewBox: "".concat(polygonAreaInfo.x, " ").concat(polygonAreaInfo.y, " ").concat(width, " ").concat(height)
128
127
  }, svgProperties), React__default["default"].createElement("path", tslib.__assign({
129
128
  fillRule: "evenodd",
130
129
  pointerEvents: "visiblepainted",
131
- x: "0",
132
- y: "0",
133
- width: width,
134
- height: height,
135
130
  fill: mode === 'POLYLINE' ? 'none' : background,
136
131
  stroke: mode === 'POLYLINE' ? 'black' : 'green',
137
132
  strokeLinejoin: "miter",
@@ -123,7 +123,7 @@ function () {
123
123
  };
124
124
 
125
125
  Bounds.prototype.intersects = function (positions) {
126
- return polygon.PolygonCalculator.intersects([this.nw, this.se], positions);
126
+ return polygon.PolygonCalculator.intersects([this.nw, this.sw, this.se, this.ne, this.nw], positions);
127
127
  };
128
128
 
129
129
  return Bounds;
package/dist/index.es.js CHANGED
@@ -592,7 +592,7 @@ function () {
592
592
  };
593
593
 
594
594
  Bounds.prototype.intersects = function (positions) {
595
- return PolygonCalculator.intersects([this.nw, this.se], positions);
595
+ return PolygonCalculator.intersects([this.nw, this.sw, this.se, this.ne, this.nw], positions);
596
596
  };
597
597
 
598
598
  return Bounds;
@@ -3744,6 +3744,86 @@ function SVGCircle(_a) {
3744
3744
  }, children));
3745
3745
  }
3746
3746
 
3747
+ var Drawable =
3748
+ /** @class */
3749
+ function () {
3750
+ function Drawable() {}
3751
+
3752
+ return Drawable;
3753
+ }();
3754
+
3755
+ var Marker =
3756
+ /** @class */
3757
+ function (_super) {
3758
+ __extends(Marker, _super);
3759
+ /**
3760
+ * 지도에 표시할 마커정보
3761
+ */
3762
+
3763
+
3764
+ function Marker(options) {
3765
+ var _this = _super.call(this) || this;
3766
+
3767
+ _this.options = options;
3768
+ return _this;
3769
+ }
3770
+
3771
+ return Marker;
3772
+ }(Drawable);
3773
+
3774
+ var Polyline =
3775
+ /** @class */
3776
+ function (_super) {
3777
+ __extends(Polyline, _super);
3778
+ /**
3779
+ * 지도에 표시할 폴리곤정보
3780
+ */
3781
+
3782
+
3783
+ function Polyline(options) {
3784
+ var _this = _super.call(this) || this;
3785
+
3786
+ _this.options = options;
3787
+ return _this;
3788
+ }
3789
+
3790
+ return Polyline;
3791
+ }(Drawable);
3792
+
3793
+ var Polygon =
3794
+ /** @class */
3795
+ function (_super) {
3796
+ __extends(Polygon, _super);
3797
+ /**
3798
+ * 지도에 표시할 폴리곤정보
3799
+ */
3800
+
3801
+
3802
+ function Polygon(options) {
3803
+ var _this = _super.call(this) || this;
3804
+
3805
+ _this.options = options;
3806
+ return _this;
3807
+ }
3808
+ /**
3809
+ * 폴리곤의 중점을 구한다.
3810
+ */
3811
+
3812
+
3813
+ Polygon.prototype.getCenter = function () {
3814
+ if (Array.isArray(this.options.position) && this.options.position.length > 0) {
3815
+ var paths = this.options.position.map(function (elem) {
3816
+ return elem instanceof Position ? elem : new Position(elem[0], elem[1]);
3817
+ });
3818
+ return PolygonCalculator.getCenter(paths);
3819
+ }
3820
+
3821
+ throw new Error('center 를 찾을 수 없습니다.');
3822
+ };
3823
+
3824
+ return Polygon;
3825
+ }(Drawable);
3826
+
3747
3827
  function SVGPolygon(_a) {
3748
3828
  var path = _a.path,
3749
3829
  _b = _a.innerPath,
@@ -3798,39 +3878,33 @@ function SVGPolygon(_a) {
3798
3878
  containerHeight: height
3799
3879
  };
3800
3880
  }, []);
3801
- var getD = useCallback(function (_a) {
3802
- var path = _a.path,
3803
- containerLeft = _a.containerLeft,
3804
- containerTop = _a.containerTop,
3805
- mode = _a.mode;
3806
- var left = containerLeft;
3807
- var top = containerTop;
3881
+ var getD = useCallback(function (path, innerPath, mode) {
3808
3882
  var isPolygon = mode === 'POLYGON';
3809
3883
  var out = ''; //path
3810
3884
 
3811
- out += getLine(path, left, top, isPolygon); //inner path
3885
+ out += getLine(path, isPolygon); //inner path
3812
3886
 
3813
3887
  for (var _i = 0, innerPath_1 = innerPath; _i < innerPath_1.length; _i++) {
3814
3888
  var inner = innerPath_1[_i];
3815
- out += ' ' + getLine(inner, left, top, isPolygon);
3889
+ out += ' ' + getLine(inner, isPolygon);
3816
3890
  }
3817
3891
 
3818
3892
  return out;
3819
3893
  }, []);
3820
- var getLine = useCallback(function (path, offsetLeft, offsetTop, closePath) {
3894
+ var getLine = useCallback(function (path, isPolygon) {
3821
3895
  return path.map(function (offset, idx) {
3822
3896
  if (idx === 0) {
3823
- return "M ".concat(offset.x - offsetLeft, ",").concat(offset.y - offsetTop);
3897
+ return "M ".concat(offset.x, ",").concat(offset.y);
3824
3898
  } else if (idx === 1) {
3825
- return "L ".concat(offset.x - offsetLeft, ",").concat(offset.y - offsetTop);
3899
+ return "L ".concat(offset.x, ",").concat(offset.y);
3826
3900
  } else {
3827
3901
  if (offset.equals(path[idx - 1])) {
3828
3902
  return '';
3829
3903
  } else {
3830
- return "".concat(offset.x - offsetLeft, ",").concat(offset.y - offsetTop);
3904
+ return "".concat(offset.x, ",").concat(offset.y);
3831
3905
  }
3832
3906
  }
3833
- }).join(' ') + " ".concat(closePath ? 'Z' : '');
3907
+ }).join(' ') + " ".concat(isPolygon ? 'Z' : "".concat(path[0].x, ",").concat(path[0].y));
3834
3908
  }, []);
3835
3909
 
3836
3910
  var _g = useState(0),
@@ -3845,28 +3919,26 @@ function SVGPolygon(_a) {
3845
3919
  d = _j[0],
3846
3920
  setD = _j[1];
3847
3921
 
3922
+ var _k = useState(new Offset(0, 0)),
3923
+ polygonAreaInfo = _k[0],
3924
+ setPolygonAreaInfo = _k[1];
3925
+
3848
3926
  useEffect(function () {
3849
3927
  var info = getPolygonInfo(path);
3928
+ setPolygonAreaInfo(new Offset(Math.round(info.containerLeft), Math.round(info.containerTop)));
3850
3929
  setWidth(Math.round(info.containerWidth));
3851
3930
  setHeight(Math.round(info.containerHeight));
3852
- setD(getD(__assign(__assign({}, info), {
3853
- path: path,
3854
- innerPath: innerPath,
3855
- mode: mode
3856
- })));
3857
- }, [path, innerPath]);
3931
+ setD(getD(path, innerPath, mode));
3932
+ }, [path, innerPath, mode]);
3858
3933
  return React.createElement(React.Fragment, null, React.createElement("svg", __assign({
3859
3934
  pointerEvents: "none",
3935
+ overflow: 'visible',
3860
3936
  width: width,
3861
3937
  height: height,
3862
- viewBox: "0 0 ".concat(width, " ").concat(height)
3938
+ viewBox: "".concat(polygonAreaInfo.x, " ").concat(polygonAreaInfo.y, " ").concat(width, " ").concat(height)
3863
3939
  }, svgProperties), React.createElement("path", __assign({
3864
3940
  fillRule: "evenodd",
3865
3941
  pointerEvents: "visiblepainted",
3866
- x: "0",
3867
- y: "0",
3868
- width: width,
3869
- height: height,
3870
3942
  fill: mode === 'POLYLINE' ? 'none' : background,
3871
3943
  stroke: mode === 'POLYLINE' ? 'black' : 'green',
3872
3944
  strokeLinejoin: "miter",
@@ -3932,86 +4004,6 @@ function SVGRect(_a) {
3932
4004
  }, children));
3933
4005
  }
3934
4006
 
3935
- var Drawable =
3936
- /** @class */
3937
- function () {
3938
- function Drawable() {}
3939
-
3940
- return Drawable;
3941
- }();
3942
-
3943
- var Marker =
3944
- /** @class */
3945
- function (_super) {
3946
- __extends(Marker, _super);
3947
- /**
3948
- * 지도에 표시할 마커정보
3949
- */
3950
-
3951
-
3952
- function Marker(options) {
3953
- var _this = _super.call(this) || this;
3954
-
3955
- _this.options = options;
3956
- return _this;
3957
- }
3958
-
3959
- return Marker;
3960
- }(Drawable);
3961
-
3962
- var Polyline =
3963
- /** @class */
3964
- function (_super) {
3965
- __extends(Polyline, _super);
3966
- /**
3967
- * 지도에 표시할 폴리곤정보
3968
- */
3969
-
3970
-
3971
- function Polyline(options) {
3972
- var _this = _super.call(this) || this;
3973
-
3974
- _this.options = options;
3975
- return _this;
3976
- }
3977
-
3978
- return Polyline;
3979
- }(Drawable);
3980
-
3981
- var Polygon =
3982
- /** @class */
3983
- function (_super) {
3984
- __extends(Polygon, _super);
3985
- /**
3986
- * 지도에 표시할 폴리곤정보
3987
- */
3988
-
3989
-
3990
- function Polygon(options) {
3991
- var _this = _super.call(this) || this;
3992
-
3993
- _this.options = options;
3994
- return _this;
3995
- }
3996
- /**
3997
- * 폴리곤의 중점을 구한다.
3998
- */
3999
-
4000
-
4001
- Polygon.prototype.getCenter = function () {
4002
- if (Array.isArray(this.options.position) && this.options.position.length > 0) {
4003
- var paths = this.options.position.map(function (elem) {
4004
- return elem instanceof Position ? elem : new Position(elem[0], elem[1]);
4005
- });
4006
- return PolygonCalculator.getCenter(paths);
4007
- }
4008
-
4009
- throw new Error('center 를 찾을 수 없습니다.');
4010
- };
4011
-
4012
- return Polygon;
4013
- }(Drawable);
4014
-
4015
4007
  function nextIndex(array, currIdx) {
4016
4008
  var next = currIdx + 1;
4017
4009
 
@@ -4355,6 +4347,7 @@ function CircleMarker(_a) {
4355
4347
  _f = _a.visible,
4356
4348
  visible = _f === void 0 ? true : _f,
4357
4349
  zIndex = _a.zIndex,
4350
+ debug = _a.debug,
4358
4351
  debugLabel = _a.debugLabel; //controller
4359
4352
 
4360
4353
  var controller = useMintMapController(); //zoom start event
@@ -4440,6 +4433,7 @@ function CircleMarker(_a) {
4440
4433
  visible: visible,
4441
4434
  disablePointerEvent: true,
4442
4435
  zIndex: zIndex,
4436
+ debug: debug,
4443
4437
  debugLabel: debugLabel
4444
4438
  }, mapVisible && React.createElement(SVGCircle, {
4445
4439
  radius: computedRadius,
@@ -4479,6 +4473,7 @@ function PolygonMarker(_a) {
4479
4473
  zIndex = _a.zIndex,
4480
4474
  _h = _a.mode,
4481
4475
  mode = _h === void 0 ? 'POLYGON' : _h,
4476
+ debug = _a.debug,
4482
4477
  debugLabel = _a.debugLabel; //controller
4483
4478
 
4484
4479
  var controller = useMintMapController(); //zoom start event
@@ -4492,8 +4487,11 @@ function PolygonMarker(_a) {
4492
4487
 
4493
4488
  if (zoomLevel.current !== newZoomLevel) {
4494
4489
  zoomLevel.current = newZoomLevel;
4495
- renderPolygonBase();
4496
- setMapVisible(true);
4490
+ calculatePolygonBase();
4491
+ setTimeout(function () {
4492
+ setMapVisible(true);
4493
+ renderPolygon();
4494
+ }, 50);
4497
4495
  }
4498
4496
  }, []);
4499
4497
  var zoomLevel = useRef(controller.getZoomLevel());
@@ -4530,7 +4528,6 @@ function PolygonMarker(_a) {
4530
4528
  }); //polygon 생성 effect
4531
4529
 
4532
4530
  useEffect(function () {
4533
- // console.log('polygon changed');
4534
4531
  polygonPropsRef.current = {
4535
4532
  position: position,
4536
4533
  innerPositions: innerPositions,
@@ -4538,14 +4535,19 @@ function PolygonMarker(_a) {
4538
4535
  simplifyTolerance: simplifyTolerance,
4539
4536
  lastReapeated: lastReapeated
4540
4537
  };
4541
- renderPolygonBase();
4538
+ calculatePolygonBase(true); // console.log('PolygonMarker useEffect');
4542
4539
  }, [position, innerPositions, simplifyPath, simplifyTolerance, lastReapeated]); //render
4543
4540
 
4544
4541
  var _m = useState(true),
4545
4542
  mapVisible = _m[0],
4546
4543
  setMapVisible = _m[1];
4547
4544
 
4548
- var renderPolygonBase = useCallback(function () {
4545
+ var renderInfoRef = useRef({
4546
+ offset: [],
4547
+ innerOffset: [],
4548
+ startPosition: undefined
4549
+ });
4550
+ var calculatePolygonBase = useCallback(function (renderNow) {
4549
4551
  // console.log('renderPolygonBase');
4550
4552
  var _a = polygonPropsRef.current,
4551
4553
  position = _a.position,
@@ -4569,7 +4571,7 @@ function PolygonMarker(_a) {
4569
4571
  return controller instanceof NaverMintMapController ? controller.naverPositionToOffset(pos) : controller.positionToOffset(pos);
4570
4572
  });
4571
4573
  var simplified = simplifyPath ? PolygonCalculator.simplifyPoints(offsets, simplifyTolerance, lastReapeated) : offsets;
4572
- setOffsets(simplified); //inner path
4574
+ renderInfoRef.current.offset = simplified; //inner path
4573
4575
 
4574
4576
  var innerPath = [];
4575
4577
 
@@ -4583,27 +4585,39 @@ function PolygonMarker(_a) {
4583
4585
  var simplified_1 = simplifyPath ? PolygonCalculator.simplifyPoints(offsets_1, simplifyTolerance, lastReapeated) : offsets_1;
4584
4586
  innerPath.push(simplified_1);
4585
4587
  }
4588
+ }
4586
4589
 
4587
- setInnerOffsets(innerPath);
4588
- } //start point
4589
-
4590
+ renderInfoRef.current.innerOffset = innerPath; //start point
4590
4591
 
4591
4592
  var startPosition = maxLat && minLng ? new Position(maxLat, minLng) : undefined;
4592
- setPolygonStart(startPosition);
4593
+ renderInfoRef.current.startPosition = startPosition;
4594
+
4595
+ if (renderNow) {
4596
+ renderPolygon();
4597
+ }
4598
+ }, []);
4599
+ var renderPolygon = useCallback(function () {
4600
+ // console.log('render', renderInfoRef.current.offset);
4601
+ setOffsets(renderInfoRef.current.offset);
4602
+ setInnerOffsets(renderInfoRef.current.innerOffset);
4603
+ setPolygonStart(renderInfoRef.current.startPosition);
4593
4604
  }, []);
4594
4605
  return React.createElement(React.Fragment, null, polygonStart && React.createElement(MapMarkerWrapper, {
4595
4606
  position: polygonStart,
4596
4607
  visible: visible,
4597
4608
  disablePointerEvent: true,
4598
4609
  zIndex: zIndex,
4610
+ debug: debug,
4599
4611
  debugLabel: debugLabel
4600
- }, mapVisible && React.createElement(SVGPolygon, {
4612
+ }, React.createElement(SVGPolygon, {
4601
4613
  path: offsets,
4602
4614
  innerPath: innerOffsets,
4603
4615
  mode: mode,
4604
4616
  background: background,
4605
4617
  shapeProperties: shapeProperties,
4606
- svgProperties: svgProperties
4618
+ svgProperties: __assign({
4619
+ display: mapVisible ? '' : 'none'
4620
+ }, svgProperties)
4607
4621
  }, children)));
4608
4622
  }
4609
4623
 
package/dist/index.umd.js CHANGED
@@ -596,7 +596,7 @@
596
596
  };
597
597
 
598
598
  Bounds.prototype.intersects = function (positions) {
599
- return PolygonCalculator.intersects([this.nw, this.se], positions);
599
+ return PolygonCalculator.intersects([this.nw, this.sw, this.se, this.ne, this.nw], positions);
600
600
  };
601
601
 
602
602
  return Bounds;
@@ -3748,6 +3748,86 @@
3748
3748
  }, children));
3749
3749
  }
3750
3750
 
3751
+ var Drawable =
3752
+ /** @class */
3753
+ function () {
3754
+ function Drawable() {}
3755
+
3756
+ return Drawable;
3757
+ }();
3758
+
3759
+ var Marker =
3760
+ /** @class */
3761
+ function (_super) {
3762
+ tslib.__extends(Marker, _super);
3763
+ /**
3764
+ * 지도에 표시할 마커정보
3765
+ */
3766
+
3767
+
3768
+ function Marker(options) {
3769
+ var _this = _super.call(this) || this;
3770
+
3771
+ _this.options = options;
3772
+ return _this;
3773
+ }
3774
+
3775
+ return Marker;
3776
+ }(Drawable);
3777
+
3778
+ var Polyline =
3779
+ /** @class */
3780
+ function (_super) {
3781
+ tslib.__extends(Polyline, _super);
3782
+ /**
3783
+ * 지도에 표시할 폴리곤정보
3784
+ */
3785
+
3786
+
3787
+ function Polyline(options) {
3788
+ var _this = _super.call(this) || this;
3789
+
3790
+ _this.options = options;
3791
+ return _this;
3792
+ }
3793
+
3794
+ return Polyline;
3795
+ }(Drawable);
3796
+
3797
+ var Polygon =
3798
+ /** @class */
3799
+ function (_super) {
3800
+ tslib.__extends(Polygon, _super);
3801
+ /**
3802
+ * 지도에 표시할 폴리곤정보
3803
+ */
3804
+
3805
+
3806
+ function Polygon(options) {
3807
+ var _this = _super.call(this) || this;
3808
+
3809
+ _this.options = options;
3810
+ return _this;
3811
+ }
3812
+ /**
3813
+ * 폴리곤의 중점을 구한다.
3814
+ */
3815
+
3816
+
3817
+ Polygon.prototype.getCenter = function () {
3818
+ if (Array.isArray(this.options.position) && this.options.position.length > 0) {
3819
+ var paths = this.options.position.map(function (elem) {
3820
+ return elem instanceof Position ? elem : new Position(elem[0], elem[1]);
3821
+ });
3822
+ return PolygonCalculator.getCenter(paths);
3823
+ }
3824
+
3825
+ throw new Error('center 를 찾을 수 없습니다.');
3826
+ };
3827
+
3828
+ return Polygon;
3829
+ }(Drawable);
3830
+
3751
3831
  function SVGPolygon(_a) {
3752
3832
  var path = _a.path,
3753
3833
  _b = _a.innerPath,
@@ -3802,39 +3882,33 @@
3802
3882
  containerHeight: height
3803
3883
  };
3804
3884
  }, []);
3805
- var getD = React.useCallback(function (_a) {
3806
- var path = _a.path,
3807
- containerLeft = _a.containerLeft,
3808
- containerTop = _a.containerTop,
3809
- mode = _a.mode;
3810
- var left = containerLeft;
3811
- var top = containerTop;
3885
+ var getD = React.useCallback(function (path, innerPath, mode) {
3812
3886
  var isPolygon = mode === 'POLYGON';
3813
3887
  var out = ''; //path
3814
3888
 
3815
- out += getLine(path, left, top, isPolygon); //inner path
3889
+ out += getLine(path, isPolygon); //inner path
3816
3890
 
3817
3891
  for (var _i = 0, innerPath_1 = innerPath; _i < innerPath_1.length; _i++) {
3818
3892
  var inner = innerPath_1[_i];
3819
- out += ' ' + getLine(inner, left, top, isPolygon);
3893
+ out += ' ' + getLine(inner, isPolygon);
3820
3894
  }
3821
3895
 
3822
3896
  return out;
3823
3897
  }, []);
3824
- var getLine = React.useCallback(function (path, offsetLeft, offsetTop, closePath) {
3898
+ var getLine = React.useCallback(function (path, isPolygon) {
3825
3899
  return path.map(function (offset, idx) {
3826
3900
  if (idx === 0) {
3827
- return "M ".concat(offset.x - offsetLeft, ",").concat(offset.y - offsetTop);
3901
+ return "M ".concat(offset.x, ",").concat(offset.y);
3828
3902
  } else if (idx === 1) {
3829
- return "L ".concat(offset.x - offsetLeft, ",").concat(offset.y - offsetTop);
3903
+ return "L ".concat(offset.x, ",").concat(offset.y);
3830
3904
  } else {
3831
3905
  if (offset.equals(path[idx - 1])) {
3832
3906
  return '';
3833
3907
  } else {
3834
- return "".concat(offset.x - offsetLeft, ",").concat(offset.y - offsetTop);
3908
+ return "".concat(offset.x, ",").concat(offset.y);
3835
3909
  }
3836
3910
  }
3837
- }).join(' ') + " ".concat(closePath ? 'Z' : '');
3911
+ }).join(' ') + " ".concat(isPolygon ? 'Z' : "".concat(path[0].x, ",").concat(path[0].y));
3838
3912
  }, []);
3839
3913
 
3840
3914
  var _g = React.useState(0),
@@ -3849,28 +3923,26 @@
3849
3923
  d = _j[0],
3850
3924
  setD = _j[1];
3851
3925
 
3926
+ var _k = React.useState(new Offset(0, 0)),
3927
+ polygonAreaInfo = _k[0],
3928
+ setPolygonAreaInfo = _k[1];
3929
+
3852
3930
  React.useEffect(function () {
3853
3931
  var info = getPolygonInfo(path);
3932
+ setPolygonAreaInfo(new Offset(Math.round(info.containerLeft), Math.round(info.containerTop)));
3854
3933
  setWidth(Math.round(info.containerWidth));
3855
3934
  setHeight(Math.round(info.containerHeight));
3856
- setD(getD(tslib.__assign(tslib.__assign({}, info), {
3857
- path: path,
3858
- innerPath: innerPath,
3859
- mode: mode
3860
- })));
3861
- }, [path, innerPath]);
3935
+ setD(getD(path, innerPath, mode));
3936
+ }, [path, innerPath, mode]);
3862
3937
  return React__default["default"].createElement(React__default["default"].Fragment, null, React__default["default"].createElement("svg", tslib.__assign({
3863
3938
  pointerEvents: "none",
3939
+ overflow: 'visible',
3864
3940
  width: width,
3865
3941
  height: height,
3866
- viewBox: "0 0 ".concat(width, " ").concat(height)
3942
+ viewBox: "".concat(polygonAreaInfo.x, " ").concat(polygonAreaInfo.y, " ").concat(width, " ").concat(height)
3867
3943
  }, svgProperties), React__default["default"].createElement("path", tslib.__assign({
3868
3944
  fillRule: "evenodd",
3869
3945
  pointerEvents: "visiblepainted",
3870
- x: "0",
3871
- y: "0",
3872
- width: width,
3873
- height: height,
3874
3946
  fill: mode === 'POLYLINE' ? 'none' : background,
3875
3947
  stroke: mode === 'POLYLINE' ? 'black' : 'green',
3876
3948
  strokeLinejoin: "miter",
@@ -3936,86 +4008,6 @@
3936
4008
  }, children));
3937
4009
  }
3938
4010
 
3939
- var Drawable =
3940
- /** @class */
3941
- function () {
3942
- function Drawable() {}
3943
-
3944
- return Drawable;
3945
- }();
3946
-
3947
- var Marker =
3948
- /** @class */
3949
- function (_super) {
3950
- tslib.__extends(Marker, _super);
3951
- /**
3952
- * 지도에 표시할 마커정보
3953
- */
3954
-
3955
-
3956
- function Marker(options) {
3957
- var _this = _super.call(this) || this;
3958
-
3959
- _this.options = options;
3960
- return _this;
3961
- }
3962
-
3963
- return Marker;
3964
- }(Drawable);
3965
-
3966
- var Polyline =
3967
- /** @class */
3968
- function (_super) {
3969
- tslib.__extends(Polyline, _super);
3970
- /**
3971
- * 지도에 표시할 폴리곤정보
3972
- */
3973
-
3974
-
3975
- function Polyline(options) {
3976
- var _this = _super.call(this) || this;
3977
-
3978
- _this.options = options;
3979
- return _this;
3980
- }
3981
-
3982
- return Polyline;
3983
- }(Drawable);
3984
-
3985
- var Polygon =
3986
- /** @class */
3987
- function (_super) {
3988
- tslib.__extends(Polygon, _super);
3989
- /**
3990
- * 지도에 표시할 폴리곤정보
3991
- */
3992
-
3993
-
3994
- function Polygon(options) {
3995
- var _this = _super.call(this) || this;
3996
-
3997
- _this.options = options;
3998
- return _this;
3999
- }
4000
- /**
4001
- * 폴리곤의 중점을 구한다.
4002
- */
4003
-
4004
-
4005
- Polygon.prototype.getCenter = function () {
4006
- if (Array.isArray(this.options.position) && this.options.position.length > 0) {
4007
- var paths = this.options.position.map(function (elem) {
4008
- return elem instanceof Position ? elem : new Position(elem[0], elem[1]);
4009
- });
4010
- return PolygonCalculator.getCenter(paths);
4011
- }
4012
-
4013
- throw new Error('center 를 찾을 수 없습니다.');
4014
- };
4015
-
4016
- return Polygon;
4017
- }(Drawable);
4018
-
4019
4011
  function nextIndex(array, currIdx) {
4020
4012
  var next = currIdx + 1;
4021
4013
 
@@ -4359,6 +4351,7 @@
4359
4351
  _f = _a.visible,
4360
4352
  visible = _f === void 0 ? true : _f,
4361
4353
  zIndex = _a.zIndex,
4354
+ debug = _a.debug,
4362
4355
  debugLabel = _a.debugLabel; //controller
4363
4356
 
4364
4357
  var controller = useMintMapController(); //zoom start event
@@ -4444,6 +4437,7 @@
4444
4437
  visible: visible,
4445
4438
  disablePointerEvent: true,
4446
4439
  zIndex: zIndex,
4440
+ debug: debug,
4447
4441
  debugLabel: debugLabel
4448
4442
  }, mapVisible && React__default["default"].createElement(SVGCircle, {
4449
4443
  radius: computedRadius,
@@ -4483,6 +4477,7 @@
4483
4477
  zIndex = _a.zIndex,
4484
4478
  _h = _a.mode,
4485
4479
  mode = _h === void 0 ? 'POLYGON' : _h,
4480
+ debug = _a.debug,
4486
4481
  debugLabel = _a.debugLabel; //controller
4487
4482
 
4488
4483
  var controller = useMintMapController(); //zoom start event
@@ -4496,8 +4491,11 @@
4496
4491
 
4497
4492
  if (zoomLevel.current !== newZoomLevel) {
4498
4493
  zoomLevel.current = newZoomLevel;
4499
- renderPolygonBase();
4500
- setMapVisible(true);
4494
+ calculatePolygonBase();
4495
+ setTimeout(function () {
4496
+ setMapVisible(true);
4497
+ renderPolygon();
4498
+ }, 50);
4501
4499
  }
4502
4500
  }, []);
4503
4501
  var zoomLevel = React.useRef(controller.getZoomLevel());
@@ -4534,7 +4532,6 @@
4534
4532
  }); //polygon 생성 effect
4535
4533
 
4536
4534
  React.useEffect(function () {
4537
- // console.log('polygon changed');
4538
4535
  polygonPropsRef.current = {
4539
4536
  position: position,
4540
4537
  innerPositions: innerPositions,
@@ -4542,14 +4539,19 @@
4542
4539
  simplifyTolerance: simplifyTolerance,
4543
4540
  lastReapeated: lastReapeated
4544
4541
  };
4545
- renderPolygonBase();
4542
+ calculatePolygonBase(true); // console.log('PolygonMarker useEffect');
4546
4543
  }, [position, innerPositions, simplifyPath, simplifyTolerance, lastReapeated]); //render
4547
4544
 
4548
4545
  var _m = React.useState(true),
4549
4546
  mapVisible = _m[0],
4550
4547
  setMapVisible = _m[1];
4551
4548
 
4552
- var renderPolygonBase = React.useCallback(function () {
4549
+ var renderInfoRef = React.useRef({
4550
+ offset: [],
4551
+ innerOffset: [],
4552
+ startPosition: undefined
4553
+ });
4554
+ var calculatePolygonBase = React.useCallback(function (renderNow) {
4553
4555
  // console.log('renderPolygonBase');
4554
4556
  var _a = polygonPropsRef.current,
4555
4557
  position = _a.position,
@@ -4573,7 +4575,7 @@
4573
4575
  return controller instanceof NaverMintMapController ? controller.naverPositionToOffset(pos) : controller.positionToOffset(pos);
4574
4576
  });
4575
4577
  var simplified = simplifyPath ? PolygonCalculator.simplifyPoints(offsets, simplifyTolerance, lastReapeated) : offsets;
4576
- setOffsets(simplified); //inner path
4578
+ renderInfoRef.current.offset = simplified; //inner path
4577
4579
 
4578
4580
  var innerPath = [];
4579
4581
 
@@ -4587,27 +4589,39 @@
4587
4589
  var simplified_1 = simplifyPath ? PolygonCalculator.simplifyPoints(offsets_1, simplifyTolerance, lastReapeated) : offsets_1;
4588
4590
  innerPath.push(simplified_1);
4589
4591
  }
4592
+ }
4590
4593
 
4591
- setInnerOffsets(innerPath);
4592
- } //start point
4593
-
4594
+ renderInfoRef.current.innerOffset = innerPath; //start point
4594
4595
 
4595
4596
  var startPosition = maxLat && minLng ? new Position(maxLat, minLng) : undefined;
4596
- setPolygonStart(startPosition);
4597
+ renderInfoRef.current.startPosition = startPosition;
4598
+
4599
+ if (renderNow) {
4600
+ renderPolygon();
4601
+ }
4602
+ }, []);
4603
+ var renderPolygon = React.useCallback(function () {
4604
+ // console.log('render', renderInfoRef.current.offset);
4605
+ setOffsets(renderInfoRef.current.offset);
4606
+ setInnerOffsets(renderInfoRef.current.innerOffset);
4607
+ setPolygonStart(renderInfoRef.current.startPosition);
4597
4608
  }, []);
4598
4609
  return React__default["default"].createElement(React__default["default"].Fragment, null, polygonStart && React__default["default"].createElement(MapMarkerWrapper, {
4599
4610
  position: polygonStart,
4600
4611
  visible: visible,
4601
4612
  disablePointerEvent: true,
4602
4613
  zIndex: zIndex,
4614
+ debug: debug,
4603
4615
  debugLabel: debugLabel
4604
- }, mapVisible && React__default["default"].createElement(SVGPolygon, {
4616
+ }, React__default["default"].createElement(SVGPolygon, {
4605
4617
  path: offsets,
4606
4618
  innerPath: innerOffsets,
4607
4619
  mode: mode,
4608
4620
  background: background,
4609
4621
  shapeProperties: shapeProperties,
4610
- svgProperties: svgProperties
4622
+ svgProperties: tslib.__assign({
4623
+ display: mapVisible ? '' : 'none'
4624
+ }, svgProperties)
4611
4625
  }, children)));
4612
4626
  }
4613
4627
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mint-ui/map",
3
- "version": "0.5.10-beta",
3
+ "version": "0.5.11-beta",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.es.js",
6
6
  "browser": "./dist/index.umd.js",