@mint-ui/map 0.9.2-beta → 0.9.2-beta-test2

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.
@@ -0,0 +1,18 @@
1
+ import React from "react";
2
+ import { MarkerOptions, Offset, Position } from "../../../types";
3
+ export interface CanvasMarkerRendererParams<T> {
4
+ context: CanvasRenderingContext2D;
5
+ offset: Offset[];
6
+ payload?: CanvasMarkerData<T>;
7
+ }
8
+ export interface CanvasMarkerOption {
9
+ position?: Position[];
10
+ visible?: boolean;
11
+ }
12
+ export declare type CanvasMarkerData<T> = T & CanvasMarkerOption;
13
+ export declare type CanvasMarkerRenderFunction<T> = (params: CanvasMarkerRendererParams<T>) => void;
14
+ export interface CanvasMarkerProps<T> extends Pick<MarkerOptions, 'zIndex' | 'anchor' | 'visible'> {
15
+ renderer: CanvasMarkerRenderFunction<T>;
16
+ data: CanvasMarkerData<T>[];
17
+ }
18
+ export declare function CanvasMarker<T>({ renderer, data, ...options }: CanvasMarkerProps<T>): React.ReactPortal;
@@ -0,0 +1,161 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var tslib = require('tslib');
6
+ var React = require('react');
7
+ var MintMapProvider = require('../../provider/MintMapProvider.js');
8
+ var MapDrawables = require('../../../types/MapDrawables.js');
9
+ require('../../../types/MapTypes.js');
10
+ require('../../../types/MapEventTypes.js');
11
+ var reactDom = require('react-dom');
12
+ var canvasUtil = require('./draw/canvas-util.js');
13
+
14
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
15
+
16
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
17
+
18
+ function CanvasMarker(_a) {
19
+ var renderer = _a.renderer,
20
+ data = _a.data,
21
+ options = tslib.__rest(_a, ["renderer", "data"]); //controller
22
+
23
+
24
+ var controller = MintMapProvider.useMintMapController(); //element
25
+
26
+ var divRef = React.useRef(document.createElement('div'));
27
+ var divElement = divRef.current; //canvas container ref
28
+
29
+ var containerRef = React.useRef(null); //canvas ref
30
+
31
+ var canvasRef = React.useRef(null); //canvas context
32
+
33
+ var contextRef = React.useRef(); //marker
34
+
35
+ var markerRef = React.useRef(); //create object
36
+
37
+ React.useEffect(function () {
38
+ divElement.style.width = 'fit-content';
39
+ divElement.style.pointerEvents = 'none';
40
+ return function () {
41
+ if (markerRef.current) {
42
+ controller.clearDrawable(markerRef.current);
43
+ markerRef.current = undefined;
44
+ }
45
+ };
46
+ }, []); //create / update object
47
+
48
+ React.useEffect(function () {
49
+ if (options) {
50
+ var bounds = controller.getCurrBounds();
51
+
52
+ var markerOptions = tslib.__assign({
53
+ position: bounds.nw
54
+ }, options);
55
+
56
+ if (markerRef.current) {
57
+ controller.updateMarker(markerRef.current, markerOptions);
58
+ } else {
59
+ markerRef.current = new MapDrawables.Marker(markerOptions);
60
+ markerRef.current.element = divElement;
61
+ controller.createMarker(markerRef.current); //disablePointerEvent 처리
62
+
63
+ if (divElement.parentElement) {
64
+ divElement.style.pointerEvents = 'none';
65
+ divElement.parentElement.style.pointerEvents = 'none';
66
+ } //z-index 처리
67
+
68
+
69
+ if (options.zIndex !== undefined) {
70
+ controller.setMarkerZIndex(markerRef.current, options.zIndex);
71
+ }
72
+ }
73
+ }
74
+ }, [options]);
75
+
76
+ var handleIdle = function () {
77
+ // 클리어
78
+ canvasUtil.clearRect(canvasRef.current, contextRef.current); // 마커 이동
79
+
80
+ var bounds = controller.getCurrBounds();
81
+
82
+ var markerOptions = tslib.__assign({
83
+ position: bounds.nw
84
+ }, options);
85
+
86
+ markerRef.current && controller.updateMarker(markerRef.current, markerOptions); // 렌더링
87
+
88
+ canvasUtil.renderMain(controller, rendererRef.current, containerRef.current, canvasRef.current, contextRef.current, dataRef.current);
89
+ };
90
+
91
+ var handleZoomStart = function () {
92
+ containerRef.current && (containerRef.current.style.visibility = 'hidden');
93
+ };
94
+
95
+ var handleZoomEnd = function () {
96
+ containerRef.current && (containerRef.current.style.visibility = '');
97
+ }; //initialize
98
+
99
+
100
+ React.useEffect(function () {
101
+ var resizeObserver;
102
+
103
+ if (canvasRef.current && containerRef.current) {
104
+ // 리사이즈 처리
105
+ resizeObserver = new ResizeObserver(function () {
106
+ // 클리어
107
+ canvasUtil.clearRect(canvasRef.current, contextRef.current); // 스케일링
108
+
109
+ canvasRef.current && contextRef.current && canvasUtil.scaleCanvas(controller, canvasRef.current, contextRef.current); // 렌더링
110
+
111
+ canvasUtil.renderMain(controller, rendererRef.current, containerRef.current, canvasRef.current, contextRef.current, dataRef.current);
112
+ });
113
+ resizeObserver.observe(controller.mapDivElement); // IDLE 이벤트 등록
114
+
115
+ controller.addEventListener('IDLE', handleIdle); // 줌 처리
116
+
117
+ controller.addEventListener('ZOOMSTART', handleZoomStart);
118
+ controller.addEventListener('ZOOM_CHANGED', handleZoomEnd); // 2d 컨텍스트
119
+
120
+ contextRef.current = canvasRef.current.getContext('2d'); // 스케일링
121
+
122
+ if (contextRef.current) {
123
+ canvasUtil.scaleCanvas(controller, canvasRef.current, contextRef.current);
124
+ }
125
+ }
126
+
127
+ return function () {
128
+ resizeObserver && resizeObserver.disconnect();
129
+ controller.removeEventListener('IDLE', handleIdle);
130
+ controller.removeEventListener('ZOOMSTART', handleZoomStart);
131
+ controller.removeEventListener('ZOOM_CHANGED', handleZoomEnd);
132
+ };
133
+ }, []); // data ref
134
+
135
+ var dataRef = React.useRef(data);
136
+ React.useEffect(function () {
137
+ dataRef.current = data;
138
+ }, [data]); // renderer ref
139
+
140
+ var rendererRef = React.useRef(renderer);
141
+ React.useEffect(function () {
142
+ rendererRef.current = renderer;
143
+ }, [renderer]);
144
+ canvasUtil.renderMain(controller, renderer, containerRef.current, canvasRef.current, contextRef.current, data);
145
+ return reactDom.createPortal(React__default["default"].createElement("div", {
146
+ ref: containerRef,
147
+ style: {
148
+ position: 'absolute',
149
+ width: '100%',
150
+ height: '100%',
151
+ pointerEvents: 'none'
152
+ }
153
+ }, React__default["default"].createElement("canvas", {
154
+ ref: canvasRef,
155
+ style: {
156
+ pointerEvents: 'revert-layer'
157
+ }
158
+ })), divElement);
159
+ }
160
+
161
+ exports.CanvasMarker = CanvasMarker;
@@ -0,0 +1,5 @@
1
+ import { MintMapController } from "../../../MintMapController";
2
+ import { CanvasMarkerData, CanvasMarkerRenderFunction } from "../CanvasMarker";
3
+ export declare const scaleCanvas: (controller: MintMapController, canvasElement: HTMLCanvasElement, canvasContext: CanvasRenderingContext2D) => void;
4
+ export declare const clearRect: (canvas: HTMLCanvasElement | null, context?: CanvasRenderingContext2D | null) => boolean;
5
+ export declare function renderMain<T>(controller: MintMapController, renderer: CanvasMarkerRenderFunction<T>, container?: HTMLDivElement | null, canvas?: HTMLCanvasElement | null, context?: CanvasRenderingContext2D | null, data?: CanvasMarkerData<T>[]): void;
@@ -0,0 +1,54 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ //scaling
6
+ var scaleCanvas = function (controller, canvasElement, canvasContext) {
7
+ var devicePixelRatio = window.devicePixelRatio;
8
+ var container = controller.mapDivElement;
9
+ var width = container.offsetWidth;
10
+ var height = container.offsetHeight;
11
+ canvasElement.width = width * devicePixelRatio;
12
+ canvasElement.height = height * devicePixelRatio;
13
+ canvasElement.style.width = "".concat(width, "px");
14
+ canvasElement.style.height = "".concat(height, "px");
15
+ canvasContext.scale(devicePixelRatio, devicePixelRatio);
16
+ }; //clear rect
17
+
18
+ var clearRect = function (canvas, context) {
19
+ if (canvas && context) {
20
+ context.clearRect(canvas.width * -1, canvas.height * -1, canvas.width * 3, canvas.height * 3);
21
+ }
22
+
23
+ return true;
24
+ };
25
+ function renderMain(controller, renderer, container, canvas, context, data) {
26
+ if (!container || !canvas || !context || !data) {
27
+ return;
28
+ } //all clear
29
+
30
+
31
+ clearRect(canvas, context); //draw
32
+
33
+ data.forEach(function (item) {
34
+ var _a; // 그리기 대상이면
35
+
36
+
37
+ if (item.visible === undefined || item.visible) {
38
+ //위치 변환
39
+ var offset = ((_a = item.position) === null || _a === void 0 ? void 0 : _a.map(function (pos) {
40
+ return controller.positionToOffset(pos);
41
+ })) || []; //그리기
42
+
43
+ renderer({
44
+ context: context,
45
+ offset: offset,
46
+ payload: item
47
+ });
48
+ }
49
+ });
50
+ }
51
+
52
+ exports.clearRect = clearRect;
53
+ exports.renderMain = renderMain;
54
+ exports.scaleCanvas = scaleCanvas;
@@ -0,0 +1 @@
1
+ export * from './CanvasMarker';
@@ -1,3 +1,4 @@
1
1
  export * from './shapes';
2
+ export * from './canvas';
2
3
  export * from './MapBuildingProjection';
3
4
  export * from './MapLoadingComponents';
package/dist/index.es.js CHANGED
@@ -4830,6 +4830,196 @@ function PolygonMarker(_a) {
4830
4830
  }, children)));
4831
4831
  }
4832
4832
 
4833
+ //scaling
4834
+ var scaleCanvas = function (controller, canvasElement, canvasContext) {
4835
+ var devicePixelRatio = window.devicePixelRatio;
4836
+ var container = controller.mapDivElement;
4837
+ var width = container.offsetWidth;
4838
+ var height = container.offsetHeight;
4839
+ canvasElement.width = width * devicePixelRatio;
4840
+ canvasElement.height = height * devicePixelRatio;
4841
+ canvasElement.style.width = "".concat(width, "px");
4842
+ canvasElement.style.height = "".concat(height, "px");
4843
+ canvasContext.scale(devicePixelRatio, devicePixelRatio);
4844
+ }; //clear rect
4845
+
4846
+ var clearRect = function (canvas, context) {
4847
+ if (canvas && context) {
4848
+ context.clearRect(canvas.width * -1, canvas.height * -1, canvas.width * 3, canvas.height * 3);
4849
+ }
4850
+
4851
+ return true;
4852
+ };
4853
+ function renderMain(controller, renderer, container, canvas, context, data) {
4854
+ if (!container || !canvas || !context || !data) {
4855
+ return;
4856
+ } //all clear
4857
+
4858
+
4859
+ clearRect(canvas, context); //draw
4860
+
4861
+ data.forEach(function (item) {
4862
+ var _a; // 그리기 대상이면
4863
+
4864
+
4865
+ if (item.visible === undefined || item.visible) {
4866
+ //위치 변환
4867
+ var offset = ((_a = item.position) === null || _a === void 0 ? void 0 : _a.map(function (pos) {
4868
+ return controller.positionToOffset(pos);
4869
+ })) || []; //그리기
4870
+
4871
+ renderer({
4872
+ context: context,
4873
+ offset: offset,
4874
+ payload: item
4875
+ });
4876
+ }
4877
+ });
4878
+ }
4879
+
4880
+ function CanvasMarker(_a) {
4881
+ var renderer = _a.renderer,
4882
+ data = _a.data,
4883
+ options = __rest(_a, ["renderer", "data"]); //controller
4884
+
4885
+
4886
+ var controller = useMintMapController(); //element
4887
+
4888
+ var divRef = useRef(document.createElement('div'));
4889
+ var divElement = divRef.current; //canvas container ref
4890
+
4891
+ var containerRef = useRef(null); //canvas ref
4892
+
4893
+ var canvasRef = useRef(null); //canvas context
4894
+
4895
+ var contextRef = useRef(); //marker
4896
+
4897
+ var markerRef = useRef(); //create object
4898
+
4899
+ useEffect(function () {
4900
+ divElement.style.width = 'fit-content';
4901
+ divElement.style.pointerEvents = 'none';
4902
+ return function () {
4903
+ if (markerRef.current) {
4904
+ controller.clearDrawable(markerRef.current);
4905
+ markerRef.current = undefined;
4906
+ }
4907
+ };
4908
+ }, []); //create / update object
4909
+
4910
+ useEffect(function () {
4911
+ if (options) {
4912
+ var bounds = controller.getCurrBounds();
4913
+
4914
+ var markerOptions = __assign({
4915
+ position: bounds.nw
4916
+ }, options);
4917
+
4918
+ if (markerRef.current) {
4919
+ controller.updateMarker(markerRef.current, markerOptions);
4920
+ } else {
4921
+ markerRef.current = new Marker(markerOptions);
4922
+ markerRef.current.element = divElement;
4923
+ controller.createMarker(markerRef.current); //disablePointerEvent 처리
4924
+
4925
+ if (divElement.parentElement) {
4926
+ divElement.style.pointerEvents = 'none';
4927
+ divElement.parentElement.style.pointerEvents = 'none';
4928
+ } //z-index 처리
4929
+
4930
+
4931
+ if (options.zIndex !== undefined) {
4932
+ controller.setMarkerZIndex(markerRef.current, options.zIndex);
4933
+ }
4934
+ }
4935
+ }
4936
+ }, [options]);
4937
+
4938
+ var handleIdle = function () {
4939
+ // 클리어
4940
+ clearRect(canvasRef.current, contextRef.current); // 마커 이동
4941
+
4942
+ var bounds = controller.getCurrBounds();
4943
+
4944
+ var markerOptions = __assign({
4945
+ position: bounds.nw
4946
+ }, options);
4947
+
4948
+ markerRef.current && controller.updateMarker(markerRef.current, markerOptions); // 렌더링
4949
+
4950
+ renderMain(controller, rendererRef.current, containerRef.current, canvasRef.current, contextRef.current, dataRef.current);
4951
+ };
4952
+
4953
+ var handleZoomStart = function () {
4954
+ containerRef.current && (containerRef.current.style.visibility = 'hidden');
4955
+ };
4956
+
4957
+ var handleZoomEnd = function () {
4958
+ containerRef.current && (containerRef.current.style.visibility = '');
4959
+ }; //initialize
4960
+
4961
+
4962
+ useEffect(function () {
4963
+ var resizeObserver;
4964
+
4965
+ if (canvasRef.current && containerRef.current) {
4966
+ // 리사이즈 처리
4967
+ resizeObserver = new ResizeObserver(function () {
4968
+ // 클리어
4969
+ clearRect(canvasRef.current, contextRef.current); // 스케일링
4970
+
4971
+ canvasRef.current && contextRef.current && scaleCanvas(controller, canvasRef.current, contextRef.current); // 렌더링
4972
+
4973
+ renderMain(controller, rendererRef.current, containerRef.current, canvasRef.current, contextRef.current, dataRef.current);
4974
+ });
4975
+ resizeObserver.observe(controller.mapDivElement); // IDLE 이벤트 등록
4976
+
4977
+ controller.addEventListener('IDLE', handleIdle); // 줌 처리
4978
+
4979
+ controller.addEventListener('ZOOMSTART', handleZoomStart);
4980
+ controller.addEventListener('ZOOM_CHANGED', handleZoomEnd); // 2d 컨텍스트
4981
+
4982
+ contextRef.current = canvasRef.current.getContext('2d'); // 스케일링
4983
+
4984
+ if (contextRef.current) {
4985
+ scaleCanvas(controller, canvasRef.current, contextRef.current);
4986
+ }
4987
+ }
4988
+
4989
+ return function () {
4990
+ resizeObserver && resizeObserver.disconnect();
4991
+ controller.removeEventListener('IDLE', handleIdle);
4992
+ controller.removeEventListener('ZOOMSTART', handleZoomStart);
4993
+ controller.removeEventListener('ZOOM_CHANGED', handleZoomEnd);
4994
+ };
4995
+ }, []); // data ref
4996
+
4997
+ var dataRef = useRef(data);
4998
+ useEffect(function () {
4999
+ dataRef.current = data;
5000
+ }, [data]); // renderer ref
5001
+
5002
+ var rendererRef = useRef(renderer);
5003
+ useEffect(function () {
5004
+ rendererRef.current = renderer;
5005
+ }, [renderer]);
5006
+ renderMain(controller, renderer, containerRef.current, canvasRef.current, contextRef.current, data);
5007
+ return createPortal(React.createElement("div", {
5008
+ ref: containerRef,
5009
+ style: {
5010
+ position: 'absolute',
5011
+ width: '100%',
5012
+ height: '100%',
5013
+ pointerEvents: 'none'
5014
+ }
5015
+ }, React.createElement("canvas", {
5016
+ ref: canvasRef,
5017
+ style: {
5018
+ pointerEvents: 'revert-layer'
5019
+ }
5020
+ })), divElement);
5021
+ }
5022
+
4833
5023
  /**
4834
5024
  * Mint Map 컴포넌트
4835
5025
  *
@@ -5702,4 +5892,4 @@ function MapCanvasMarkerWrapper(_props) {
5702
5892
  return React.createElement(React.Fragment, null);
5703
5893
  }
5704
5894
 
5705
- export { AnimationPlayer, Bounds, CircleMarker, Drawable, GeoCalulator, GoogleMintMapController, MapBuildingProjection, MapCanvasMarkerWrapper, MapCanvasWrapper, MapControlWrapper, MapEvent, MapLoadingWithImage, MapMarkerWrapper, MapPolygonWrapper, MapPolylineWrapper, MapUIEvent, Marker, MintMap, MintMapCanvasRenderer, MintMapController, MintMapCore, MintMapProvider, NaverMintMapController, Offset, PointLoading, Polygon, PolygonCalculator, PolygonMarker, Polyline, Position, SVGCircle, SVGPolygon, SVGRect, Status, getClusterInfo, getMapOfType, log, useMarkerMoving, useMintMapController, waiting };
5895
+ export { AnimationPlayer, Bounds, CanvasMarker, CircleMarker, Drawable, GeoCalulator, GoogleMintMapController, MapBuildingProjection, MapCanvasMarkerWrapper, MapCanvasWrapper, MapControlWrapper, MapEvent, MapLoadingWithImage, MapMarkerWrapper, MapPolygonWrapper, MapPolylineWrapper, MapUIEvent, Marker, MintMap, MintMapCanvasRenderer, MintMapController, MintMapCore, MintMapProvider, NaverMintMapController, Offset, PointLoading, Polygon, PolygonCalculator, PolygonMarker, Polyline, Position, SVGCircle, SVGPolygon, SVGRect, Status, getClusterInfo, getMapOfType, log, useMarkerMoving, useMintMapController, waiting };
package/dist/index.js CHANGED
@@ -11,6 +11,7 @@ var SVGPolygon = require('./components/mint-map/core/advanced/shapes/base/SVGPol
11
11
  var SVGRect = require('./components/mint-map/core/advanced/shapes/base/SVGRect.js');
12
12
  var CircleMarker = require('./components/mint-map/core/advanced/shapes/CircleMarker.js');
13
13
  var PolygonMarker = require('./components/mint-map/core/advanced/shapes/PolygonMarker.js');
14
+ var CanvasMarker = require('./components/mint-map/core/advanced/canvas/CanvasMarker.js');
14
15
  var MapBuildingProjection = require('./components/mint-map/core/advanced/MapBuildingProjection.js');
15
16
  var MapLoadingComponents = require('./components/mint-map/core/advanced/MapLoadingComponents.js');
16
17
  var MarkerMovingHook = require('./components/mint-map/core/hooks/MarkerMovingHook.js');
@@ -46,6 +47,7 @@ exports.SVGPolygon = SVGPolygon.SVGPolygon;
46
47
  exports.SVGRect = SVGRect.SVGRect;
47
48
  exports.CircleMarker = CircleMarker.CircleMarker;
48
49
  exports.PolygonMarker = PolygonMarker.PolygonMarker;
50
+ exports.CanvasMarker = CanvasMarker.CanvasMarker;
49
51
  exports.MapBuildingProjection = MapBuildingProjection.MapBuildingProjection;
50
52
  exports.MapLoadingWithImage = MapLoadingComponents.MapLoadingWithImage;
51
53
  exports.PointLoading = MapLoadingComponents.PointLoading;
package/dist/index.umd.js CHANGED
@@ -4834,6 +4834,196 @@
4834
4834
  }, children)));
4835
4835
  }
4836
4836
 
4837
+ //scaling
4838
+ var scaleCanvas = function (controller, canvasElement, canvasContext) {
4839
+ var devicePixelRatio = window.devicePixelRatio;
4840
+ var container = controller.mapDivElement;
4841
+ var width = container.offsetWidth;
4842
+ var height = container.offsetHeight;
4843
+ canvasElement.width = width * devicePixelRatio;
4844
+ canvasElement.height = height * devicePixelRatio;
4845
+ canvasElement.style.width = "".concat(width, "px");
4846
+ canvasElement.style.height = "".concat(height, "px");
4847
+ canvasContext.scale(devicePixelRatio, devicePixelRatio);
4848
+ }; //clear rect
4849
+
4850
+ var clearRect = function (canvas, context) {
4851
+ if (canvas && context) {
4852
+ context.clearRect(canvas.width * -1, canvas.height * -1, canvas.width * 3, canvas.height * 3);
4853
+ }
4854
+
4855
+ return true;
4856
+ };
4857
+ function renderMain(controller, renderer, container, canvas, context, data) {
4858
+ if (!container || !canvas || !context || !data) {
4859
+ return;
4860
+ } //all clear
4861
+
4862
+
4863
+ clearRect(canvas, context); //draw
4864
+
4865
+ data.forEach(function (item) {
4866
+ var _a; // 그리기 대상이면
4867
+
4868
+
4869
+ if (item.visible === undefined || item.visible) {
4870
+ //위치 변환
4871
+ var offset = ((_a = item.position) === null || _a === void 0 ? void 0 : _a.map(function (pos) {
4872
+ return controller.positionToOffset(pos);
4873
+ })) || []; //그리기
4874
+
4875
+ renderer({
4876
+ context: context,
4877
+ offset: offset,
4878
+ payload: item
4879
+ });
4880
+ }
4881
+ });
4882
+ }
4883
+
4884
+ function CanvasMarker(_a) {
4885
+ var renderer = _a.renderer,
4886
+ data = _a.data,
4887
+ options = tslib.__rest(_a, ["renderer", "data"]); //controller
4888
+
4889
+
4890
+ var controller = useMintMapController(); //element
4891
+
4892
+ var divRef = React.useRef(document.createElement('div'));
4893
+ var divElement = divRef.current; //canvas container ref
4894
+
4895
+ var containerRef = React.useRef(null); //canvas ref
4896
+
4897
+ var canvasRef = React.useRef(null); //canvas context
4898
+
4899
+ var contextRef = React.useRef(); //marker
4900
+
4901
+ var markerRef = React.useRef(); //create object
4902
+
4903
+ React.useEffect(function () {
4904
+ divElement.style.width = 'fit-content';
4905
+ divElement.style.pointerEvents = 'none';
4906
+ return function () {
4907
+ if (markerRef.current) {
4908
+ controller.clearDrawable(markerRef.current);
4909
+ markerRef.current = undefined;
4910
+ }
4911
+ };
4912
+ }, []); //create / update object
4913
+
4914
+ React.useEffect(function () {
4915
+ if (options) {
4916
+ var bounds = controller.getCurrBounds();
4917
+
4918
+ var markerOptions = tslib.__assign({
4919
+ position: bounds.nw
4920
+ }, options);
4921
+
4922
+ if (markerRef.current) {
4923
+ controller.updateMarker(markerRef.current, markerOptions);
4924
+ } else {
4925
+ markerRef.current = new Marker(markerOptions);
4926
+ markerRef.current.element = divElement;
4927
+ controller.createMarker(markerRef.current); //disablePointerEvent 처리
4928
+
4929
+ if (divElement.parentElement) {
4930
+ divElement.style.pointerEvents = 'none';
4931
+ divElement.parentElement.style.pointerEvents = 'none';
4932
+ } //z-index 처리
4933
+
4934
+
4935
+ if (options.zIndex !== undefined) {
4936
+ controller.setMarkerZIndex(markerRef.current, options.zIndex);
4937
+ }
4938
+ }
4939
+ }
4940
+ }, [options]);
4941
+
4942
+ var handleIdle = function () {
4943
+ // 클리어
4944
+ clearRect(canvasRef.current, contextRef.current); // 마커 이동
4945
+
4946
+ var bounds = controller.getCurrBounds();
4947
+
4948
+ var markerOptions = tslib.__assign({
4949
+ position: bounds.nw
4950
+ }, options);
4951
+
4952
+ markerRef.current && controller.updateMarker(markerRef.current, markerOptions); // 렌더링
4953
+
4954
+ renderMain(controller, rendererRef.current, containerRef.current, canvasRef.current, contextRef.current, dataRef.current);
4955
+ };
4956
+
4957
+ var handleZoomStart = function () {
4958
+ containerRef.current && (containerRef.current.style.visibility = 'hidden');
4959
+ };
4960
+
4961
+ var handleZoomEnd = function () {
4962
+ containerRef.current && (containerRef.current.style.visibility = '');
4963
+ }; //initialize
4964
+
4965
+
4966
+ React.useEffect(function () {
4967
+ var resizeObserver;
4968
+
4969
+ if (canvasRef.current && containerRef.current) {
4970
+ // 리사이즈 처리
4971
+ resizeObserver = new ResizeObserver(function () {
4972
+ // 클리어
4973
+ clearRect(canvasRef.current, contextRef.current); // 스케일링
4974
+
4975
+ canvasRef.current && contextRef.current && scaleCanvas(controller, canvasRef.current, contextRef.current); // 렌더링
4976
+
4977
+ renderMain(controller, rendererRef.current, containerRef.current, canvasRef.current, contextRef.current, dataRef.current);
4978
+ });
4979
+ resizeObserver.observe(controller.mapDivElement); // IDLE 이벤트 등록
4980
+
4981
+ controller.addEventListener('IDLE', handleIdle); // 줌 처리
4982
+
4983
+ controller.addEventListener('ZOOMSTART', handleZoomStart);
4984
+ controller.addEventListener('ZOOM_CHANGED', handleZoomEnd); // 2d 컨텍스트
4985
+
4986
+ contextRef.current = canvasRef.current.getContext('2d'); // 스케일링
4987
+
4988
+ if (contextRef.current) {
4989
+ scaleCanvas(controller, canvasRef.current, contextRef.current);
4990
+ }
4991
+ }
4992
+
4993
+ return function () {
4994
+ resizeObserver && resizeObserver.disconnect();
4995
+ controller.removeEventListener('IDLE', handleIdle);
4996
+ controller.removeEventListener('ZOOMSTART', handleZoomStart);
4997
+ controller.removeEventListener('ZOOM_CHANGED', handleZoomEnd);
4998
+ };
4999
+ }, []); // data ref
5000
+
5001
+ var dataRef = React.useRef(data);
5002
+ React.useEffect(function () {
5003
+ dataRef.current = data;
5004
+ }, [data]); // renderer ref
5005
+
5006
+ var rendererRef = React.useRef(renderer);
5007
+ React.useEffect(function () {
5008
+ rendererRef.current = renderer;
5009
+ }, [renderer]);
5010
+ renderMain(controller, renderer, containerRef.current, canvasRef.current, contextRef.current, data);
5011
+ return reactDom.createPortal(React__default["default"].createElement("div", {
5012
+ ref: containerRef,
5013
+ style: {
5014
+ position: 'absolute',
5015
+ width: '100%',
5016
+ height: '100%',
5017
+ pointerEvents: 'none'
5018
+ }
5019
+ }, React__default["default"].createElement("canvas", {
5020
+ ref: canvasRef,
5021
+ style: {
5022
+ pointerEvents: 'revert-layer'
5023
+ }
5024
+ })), divElement);
5025
+ }
5026
+
4837
5027
  /**
4838
5028
  * Mint Map 컴포넌트
4839
5029
  *
@@ -5708,6 +5898,7 @@
5708
5898
 
5709
5899
  exports.AnimationPlayer = AnimationPlayer;
5710
5900
  exports.Bounds = Bounds;
5901
+ exports.CanvasMarker = CanvasMarker;
5711
5902
  exports.CircleMarker = CircleMarker;
5712
5903
  exports.Drawable = Drawable;
5713
5904
  exports.GeoCalulator = GeoCalulator;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mint-ui/map",
3
- "version": "0.9.2-beta",
3
+ "version": "0.9.2-beta-test2",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.es.js",
6
6
  "browser": "./dist/index.umd.js",