@mint-ui/map 0.5.10-beta → 0.5.12-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
 
@@ -32,7 +32,8 @@ function SVGCircle(_a) {
32
32
  pointerEvents: "none",
33
33
  width: boxSize,
34
34
  height: boxSize,
35
- viewBox: "0 0 ".concat(boxSize, " ").concat(boxSize)
35
+ viewBox: "0 0 ".concat(boxSize, " ").concat(boxSize),
36
+ overflow: 'visible'
36
37
  }, svgProperties), React__default["default"].createElement("circle", tslib.__assign({
37
38
  pointerEvents: "visiblepainted",
38
39
  cx: radius,
@@ -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",
@@ -37,7 +37,8 @@ function SVGRect(_a) {
37
37
  pointerEvents: "none",
38
38
  width: width,
39
39
  height: height,
40
- viewBox: "0 0 ".concat(viewWidth.current, " ").concat(viewHeight)
40
+ viewBox: "0 0 ".concat(viewWidth.current, " ").concat(viewHeight),
41
+ overflow: 'visible'
41
42
  }, svgProperties), React__default["default"].createElement("rect", tslib.__assign({
42
43
  pointerEvents: "visiblepainted",
43
44
  x: "0",
@@ -2,8 +2,8 @@ import { PropsWithChildren } from "react";
2
2
  declare type AlignHorizontal = 'left' | 'right' | 'center';
3
3
  declare type AlignVertical = 'top' | 'bottom' | 'center';
4
4
  export interface MapControlWrapperProps {
5
- width?: number | string;
6
- height?: number | string;
5
+ width?: string | number;
6
+ height?: string | number;
7
7
  positionHorizontal?: AlignHorizontal;
8
8
  positionVertical?: AlignVertical;
9
9
  }
@@ -12,48 +12,6 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
12
12
  var classNames__default = /*#__PURE__*/_interopDefaultLegacy(classNames);
13
13
 
14
14
  var cn = classNames__default["default"].bind(MintMapWrapper_module);
15
-
16
- var getSizeString = function (size) {
17
- return typeof size === 'string' ? size.replace(/ /g, '') : "".concat(size, "px");
18
- };
19
-
20
- var getAlignPosition = function (value, align) {
21
- if (typeof value === 'string') {
22
- var trimmed = value.replace(/ /g, '');
23
- console.log('trimmed:', trimmed);
24
- var isPercent = trimmed.endsWith('%');
25
-
26
- if (!isPercent && !trimmed.endsWith('px')) {
27
- throw new Error("Size [".concat(value, "] is not valid string value."));
28
- }
29
-
30
- var numberPart = isPercent ? trimmed.substring(0, trimmed.length - 2) : trimmed.substring(0, trimmed.length - 3);
31
- var unit = isPercent ? '%' : 'px';
32
- var numberValue = Number(numberPart);
33
-
34
- if (isNaN(numberValue)) {
35
- throw new Error("Size [".concat(value, "] is not valid % or pixel number value."));
36
- }
37
-
38
- if (align === 'center') {
39
- return "calc(50% - ".concat(numberValue / 2).concat(unit, ")");
40
- } else if (align === 'right' || align === 'bottom') {
41
- return "calc(100% - ".concat(numberValue).concat(unit, ")");
42
- } else {
43
- return '0px';
44
- }
45
- } else if (typeof value === 'number') {
46
- if (align === 'center') {
47
- return "calc(50% - ".concat(value / 2, "px)");
48
- } else if (align === 'right' || align === 'bottom') {
49
- return "calc(100% - ".concat(value, "px)");
50
- } else {
51
- return '0px';
52
- }
53
- }
54
-
55
- throw new Error("Size [".concat(value, "] is not valid. (Should be % or pixel number)"));
56
- };
57
15
  /**
58
16
  * Mint Map 컴포넌트
59
17
  *
@@ -62,26 +20,29 @@ var getAlignPosition = function (value, align) {
62
20
  * @returns {JSX.Element} JSX
63
21
  */
64
22
 
65
-
66
23
  function MapControlWrapper(_a) {
67
24
  var _b = _a.width,
68
- width = _b === void 0 ? 100 : _b,
25
+ width = _b === void 0 ? 'fit-content' : _b,
69
26
  _c = _a.height,
70
- height = _c === void 0 ? 40 : _c,
27
+ height = _c === void 0 ? 'fit-content' : _c,
71
28
  _d = _a.positionHorizontal,
72
29
  positionHorizontal = _d === void 0 ? 'left' : _d,
73
30
  _e = _a.positionVertical,
74
31
  positionVertical = _e === void 0 ? 'top' : _e,
75
32
  children = _a.children;
76
33
  return React__default["default"].createElement("div", {
34
+ className: cn('mint-map-control-wrapper-container'),
35
+ style: {
36
+ justifyContent: positionHorizontal === 'center' ? 'center' : positionHorizontal === 'right' ? 'flex-end' : 'flex-start',
37
+ alignItems: positionVertical === 'center' ? 'center' : positionVertical === 'bottom' ? 'flex-end' : 'flex-start'
38
+ }
39
+ }, React__default["default"].createElement("div", {
77
40
  className: cn('mint-map-control-wrapper'),
78
41
  style: {
79
- width: getSizeString(width),
80
- height: getSizeString(height),
81
- left: getAlignPosition(width, positionHorizontal),
82
- top: getAlignPosition(height, positionVertical)
42
+ width: width,
43
+ height: height
83
44
  }
84
- }, children);
45
+ }, children));
85
46
  }
86
47
 
87
48
  exports.MapControlWrapper = MapControlWrapper;
@@ -6,8 +6,8 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
6
6
 
7
7
  var styleInject__default = /*#__PURE__*/_interopDefaultLegacy(styleInject);
8
8
 
9
- var css_248z = ".MintMapWrapper-module_mint-map-control-wrapper__DDb4y {\n position: absolute;\n z-index: 101;\n}\n\n.MintMapWrapper-module_mint-map-overlay-wrapper__Jn4wV {\n position: absolute;\n z-index: 1;\n}";
10
- var styles = {"mint-map-control-wrapper":"MintMapWrapper-module_mint-map-control-wrapper__DDb4y","mint-map-overlay-wrapper":"MintMapWrapper-module_mint-map-overlay-wrapper__Jn4wV"};
9
+ var css_248z = ".MintMapWrapper-module_mint-map-control-wrapper-container__DONh7 {\n position: absolute;\n width: 100%;\n height: 100%;\n display: flex;\n pointer-events: none;\n z-index: 101;\n}\n\n.MintMapWrapper-module_mint-map-control-wrapper__DDb4y {\n pointer-events: auto;\n}\n\n.MintMapWrapper-module_mint-map-overlay-wrapper__Jn4wV {\n position: absolute;\n z-index: 1;\n}";
10
+ var styles = {"mint-map-control-wrapper-container":"MintMapWrapper-module_mint-map-control-wrapper-container__DONh7","mint-map-control-wrapper":"MintMapWrapper-module_mint-map-control-wrapper__DDb4y","mint-map-overlay-wrapper":"MintMapWrapper-module_mint-map-overlay-wrapper__Jn4wV"};
11
11
  styleInject__default["default"](css_248z);
12
12
 
13
13
  module.exports = styles;
@@ -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;