@mint-ui/map 2.1.1-alpha1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +110 -0
- package/LICENSE +21 -0
- package/README.md +222 -0
- package/dist/atom/GoogleMap/GoogleMap.d.ts +3 -0
- package/dist/atom/GoogleMap/GoogleMap.js +13 -0
- package/dist/atom/GoogleMap/GoogleMap.module.scss.js +13 -0
- package/dist/atom/GoogleMap/GoogleMapManager.js +108 -0
- package/dist/atom/GoogleMap/index.d.ts +2 -0
- package/dist/atom/NaverMap/NaverMap.d.ts +3 -0
- package/dist/atom/NaverMap/NaverMap.js +13 -0
- package/dist/atom/NaverMap/NaverMap.module.scss.js +13 -0
- package/dist/atom/NaverMap/NaverMapManager.d.ts +10 -0
- package/dist/atom/NaverMap/NaverMapManager.js +118 -0
- package/dist/atom/NaverMap/index.d.ts +2 -0
- package/dist/atom/index.d.ts +7 -0
- package/dist/common/hook.d.ts +1 -0
- package/dist/common/type.d.ts +3 -0
- package/dist/common/util.d.ts +4 -0
- package/dist/common/util.js +15 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.es.js +250 -0
- package/dist/index.js +7 -0
- package/dist/index.umd.js +258 -0
- package/dist/module/map/MapManager.js +11 -0
- package/dist/moleclue/Map/Map.d.ts +18 -0
- package/dist/moleclue/Map/index.d.ts +2 -0
- package/dist/moleclue/index.d.ts +5 -0
- package/package.json +69 -0
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
env: {
|
|
3
|
+
browser: true,
|
|
4
|
+
node: true
|
|
5
|
+
},
|
|
6
|
+
extends: [ 'airbnb', 'airbnb/hooks', 'eslint:recommended', 'plugin:react/recommended', 'plugin:import/recommended', 'plugin:storybook/recommended' ],
|
|
7
|
+
ignorePatterns: [ '.storybook', '*.d.ts', 'node_modules', 'build', 'dist', '**/env/*.js' ],
|
|
8
|
+
overrides: [
|
|
9
|
+
{
|
|
10
|
+
files: [ '*.ts', '*.tsx' ],
|
|
11
|
+
rules: { 'no-undef': 'off' }
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
parser: '@typescript-eslint/parser',
|
|
15
|
+
parserOptions: { warnOnUnsupportedTypeScriptVersion: false },
|
|
16
|
+
plugins: [ '@typescript-eslint', 'sort-keys-fix', 'prettier' ],
|
|
17
|
+
rules: {
|
|
18
|
+
'@typescript-eslint/ban-ts-comment': [
|
|
19
|
+
'error',
|
|
20
|
+
{ 'ts-ignore': 'allow-with-description' }
|
|
21
|
+
],
|
|
22
|
+
'@typescript-eslint/no-explicit-any': 'warn',
|
|
23
|
+
'@typescript-eslint/no-unused-vars': 'error',
|
|
24
|
+
'array-bracket-spacing': [
|
|
25
|
+
'error',
|
|
26
|
+
'always',
|
|
27
|
+
{
|
|
28
|
+
arraysInArrays: false,
|
|
29
|
+
objectsInArrays: false
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
'brace-style': [ 'error', 'allman' ],
|
|
33
|
+
'class-methods-use-this': 'off',
|
|
34
|
+
'comma-dangle': [ 'error', 'never' ],
|
|
35
|
+
'eol-last': [ 'error', 'never' ],
|
|
36
|
+
'import/extensions': 'off',
|
|
37
|
+
'import/named': 'off',
|
|
38
|
+
'import/no-anonymous-default-export': 'off',
|
|
39
|
+
'import/no-cycle': 'off',
|
|
40
|
+
'import/no-extraneous-dependencies': 'off',
|
|
41
|
+
'import/no-named-as-default': 'off',
|
|
42
|
+
'import/no-unresolved': 'off',
|
|
43
|
+
'import/order': [
|
|
44
|
+
'error',
|
|
45
|
+
{
|
|
46
|
+
alphabetize: {
|
|
47
|
+
caseInsensitive: true,
|
|
48
|
+
order: 'asc'
|
|
49
|
+
},
|
|
50
|
+
groups: [ 'external', 'builtin', 'internal', 'sibling', 'parent', 'index' ],
|
|
51
|
+
'newlines-between': 'always'
|
|
52
|
+
}
|
|
53
|
+
],
|
|
54
|
+
indent: [ 'error', 'tab', { SwitchCase: 1 }],
|
|
55
|
+
'jsx-a11y/control-has-associated-label': 'off',
|
|
56
|
+
'jsx-quotes': [ 'error', 'prefer-single' ],
|
|
57
|
+
'linebreak-style': 'off',
|
|
58
|
+
'max-len': 'off',
|
|
59
|
+
'no-console': 'off',
|
|
60
|
+
'no-plusplus': 'off',
|
|
61
|
+
'no-restricted-exports': 'off',
|
|
62
|
+
'no-tabs': [ 'error', { allowIndentationTabs: true }],
|
|
63
|
+
'no-unused-vars': 'off',
|
|
64
|
+
'object-curly-newline': [ 'error', {
|
|
65
|
+
ExportDeclaration: 'never',
|
|
66
|
+
ImportDeclaration: 'never',
|
|
67
|
+
ObjectExpression: {
|
|
68
|
+
minProperties: 3,
|
|
69
|
+
multiline: true
|
|
70
|
+
},
|
|
71
|
+
ObjectPattern: { multiline: true }
|
|
72
|
+
}],
|
|
73
|
+
'react-hooks/exhaustive-deps': 'off',
|
|
74
|
+
'react/button-has-type': 'off',
|
|
75
|
+
'react/destructuring-assignment': 'off',
|
|
76
|
+
'react/function-component-definition': 'off',
|
|
77
|
+
'react/jsx-curly-brace-presence': [
|
|
78
|
+
'error',
|
|
79
|
+
{
|
|
80
|
+
children: 'never',
|
|
81
|
+
props: 'never'
|
|
82
|
+
}
|
|
83
|
+
],
|
|
84
|
+
'react/jsx-filename-extension': 'off',
|
|
85
|
+
'react/jsx-indent': [ 'error', 'tab' ],
|
|
86
|
+
'react/jsx-indent-props': [ 2, 'tab' ],
|
|
87
|
+
'react/jsx-props-no-spreading': 'off',
|
|
88
|
+
'react/jsx-sort-props': [
|
|
89
|
+
'error',
|
|
90
|
+
{
|
|
91
|
+
callbacksLast: true,
|
|
92
|
+
ignoreCase: true,
|
|
93
|
+
multiline: 'last',
|
|
94
|
+
noSortAlphabetically: false,
|
|
95
|
+
reservedFirst: false,
|
|
96
|
+
shorthandFirst: false,
|
|
97
|
+
shorthandLast: true
|
|
98
|
+
}
|
|
99
|
+
],
|
|
100
|
+
'react/prop-types': 'off',
|
|
101
|
+
'react/react-in-jsx-scope': 'off',
|
|
102
|
+
'react/require-default-props': 'off',
|
|
103
|
+
'require-jsdoc': 'off',
|
|
104
|
+
'sort-keys-fix/sort-keys-fix': 'error'
|
|
105
|
+
},
|
|
106
|
+
settings: {
|
|
107
|
+
'import/parsers': { '@typescript-eslint/parser': [ '.ts', '.tsx', '.js' ] },
|
|
108
|
+
react: { version: 'detect' }
|
|
109
|
+
}
|
|
110
|
+
};
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 itcode.dev
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://github.com/dev-rsquare/mint-ui-map" target="_blank" align="center">
|
|
3
|
+
<img src="https://user-images.githubusercontent.com/50317129/172516374-5d27ea5b-9657-4772-8351-1beedcabedef.png" width="256" height="256" />
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<h1 align="center">@mint-ui/map</h1>
|
|
8
|
+
|
|
9
|
+
- **@mint-ui**의 맵 라이브러리입니다.
|
|
10
|
+
- TypeScript, SCSS 기반
|
|
11
|
+
- 빌더로 rollup.js를 활용합니다.
|
|
12
|
+
- `CJS`
|
|
13
|
+
- `ESM`
|
|
14
|
+
- `UMD`
|
|
15
|
+
- Storybook으로 컴포넌트 확인 및 테스트를 수행합니다.
|
|
16
|
+
|
|
17
|
+
<br />
|
|
18
|
+
|
|
19
|
+
## Guide for Develop
|
|
20
|
+
|
|
21
|
+
### 1. Setup
|
|
22
|
+
|
|
23
|
+
``` bash
|
|
24
|
+
git clone https://github.com/dev-rsquare/mint-ui-map
|
|
25
|
+
|
|
26
|
+
cd ./mint-ui-map
|
|
27
|
+
|
|
28
|
+
# install dependencies
|
|
29
|
+
yarn
|
|
30
|
+
npm install
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
- 레포지토리를 클론합니다.
|
|
34
|
+
- dependencies 설치를 수행합니다.
|
|
35
|
+
- 해당 프로젝트는 `yarn`을 권장합니다.
|
|
36
|
+
|
|
37
|
+
### 2. Structure
|
|
38
|
+
|
|
39
|
+
``` bash
|
|
40
|
+
# ref 2022.06.08
|
|
41
|
+
@mint-ui/map
|
|
42
|
+
├── .storybook
|
|
43
|
+
│ ├── main.js # storybook configure
|
|
44
|
+
│ ├── preview.js
|
|
45
|
+
├── dist # output
|
|
46
|
+
├── node_modules # dependencies
|
|
47
|
+
├── src # source root
|
|
48
|
+
│ ├── [dir]
|
|
49
|
+
│ │ ├── [component].tsx # component core
|
|
50
|
+
│ │ ├── [component].stories.tsx # storybook for component
|
|
51
|
+
│ │ ├── [component].module.scss # scss for component
|
|
52
|
+
│ │ └── index.ts
|
|
53
|
+
│ ├── declaration.d.ts # module for *.module.scss
|
|
54
|
+
│ └── index.ts # main script
|
|
55
|
+
├── .eslintrs.js # eslint configure
|
|
56
|
+
├── .gitignore
|
|
57
|
+
├── .npmignore # file list to ignore when deploying
|
|
58
|
+
├── LICENSE
|
|
59
|
+
├── package.json
|
|
60
|
+
├── README.md
|
|
61
|
+
├── rollup.config.js # rollup.js configure
|
|
62
|
+
└── tsconfig.json
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
- `src/` 폴더 하위에 코드를 작성합니다.
|
|
66
|
+
- 빌드 결과물은 `dist/`에 출력되도록 설정되어 있습니다.
|
|
67
|
+
- rollup.js 설정 및 플러그인 추가는 `rollup.config.js`를 참조하세요.
|
|
68
|
+
- 레포지토리와 별개로, npm 배포 시 제외할 파일은 `.npmignore`에 추가해주세요.
|
|
69
|
+
- ESLint 설정은 제 개인적인 주관이 매우 많이 포함되어 있습니다.
|
|
70
|
+
- 필요한 설정은 적절한 협의 후 `.eslintrc.js`에 추가합니다.
|
|
71
|
+
|
|
72
|
+
### 3. Storybook Test
|
|
73
|
+
|
|
74
|
+

|
|
75
|
+
|
|
76
|
+
``` bash
|
|
77
|
+
yarn storybool
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
- 위 명령어를 통해 Storybook을 실행할 수 있습니다.
|
|
81
|
+
- Storybook에서 컴포넌트를 미리 확인하고, 프로퍼티별 옵션을 테스트할 수 있습니다.
|
|
82
|
+
|
|
83
|
+
### 4. Build
|
|
84
|
+
|
|
85
|
+
``` js
|
|
86
|
+
/**
|
|
87
|
+
* Rollup 설정 모듈
|
|
88
|
+
*
|
|
89
|
+
* @author RWB
|
|
90
|
+
* @since 2022.06.06 Mon 17:44:31
|
|
91
|
+
*/
|
|
92
|
+
|
|
93
|
+
import babel from '@rollup/plugin-babel';
|
|
94
|
+
import commonjs from '@rollup/plugin-commonjs';
|
|
95
|
+
import { nodeResolve } from '@rollup/plugin-node-resolve';
|
|
96
|
+
import typescript from '@rollup/plugin-typescript';
|
|
97
|
+
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
|
|
98
|
+
import postcss from 'rollup-plugin-postcss';
|
|
99
|
+
|
|
100
|
+
const extensions = [ 'js', 'jsx', 'ts', 'tsx', 'mjs' ];
|
|
101
|
+
|
|
102
|
+
const pkg = require('./package.json');
|
|
103
|
+
|
|
104
|
+
const config = [
|
|
105
|
+
{
|
|
106
|
+
external: [ /node_modules/ ],
|
|
107
|
+
input: './src/index.ts',
|
|
108
|
+
output: [
|
|
109
|
+
{
|
|
110
|
+
dir: './dist',
|
|
111
|
+
format: 'cjs',
|
|
112
|
+
preserveModules: true,
|
|
113
|
+
preserveModulesRoot: 'src'
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
file: pkg.module,
|
|
117
|
+
format: 'es'
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
file: pkg.browser,
|
|
121
|
+
format: 'umd',
|
|
122
|
+
name: pkg.name
|
|
123
|
+
}
|
|
124
|
+
],
|
|
125
|
+
plugins: [
|
|
126
|
+
nodeResolve({ extensions }),
|
|
127
|
+
commonjs({ include: 'node_modules/**' }),
|
|
128
|
+
peerDepsExternal(),
|
|
129
|
+
babel({
|
|
130
|
+
exclude: 'node_modules/**',
|
|
131
|
+
extensions,
|
|
132
|
+
include: [ 'src/**/*' ]
|
|
133
|
+
}),
|
|
134
|
+
typescript({ tsconfig: './tsconfig.json' }),
|
|
135
|
+
postcss({
|
|
136
|
+
extract: false,
|
|
137
|
+
inject: (cssVariableName) => `import styleInject from 'style-inject';\nstyleInject(${cssVariableName});`,
|
|
138
|
+
modules: true,
|
|
139
|
+
sourceMap: false,
|
|
140
|
+
use: [ 'sass' ]
|
|
141
|
+
})
|
|
142
|
+
]
|
|
143
|
+
}
|
|
144
|
+
];
|
|
145
|
+
|
|
146
|
+
export default config;
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
- Rollup 빌드 설정은 위와 같습니다. (2022.06.08 기준)
|
|
150
|
+
- `@rollup/plugin-babel` - Rollup.js에 Babel을 연동해줍니다.
|
|
151
|
+
- `@rollup/plugin-commonjs` - ESM 코드를 CommonJS로 변환합니다.
|
|
152
|
+
- 반드시 `@rollup/plugin-babel` 이후에 위치해야합니다.
|
|
153
|
+
- `@rollup/plugin-node-resolve` - 외부 모듈을 사용할 수 있도록 구성합니다.
|
|
154
|
+
- `rollup-plugin-peer-deps-external` - `pacakge.json`의 `peerDependencies`를 번들링하지 않고 `import` 구문으로 호출합니다.
|
|
155
|
+
- `rollup-plugin-postcss` - postcss 후처리기를 사용합니다.
|
|
156
|
+
- `src/index.ts`를 기준으로 빌드를 수행합니다.
|
|
157
|
+
- 빌드 결과물은 `dist/`에 출력됩니다.
|
|
158
|
+
- `CJS`, `ESM`, `UMD` 세 가지 모듈로 출력됩니다.
|
|
159
|
+
- `CJS`는 Tree Shaking이 적용됩니다.
|
|
160
|
+
|
|
161
|
+
``` bash
|
|
162
|
+
yarn build
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
- 빌드 명령어는 위와 같습니다.
|
|
166
|
+
|
|
167
|
+
### 5. publish
|
|
168
|
+
|
|
169
|
+
``` json
|
|
170
|
+
{
|
|
171
|
+
"name": "@mint-ui/map",
|
|
172
|
+
"version": "1.0.0",
|
|
173
|
+
"main": "./dist/index.js",
|
|
174
|
+
"module": "./dist/index.es.js",
|
|
175
|
+
"browser": "./dist/index.umd.js",
|
|
176
|
+
"types": "./dist/index.d.ts",
|
|
177
|
+
"private": false
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
- npm 배포 시 확인할 `package.json`의 주요 설정은 위와 같습니다.
|
|
182
|
+
- `name` - 라이브러리의 이름. 이 값을 기준으로 npm 라이브러리 이름이 결정됩니다. 중복은 허용되지 않습니다.
|
|
183
|
+
- 조직이 있다면 조직명을 같이 입력해주세요. `@{org}/@{name}` 형태입니다.
|
|
184
|
+
- `version` - 라이브러리의 버전. 이미 배포된 버전은 다시 배포할 수 없습니다.
|
|
185
|
+
- `main` - 라이브러리의 메인 모듈. 본 라이브러리는 `CJS` 모듈을 메인으로 사용합니다.
|
|
186
|
+
- `module` - 라이브러리의 EJS 모듈
|
|
187
|
+
- `browser` - 라이브러리의 UMD 모듈
|
|
188
|
+
- `types` - 라이브러리의 타입. TypeScript 개발환경에서의 활용을 위해 타입을 제공합니다.
|
|
189
|
+
- `private` - 라이브러리의 비공개 여부. 비공개일 경우 라이브러리를 외부에 노출시키지 않을 수 있습니다. 물룐 비용이 발생합니다.
|
|
190
|
+
- GitHub의 Private Repository와는 관련 없습니다.
|
|
191
|
+
|
|
192
|
+
``` bash
|
|
193
|
+
npm login
|
|
194
|
+
# username
|
|
195
|
+
# password
|
|
196
|
+
# email
|
|
197
|
+
# email otp
|
|
198
|
+
|
|
199
|
+
yarn publish
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
- 위 명령어를 입력하여 배포를 수행할 수 있습니다.
|
|
203
|
+
- 배포된 라이브러리는 약 수 초 뒤, npm 페이지에서 확인할 수 있습니다.
|
|
204
|
+
|
|
205
|
+
``` bash
|
|
206
|
+
npm unpublish @mint-ui/map@1.0.0
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
- 배포 취소는 위 명령어를 입력합니다.
|
|
210
|
+
- 한 번 배포된 라이브러리는 24시간 내에 취소가 가능하며, 이를 초과할 경우 npm에 직접 요청메일을 보내야합니다.
|
|
211
|
+
|
|
212
|
+
<br />
|
|
213
|
+
|
|
214
|
+
## Guide for User
|
|
215
|
+
|
|
216
|
+
``` bash
|
|
217
|
+
yarn add @mint-ui/map
|
|
218
|
+
|
|
219
|
+
npm install @mint-ui/map
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
- 위 명령어로 다운로드 받을 수 있습니다.
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { MapProps } from '../../moleclue/Map/Map';
|
|
2
|
+
export declare type GoogleLibraryType = 'drawing' | 'geometry' | 'journeySharing' | 'localContext' | 'places' | 'visualization';
|
|
3
|
+
export default function GoogleMap({ api, id, option, width, height, libraries, markers, style, className, children, ...props }: MapProps): JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('tslib');
|
|
4
|
+
var classNames = require('classnames/bind');
|
|
5
|
+
require('react');
|
|
6
|
+
var GoogleMap_module = require('./GoogleMap.module.scss.js');
|
|
7
|
+
require('./GoogleMapManager.js');
|
|
8
|
+
|
|
9
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
10
|
+
|
|
11
|
+
var classNames__default = /*#__PURE__*/_interopDefaultLegacy(classNames);
|
|
12
|
+
|
|
13
|
+
classNames__default["default"].bind(GoogleMap_module);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var styleInject = require('style-inject');
|
|
4
|
+
|
|
5
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
6
|
+
|
|
7
|
+
var styleInject__default = /*#__PURE__*/_interopDefaultLegacy(styleInject);
|
|
8
|
+
|
|
9
|
+
var css_248z = ".GoogleMap-module_google-map-wrapper__Ixip9 {\n position: relative;\n background-color: whitesmoke;\n}\n\n.GoogleMap-module_google-map__2k3RV {\n width: 100%;\n height: 100%;\n}";
|
|
10
|
+
var styles = {"google-map-wrapper":"GoogleMap-module_google-map-wrapper__Ixip9","google-map":"GoogleMap-module_google-map__2k3RV"};
|
|
11
|
+
styleInject__default["default"](css_248z);
|
|
12
|
+
|
|
13
|
+
module.exports = styles;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tslib = require('tslib');
|
|
4
|
+
var util = require('../../common/util.js');
|
|
5
|
+
var MapManager = require('../../module/map/MapManager.js');
|
|
6
|
+
|
|
7
|
+
(function (_super) {
|
|
8
|
+
tslib.__extends(GoogleMapManager, _super);
|
|
9
|
+
|
|
10
|
+
function GoogleMapManager() {
|
|
11
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
GoogleMapManager.prototype.getScriptUrl = function (libraries, callback) {
|
|
15
|
+
var params = {
|
|
16
|
+
key: this.api,
|
|
17
|
+
v: 'weekly'
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
if (libraries) {
|
|
21
|
+
params.libraries = libraries.join(',');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (callback) {
|
|
25
|
+
params.callback = callback;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return util.buildUrl('https://maps.googleapis.com/maps/api/js', params);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
GoogleMapManager.prototype.getMap = function (id, option) {
|
|
32
|
+
var tag = document.getElementById(id);
|
|
33
|
+
return new google.maps.Map(tag, this.convertOption(option));
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
GoogleMapManager.prototype.drawMarkers = function (map, options) {
|
|
37
|
+
var _this = this;
|
|
38
|
+
|
|
39
|
+
return options.map(function (option) {
|
|
40
|
+
var converted = _this.convertMarkerOption(tslib.__assign({
|
|
41
|
+
map: map
|
|
42
|
+
}, option));
|
|
43
|
+
|
|
44
|
+
return new google.maps.Marker(converted);
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
GoogleMapManager.prototype.convertOption = function (option) {
|
|
49
|
+
var center = option.center,
|
|
50
|
+
maxZoom = option.maxZoom,
|
|
51
|
+
minZoom = option.minZoom,
|
|
52
|
+
zoom = option.zoom;
|
|
53
|
+
var lat = center.lat,
|
|
54
|
+
lng = center.lng;
|
|
55
|
+
var converted = {
|
|
56
|
+
center: {
|
|
57
|
+
lat: lat,
|
|
58
|
+
lng: lng
|
|
59
|
+
},
|
|
60
|
+
maxZoom: maxZoom,
|
|
61
|
+
minZoom: minZoom,
|
|
62
|
+
zoom: zoom
|
|
63
|
+
};
|
|
64
|
+
return converted;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
GoogleMapManager.prototype.convertMarkerOption = function (_a) {
|
|
68
|
+
var map = _a.map,
|
|
69
|
+
position = _a.position,
|
|
70
|
+
icon = _a.icon,
|
|
71
|
+
title = _a.title,
|
|
72
|
+
visible = _a.visible,
|
|
73
|
+
zIndex = _a.zIndex;
|
|
74
|
+
var option = {
|
|
75
|
+
map: map || this.map,
|
|
76
|
+
position: position
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
if (icon) {
|
|
80
|
+
var url = icon.url,
|
|
81
|
+
origin_1 = icon.origin,
|
|
82
|
+
anchor = icon.anchor,
|
|
83
|
+
scaledSize = icon.scaledSize;
|
|
84
|
+
option.icon = {
|
|
85
|
+
anchor: anchor && new google.maps.Point(anchor[0], anchor[1]),
|
|
86
|
+
origin: origin_1 && new google.maps.Point(origin_1[0], origin_1[1]),
|
|
87
|
+
scaledSize: scaledSize && new google.maps.Size(scaledSize[0], scaledSize[1]),
|
|
88
|
+
url: url
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (title) {
|
|
93
|
+
option.title = title;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (visible) {
|
|
97
|
+
option.visible = visible;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (zIndex) {
|
|
101
|
+
option.zIndex = zIndex;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return option;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
return GoogleMapManager;
|
|
108
|
+
})(MapManager);
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { MapProps } from '../../moleclue/Map/Map';
|
|
2
|
+
export declare type NaverLibraryType = 'drawing' | 'geocoder' | 'panorama' | 'visualization';
|
|
3
|
+
export default function NaverMap({ api, id, option, width, height, libraries, markers, style, className, children, ...props }: MapProps): JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('tslib');
|
|
4
|
+
var classNames = require('classnames/bind');
|
|
5
|
+
require('react');
|
|
6
|
+
var NaverMap_module = require('./NaverMap.module.scss.js');
|
|
7
|
+
require('./NaverMapManager.js');
|
|
8
|
+
|
|
9
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
10
|
+
|
|
11
|
+
var classNames__default = /*#__PURE__*/_interopDefaultLegacy(classNames);
|
|
12
|
+
|
|
13
|
+
classNames__default["default"].bind(NaverMap_module);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var styleInject = require('style-inject');
|
|
4
|
+
|
|
5
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
6
|
+
|
|
7
|
+
var styleInject__default = /*#__PURE__*/_interopDefaultLegacy(styleInject);
|
|
8
|
+
|
|
9
|
+
var css_248z = ".NaverMap-module_naver-map-wrapper__dt2kP {\n position: relative;\n background-color: whitesmoke;\n}\n\n.NaverMap-module_naver-map__zTbF2 {\n width: 100%;\n height: 100%;\n}";
|
|
10
|
+
var styles = {"naver-map-wrapper":"NaverMap-module_naver-map-wrapper__dt2kP","naver-map":"NaverMap-module_naver-map__zTbF2"};
|
|
11
|
+
styleInject__default["default"](css_248z);
|
|
12
|
+
|
|
13
|
+
module.exports = styles;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="navermaps" />
|
|
2
|
+
import MapManager, { MapManagerMarkerOptionsType, MapManagerOptionType, MapType } from '../../module/map/MapManager';
|
|
3
|
+
export declare type NaverMapLibrariesType = 'drawing' | 'geocoder' | 'panorama' | 'visualization';
|
|
4
|
+
export default class NaverMapManager extends MapManager {
|
|
5
|
+
getScriptUrl(libraries?: NaverMapLibrariesType[], callback?: string): string;
|
|
6
|
+
getMap(id: string, option: MapManagerOptionType): naver.maps.Map;
|
|
7
|
+
drawMarkers(map: MapType, options: MapManagerMarkerOptionsType[]): naver.maps.Marker[];
|
|
8
|
+
private convertOption;
|
|
9
|
+
private convertMarkerOption;
|
|
10
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tslib = require('tslib');
|
|
4
|
+
var util = require('../../common/util.js');
|
|
5
|
+
var MapManager = require('../../module/map/MapManager.js');
|
|
6
|
+
|
|
7
|
+
(function (_super) {
|
|
8
|
+
tslib.__extends(NaverMapManager, _super);
|
|
9
|
+
|
|
10
|
+
function NaverMapManager() {
|
|
11
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
NaverMapManager.prototype.getScriptUrl = function (libraries, callback) {
|
|
15
|
+
var params = {
|
|
16
|
+
ncpClientId: this.api
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
if (libraries) {
|
|
20
|
+
params.submodules = libraries.join(',');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (callback) {
|
|
24
|
+
params.callback = callback;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return util.buildUrl('https://openapi.map.naver.com/openapi/v3/maps.js', params);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
NaverMapManager.prototype.getMap = function (id, option) {
|
|
31
|
+
this.map = new naver.maps.Map(id, this.convertOption(option));
|
|
32
|
+
console.dir(this.map);
|
|
33
|
+
return new naver.maps.Map(id, this.convertOption(option));
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
NaverMapManager.prototype.drawMarkers = function (map, options) {
|
|
37
|
+
var _this = this;
|
|
38
|
+
|
|
39
|
+
console.dir(this.map);
|
|
40
|
+
return options.map(function (option) {
|
|
41
|
+
var converted = _this.convertMarkerOption(tslib.__assign({
|
|
42
|
+
map: map
|
|
43
|
+
}, option));
|
|
44
|
+
|
|
45
|
+
return new naver.maps.Marker(converted);
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
NaverMapManager.prototype.convertOption = function (_a) {
|
|
50
|
+
var center = _a.center,
|
|
51
|
+
maxZoom = _a.maxZoom,
|
|
52
|
+
minZoom = _a.minZoom,
|
|
53
|
+
zoom = _a.zoom;
|
|
54
|
+
var lat = center.lat,
|
|
55
|
+
lng = center.lng;
|
|
56
|
+
var converted = {
|
|
57
|
+
center: {
|
|
58
|
+
lat: lat,
|
|
59
|
+
lng: lng
|
|
60
|
+
},
|
|
61
|
+
zoom: zoom
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
if (maxZoom) {
|
|
65
|
+
converted.maxZoom = maxZoom;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (minZoom) {
|
|
69
|
+
converted.minZoom = minZoom;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return converted;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
NaverMapManager.prototype.convertMarkerOption = function (_a) {
|
|
76
|
+
var map = _a.map,
|
|
77
|
+
position = _a.position,
|
|
78
|
+
icon = _a.icon,
|
|
79
|
+
title = _a.title,
|
|
80
|
+
visible = _a.visible,
|
|
81
|
+
zIndex = _a.zIndex;
|
|
82
|
+
var option = {
|
|
83
|
+
map: map || this.map,
|
|
84
|
+
position: position
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
if (icon) {
|
|
88
|
+
var url = icon.url,
|
|
89
|
+
size = icon.size,
|
|
90
|
+
origin_1 = icon.origin,
|
|
91
|
+
anchor = icon.anchor,
|
|
92
|
+
scaledSize = icon.scaledSize;
|
|
93
|
+
option.icon = {
|
|
94
|
+
anchor: anchor && new naver.maps.Point(anchor[0], anchor[1]),
|
|
95
|
+
origin: origin_1 && new naver.maps.Point(origin_1[0], origin_1[1]),
|
|
96
|
+
scaledSize: scaledSize && new naver.maps.Size(scaledSize[0], scaledSize[1]),
|
|
97
|
+
size: size && new naver.maps.Size(size[0], size[1]),
|
|
98
|
+
url: url
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (title) {
|
|
103
|
+
option.title = title;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (visible) {
|
|
107
|
+
option.visible = visible;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (zIndex) {
|
|
111
|
+
option.zIndex = zIndex;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return option;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
return NaverMapManager;
|
|
118
|
+
})(MapManager);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function useScript(url: string, onLoad?: (e: Event) => void): void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
function buildUrl(baseUrl, param) {
|
|
6
|
+
var params = Object.entries(param).map(function (_a) {
|
|
7
|
+
var key = _a[0],
|
|
8
|
+
value = _a[1];
|
|
9
|
+
var temp = encodeURIComponent(Array.isArray(value) ? value.join(',') : value);
|
|
10
|
+
return "".concat(key, "=").concat(temp);
|
|
11
|
+
}).join('&');
|
|
12
|
+
return "".concat(baseUrl, "?").concat(params);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
exports.buildUrl = buildUrl;
|
package/dist/index.d.ts
ADDED
package/dist/index.es.js
ADDED
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { __extends, __assign } from 'tslib';
|
|
2
|
+
import classNames from 'classnames/bind';
|
|
3
|
+
import 'react';
|
|
4
|
+
import styleInject from 'style-inject';
|
|
5
|
+
|
|
6
|
+
var css_248z$1 = ".GoogleMap-module_google-map-wrapper__Ixip9 {\n position: relative;\n background-color: whitesmoke;\n}\n\n.GoogleMap-module_google-map__2k3RV {\n width: 100%;\n height: 100%;\n}";
|
|
7
|
+
var styles$1 = {"google-map-wrapper":"GoogleMap-module_google-map-wrapper__Ixip9","google-map":"GoogleMap-module_google-map__2k3RV"};
|
|
8
|
+
styleInject(css_248z$1);
|
|
9
|
+
|
|
10
|
+
function buildUrl(baseUrl, param) {
|
|
11
|
+
var params = Object.entries(param).map(function (_a) {
|
|
12
|
+
var key = _a[0],
|
|
13
|
+
value = _a[1];
|
|
14
|
+
var temp = encodeURIComponent(Array.isArray(value) ? value.join(',') : value);
|
|
15
|
+
return "".concat(key, "=").concat(temp);
|
|
16
|
+
}).join('&');
|
|
17
|
+
return "".concat(baseUrl, "?").concat(params);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
var MapManager = function () {
|
|
21
|
+
function MapManager(api) {
|
|
22
|
+
this.api = api;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return MapManager;
|
|
26
|
+
}();
|
|
27
|
+
|
|
28
|
+
(function (_super) {
|
|
29
|
+
__extends(GoogleMapManager, _super);
|
|
30
|
+
|
|
31
|
+
function GoogleMapManager() {
|
|
32
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
GoogleMapManager.prototype.getScriptUrl = function (libraries, callback) {
|
|
36
|
+
var params = {
|
|
37
|
+
key: this.api,
|
|
38
|
+
v: 'weekly'
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
if (libraries) {
|
|
42
|
+
params.libraries = libraries.join(',');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (callback) {
|
|
46
|
+
params.callback = callback;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return buildUrl('https://maps.googleapis.com/maps/api/js', params);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
GoogleMapManager.prototype.getMap = function (id, option) {
|
|
53
|
+
var tag = document.getElementById(id);
|
|
54
|
+
return new google.maps.Map(tag, this.convertOption(option));
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
GoogleMapManager.prototype.drawMarkers = function (map, options) {
|
|
58
|
+
var _this = this;
|
|
59
|
+
|
|
60
|
+
return options.map(function (option) {
|
|
61
|
+
var converted = _this.convertMarkerOption(__assign({
|
|
62
|
+
map: map
|
|
63
|
+
}, option));
|
|
64
|
+
|
|
65
|
+
return new google.maps.Marker(converted);
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
GoogleMapManager.prototype.convertOption = function (option) {
|
|
70
|
+
var center = option.center,
|
|
71
|
+
maxZoom = option.maxZoom,
|
|
72
|
+
minZoom = option.minZoom,
|
|
73
|
+
zoom = option.zoom;
|
|
74
|
+
var lat = center.lat,
|
|
75
|
+
lng = center.lng;
|
|
76
|
+
var converted = {
|
|
77
|
+
center: {
|
|
78
|
+
lat: lat,
|
|
79
|
+
lng: lng
|
|
80
|
+
},
|
|
81
|
+
maxZoom: maxZoom,
|
|
82
|
+
minZoom: minZoom,
|
|
83
|
+
zoom: zoom
|
|
84
|
+
};
|
|
85
|
+
return converted;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
GoogleMapManager.prototype.convertMarkerOption = function (_a) {
|
|
89
|
+
var map = _a.map,
|
|
90
|
+
position = _a.position,
|
|
91
|
+
icon = _a.icon,
|
|
92
|
+
title = _a.title,
|
|
93
|
+
visible = _a.visible,
|
|
94
|
+
zIndex = _a.zIndex;
|
|
95
|
+
var option = {
|
|
96
|
+
map: map || this.map,
|
|
97
|
+
position: position
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
if (icon) {
|
|
101
|
+
var url = icon.url,
|
|
102
|
+
origin_1 = icon.origin,
|
|
103
|
+
anchor = icon.anchor,
|
|
104
|
+
scaledSize = icon.scaledSize;
|
|
105
|
+
option.icon = {
|
|
106
|
+
anchor: anchor && new google.maps.Point(anchor[0], anchor[1]),
|
|
107
|
+
origin: origin_1 && new google.maps.Point(origin_1[0], origin_1[1]),
|
|
108
|
+
scaledSize: scaledSize && new google.maps.Size(scaledSize[0], scaledSize[1]),
|
|
109
|
+
url: url
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (title) {
|
|
114
|
+
option.title = title;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (visible) {
|
|
118
|
+
option.visible = visible;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (zIndex) {
|
|
122
|
+
option.zIndex = zIndex;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return option;
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
return GoogleMapManager;
|
|
129
|
+
})(MapManager);
|
|
130
|
+
|
|
131
|
+
classNames.bind(styles$1);
|
|
132
|
+
|
|
133
|
+
var css_248z = ".NaverMap-module_naver-map-wrapper__dt2kP {\n position: relative;\n background-color: whitesmoke;\n}\n\n.NaverMap-module_naver-map__zTbF2 {\n width: 100%;\n height: 100%;\n}";
|
|
134
|
+
var styles = {"naver-map-wrapper":"NaverMap-module_naver-map-wrapper__dt2kP","naver-map":"NaverMap-module_naver-map__zTbF2"};
|
|
135
|
+
styleInject(css_248z);
|
|
136
|
+
|
|
137
|
+
(function (_super) {
|
|
138
|
+
__extends(NaverMapManager, _super);
|
|
139
|
+
|
|
140
|
+
function NaverMapManager() {
|
|
141
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
NaverMapManager.prototype.getScriptUrl = function (libraries, callback) {
|
|
145
|
+
var params = {
|
|
146
|
+
ncpClientId: this.api
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
if (libraries) {
|
|
150
|
+
params.submodules = libraries.join(',');
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (callback) {
|
|
154
|
+
params.callback = callback;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return buildUrl('https://openapi.map.naver.com/openapi/v3/maps.js', params);
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
NaverMapManager.prototype.getMap = function (id, option) {
|
|
161
|
+
this.map = new naver.maps.Map(id, this.convertOption(option));
|
|
162
|
+
console.dir(this.map);
|
|
163
|
+
return new naver.maps.Map(id, this.convertOption(option));
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
NaverMapManager.prototype.drawMarkers = function (map, options) {
|
|
167
|
+
var _this = this;
|
|
168
|
+
|
|
169
|
+
console.dir(this.map);
|
|
170
|
+
return options.map(function (option) {
|
|
171
|
+
var converted = _this.convertMarkerOption(__assign({
|
|
172
|
+
map: map
|
|
173
|
+
}, option));
|
|
174
|
+
|
|
175
|
+
return new naver.maps.Marker(converted);
|
|
176
|
+
});
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
NaverMapManager.prototype.convertOption = function (_a) {
|
|
180
|
+
var center = _a.center,
|
|
181
|
+
maxZoom = _a.maxZoom,
|
|
182
|
+
minZoom = _a.minZoom,
|
|
183
|
+
zoom = _a.zoom;
|
|
184
|
+
var lat = center.lat,
|
|
185
|
+
lng = center.lng;
|
|
186
|
+
var converted = {
|
|
187
|
+
center: {
|
|
188
|
+
lat: lat,
|
|
189
|
+
lng: lng
|
|
190
|
+
},
|
|
191
|
+
zoom: zoom
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
if (maxZoom) {
|
|
195
|
+
converted.maxZoom = maxZoom;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (minZoom) {
|
|
199
|
+
converted.minZoom = minZoom;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return converted;
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
NaverMapManager.prototype.convertMarkerOption = function (_a) {
|
|
206
|
+
var map = _a.map,
|
|
207
|
+
position = _a.position,
|
|
208
|
+
icon = _a.icon,
|
|
209
|
+
title = _a.title,
|
|
210
|
+
visible = _a.visible,
|
|
211
|
+
zIndex = _a.zIndex;
|
|
212
|
+
var option = {
|
|
213
|
+
map: map || this.map,
|
|
214
|
+
position: position
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
if (icon) {
|
|
218
|
+
var url = icon.url,
|
|
219
|
+
size = icon.size,
|
|
220
|
+
origin_1 = icon.origin,
|
|
221
|
+
anchor = icon.anchor,
|
|
222
|
+
scaledSize = icon.scaledSize;
|
|
223
|
+
option.icon = {
|
|
224
|
+
anchor: anchor && new naver.maps.Point(anchor[0], anchor[1]),
|
|
225
|
+
origin: origin_1 && new naver.maps.Point(origin_1[0], origin_1[1]),
|
|
226
|
+
scaledSize: scaledSize && new naver.maps.Size(scaledSize[0], scaledSize[1]),
|
|
227
|
+
size: size && new naver.maps.Size(size[0], size[1]),
|
|
228
|
+
url: url
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
if (title) {
|
|
233
|
+
option.title = title;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (visible) {
|
|
237
|
+
option.visible = visible;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
if (zIndex) {
|
|
241
|
+
option.zIndex = zIndex;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
return option;
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
return NaverMapManager;
|
|
248
|
+
})(MapManager);
|
|
249
|
+
|
|
250
|
+
classNames.bind(styles);
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('tslib'), require('classnames/bind'), require('react'), require('style-inject')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['tslib', 'classnames/bind', 'react', 'style-inject'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.tslib, global.classNames, null, global.styleInject));
|
|
5
|
+
})(this, (function (tslib, classNames, React, styleInject) { 'use strict';
|
|
6
|
+
|
|
7
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
|
+
|
|
9
|
+
var classNames__default = /*#__PURE__*/_interopDefaultLegacy(classNames);
|
|
10
|
+
var styleInject__default = /*#__PURE__*/_interopDefaultLegacy(styleInject);
|
|
11
|
+
|
|
12
|
+
var css_248z$1 = ".GoogleMap-module_google-map-wrapper__Ixip9 {\n position: relative;\n background-color: whitesmoke;\n}\n\n.GoogleMap-module_google-map__2k3RV {\n width: 100%;\n height: 100%;\n}";
|
|
13
|
+
var styles$1 = {"google-map-wrapper":"GoogleMap-module_google-map-wrapper__Ixip9","google-map":"GoogleMap-module_google-map__2k3RV"};
|
|
14
|
+
styleInject__default["default"](css_248z$1);
|
|
15
|
+
|
|
16
|
+
function buildUrl(baseUrl, param) {
|
|
17
|
+
var params = Object.entries(param).map(function (_a) {
|
|
18
|
+
var key = _a[0],
|
|
19
|
+
value = _a[1];
|
|
20
|
+
var temp = encodeURIComponent(Array.isArray(value) ? value.join(',') : value);
|
|
21
|
+
return "".concat(key, "=").concat(temp);
|
|
22
|
+
}).join('&');
|
|
23
|
+
return "".concat(baseUrl, "?").concat(params);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
var MapManager = function () {
|
|
27
|
+
function MapManager(api) {
|
|
28
|
+
this.api = api;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return MapManager;
|
|
32
|
+
}();
|
|
33
|
+
|
|
34
|
+
(function (_super) {
|
|
35
|
+
tslib.__extends(GoogleMapManager, _super);
|
|
36
|
+
|
|
37
|
+
function GoogleMapManager() {
|
|
38
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
GoogleMapManager.prototype.getScriptUrl = function (libraries, callback) {
|
|
42
|
+
var params = {
|
|
43
|
+
key: this.api,
|
|
44
|
+
v: 'weekly'
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
if (libraries) {
|
|
48
|
+
params.libraries = libraries.join(',');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (callback) {
|
|
52
|
+
params.callback = callback;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return buildUrl('https://maps.googleapis.com/maps/api/js', params);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
GoogleMapManager.prototype.getMap = function (id, option) {
|
|
59
|
+
var tag = document.getElementById(id);
|
|
60
|
+
return new google.maps.Map(tag, this.convertOption(option));
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
GoogleMapManager.prototype.drawMarkers = function (map, options) {
|
|
64
|
+
var _this = this;
|
|
65
|
+
|
|
66
|
+
return options.map(function (option) {
|
|
67
|
+
var converted = _this.convertMarkerOption(tslib.__assign({
|
|
68
|
+
map: map
|
|
69
|
+
}, option));
|
|
70
|
+
|
|
71
|
+
return new google.maps.Marker(converted);
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
GoogleMapManager.prototype.convertOption = function (option) {
|
|
76
|
+
var center = option.center,
|
|
77
|
+
maxZoom = option.maxZoom,
|
|
78
|
+
minZoom = option.minZoom,
|
|
79
|
+
zoom = option.zoom;
|
|
80
|
+
var lat = center.lat,
|
|
81
|
+
lng = center.lng;
|
|
82
|
+
var converted = {
|
|
83
|
+
center: {
|
|
84
|
+
lat: lat,
|
|
85
|
+
lng: lng
|
|
86
|
+
},
|
|
87
|
+
maxZoom: maxZoom,
|
|
88
|
+
minZoom: minZoom,
|
|
89
|
+
zoom: zoom
|
|
90
|
+
};
|
|
91
|
+
return converted;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
GoogleMapManager.prototype.convertMarkerOption = function (_a) {
|
|
95
|
+
var map = _a.map,
|
|
96
|
+
position = _a.position,
|
|
97
|
+
icon = _a.icon,
|
|
98
|
+
title = _a.title,
|
|
99
|
+
visible = _a.visible,
|
|
100
|
+
zIndex = _a.zIndex;
|
|
101
|
+
var option = {
|
|
102
|
+
map: map || this.map,
|
|
103
|
+
position: position
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
if (icon) {
|
|
107
|
+
var url = icon.url,
|
|
108
|
+
origin_1 = icon.origin,
|
|
109
|
+
anchor = icon.anchor,
|
|
110
|
+
scaledSize = icon.scaledSize;
|
|
111
|
+
option.icon = {
|
|
112
|
+
anchor: anchor && new google.maps.Point(anchor[0], anchor[1]),
|
|
113
|
+
origin: origin_1 && new google.maps.Point(origin_1[0], origin_1[1]),
|
|
114
|
+
scaledSize: scaledSize && new google.maps.Size(scaledSize[0], scaledSize[1]),
|
|
115
|
+
url: url
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (title) {
|
|
120
|
+
option.title = title;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (visible) {
|
|
124
|
+
option.visible = visible;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (zIndex) {
|
|
128
|
+
option.zIndex = zIndex;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return option;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
return GoogleMapManager;
|
|
135
|
+
})(MapManager);
|
|
136
|
+
|
|
137
|
+
classNames__default["default"].bind(styles$1);
|
|
138
|
+
|
|
139
|
+
var css_248z = ".NaverMap-module_naver-map-wrapper__dt2kP {\n position: relative;\n background-color: whitesmoke;\n}\n\n.NaverMap-module_naver-map__zTbF2 {\n width: 100%;\n height: 100%;\n}";
|
|
140
|
+
var styles = {"naver-map-wrapper":"NaverMap-module_naver-map-wrapper__dt2kP","naver-map":"NaverMap-module_naver-map__zTbF2"};
|
|
141
|
+
styleInject__default["default"](css_248z);
|
|
142
|
+
|
|
143
|
+
(function (_super) {
|
|
144
|
+
tslib.__extends(NaverMapManager, _super);
|
|
145
|
+
|
|
146
|
+
function NaverMapManager() {
|
|
147
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
NaverMapManager.prototype.getScriptUrl = function (libraries, callback) {
|
|
151
|
+
var params = {
|
|
152
|
+
ncpClientId: this.api
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
if (libraries) {
|
|
156
|
+
params.submodules = libraries.join(',');
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (callback) {
|
|
160
|
+
params.callback = callback;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return buildUrl('https://openapi.map.naver.com/openapi/v3/maps.js', params);
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
NaverMapManager.prototype.getMap = function (id, option) {
|
|
167
|
+
this.map = new naver.maps.Map(id, this.convertOption(option));
|
|
168
|
+
console.dir(this.map);
|
|
169
|
+
return new naver.maps.Map(id, this.convertOption(option));
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
NaverMapManager.prototype.drawMarkers = function (map, options) {
|
|
173
|
+
var _this = this;
|
|
174
|
+
|
|
175
|
+
console.dir(this.map);
|
|
176
|
+
return options.map(function (option) {
|
|
177
|
+
var converted = _this.convertMarkerOption(tslib.__assign({
|
|
178
|
+
map: map
|
|
179
|
+
}, option));
|
|
180
|
+
|
|
181
|
+
return new naver.maps.Marker(converted);
|
|
182
|
+
});
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
NaverMapManager.prototype.convertOption = function (_a) {
|
|
186
|
+
var center = _a.center,
|
|
187
|
+
maxZoom = _a.maxZoom,
|
|
188
|
+
minZoom = _a.minZoom,
|
|
189
|
+
zoom = _a.zoom;
|
|
190
|
+
var lat = center.lat,
|
|
191
|
+
lng = center.lng;
|
|
192
|
+
var converted = {
|
|
193
|
+
center: {
|
|
194
|
+
lat: lat,
|
|
195
|
+
lng: lng
|
|
196
|
+
},
|
|
197
|
+
zoom: zoom
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
if (maxZoom) {
|
|
201
|
+
converted.maxZoom = maxZoom;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if (minZoom) {
|
|
205
|
+
converted.minZoom = minZoom;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return converted;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
NaverMapManager.prototype.convertMarkerOption = function (_a) {
|
|
212
|
+
var map = _a.map,
|
|
213
|
+
position = _a.position,
|
|
214
|
+
icon = _a.icon,
|
|
215
|
+
title = _a.title,
|
|
216
|
+
visible = _a.visible,
|
|
217
|
+
zIndex = _a.zIndex;
|
|
218
|
+
var option = {
|
|
219
|
+
map: map || this.map,
|
|
220
|
+
position: position
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
if (icon) {
|
|
224
|
+
var url = icon.url,
|
|
225
|
+
size = icon.size,
|
|
226
|
+
origin_1 = icon.origin,
|
|
227
|
+
anchor = icon.anchor,
|
|
228
|
+
scaledSize = icon.scaledSize;
|
|
229
|
+
option.icon = {
|
|
230
|
+
anchor: anchor && new naver.maps.Point(anchor[0], anchor[1]),
|
|
231
|
+
origin: origin_1 && new naver.maps.Point(origin_1[0], origin_1[1]),
|
|
232
|
+
scaledSize: scaledSize && new naver.maps.Size(scaledSize[0], scaledSize[1]),
|
|
233
|
+
size: size && new naver.maps.Size(size[0], size[1]),
|
|
234
|
+
url: url
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
if (title) {
|
|
239
|
+
option.title = title;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
if (visible) {
|
|
243
|
+
option.visible = visible;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
if (zIndex) {
|
|
247
|
+
option.zIndex = zIndex;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
return option;
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
return NaverMapManager;
|
|
254
|
+
})(MapManager);
|
|
255
|
+
|
|
256
|
+
classNames__default["default"].bind(styles);
|
|
257
|
+
|
|
258
|
+
}));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { GoogleLibraryType } from '../../atom/GoogleMap/GoogleMap';
|
|
3
|
+
import { NaverLibraryType } from '../../atom/NaverMap/NaverMap';
|
|
4
|
+
import { MapManagerMarkerOptionsType, MapManagerOptionType, MapMarkerType } from '../../module/map/MapManager';
|
|
5
|
+
export declare type MapTypeType = 'naver' | 'google';
|
|
6
|
+
export interface MapProps extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement> {
|
|
7
|
+
api: string;
|
|
8
|
+
libraries?: NaverLibraryType[] | GoogleLibraryType[];
|
|
9
|
+
option?: MapManagerOptionType;
|
|
10
|
+
width: number | string;
|
|
11
|
+
height: number | string;
|
|
12
|
+
markers?: MapManagerMarkerOptionsType[];
|
|
13
|
+
onMarkerClick?: (e: Event, marker: MapMarkerType) => void;
|
|
14
|
+
}
|
|
15
|
+
export interface AllMapProps extends MapProps {
|
|
16
|
+
mapType: MapTypeType;
|
|
17
|
+
}
|
|
18
|
+
export default function Map({ mapType, ...props }: AllMapProps): JSX.Element | null;
|
package/package.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mint-ui/map",
|
|
3
|
+
"version": "2.1.1-alpha1",
|
|
4
|
+
"main": "./dist/index.js",
|
|
5
|
+
"module": "./dist/index.es.js",
|
|
6
|
+
"browser": "./dist/index.umd.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"repository": "https://github.com/itcode-dev/react-components-library-starter",
|
|
9
|
+
"author": "RWB0104 <psj2716@gmail.com>",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"private": false,
|
|
12
|
+
"devDependencies": {
|
|
13
|
+
"@babel/core": "^7.18.2",
|
|
14
|
+
"@rollup/plugin-babel": "^5.3.1",
|
|
15
|
+
"@rollup/plugin-commonjs": "^22.0.0",
|
|
16
|
+
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
17
|
+
"@rollup/plugin-typescript": "^8.3.2",
|
|
18
|
+
"@storybook/addon-actions": "^6.5.7",
|
|
19
|
+
"@storybook/addon-essentials": "^6.5.7",
|
|
20
|
+
"@storybook/addon-interactions": "^6.5.7",
|
|
21
|
+
"@storybook/addon-links": "^6.5.7",
|
|
22
|
+
"@storybook/builder-webpack5": "^6.5.7",
|
|
23
|
+
"@storybook/manager-webpack5": "^6.5.7",
|
|
24
|
+
"@storybook/preset-scss": "^1.0.3",
|
|
25
|
+
"@storybook/react": "^6.5.7",
|
|
26
|
+
"@storybook/testing-library": "^0.0.11",
|
|
27
|
+
"@types/classnames": "^2.3.1",
|
|
28
|
+
"@types/react": "^18.0.12",
|
|
29
|
+
"@typescript-eslint/eslint-plugin": "^5.27.0",
|
|
30
|
+
"@typescript-eslint/parser": "^5.27.0",
|
|
31
|
+
"babel-loader": "^8.2.5",
|
|
32
|
+
"babel-plugin-react-icons": "^0.1.1",
|
|
33
|
+
"css-loader": "^6.7.1",
|
|
34
|
+
"eslint": "^8.17.0",
|
|
35
|
+
"eslint-config-airbnb": "^19.0.4",
|
|
36
|
+
"eslint-config-prettier": "^8.5.0",
|
|
37
|
+
"eslint-plugin-import": "^2.26.0",
|
|
38
|
+
"eslint-plugin-jsx-a11y": "^6.5.1",
|
|
39
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
40
|
+
"eslint-plugin-react": "^7.30.0",
|
|
41
|
+
"eslint-plugin-react-hooks": "^4.5.0",
|
|
42
|
+
"eslint-plugin-sort-keys-fix": "^1.1.2",
|
|
43
|
+
"eslint-plugin-storybook": "^0.5.12",
|
|
44
|
+
"postcss": "^8.4.14",
|
|
45
|
+
"react": "^18.1.0",
|
|
46
|
+
"react-dom": "^18.1.0",
|
|
47
|
+
"rollup": "^2.75.5",
|
|
48
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
49
|
+
"rollup-plugin-postcss": "^4.0.2",
|
|
50
|
+
"sass": "^1.52.2",
|
|
51
|
+
"sass-loader": "^13.0.0",
|
|
52
|
+
"shx": "^0.3.4",
|
|
53
|
+
"style-loader": "^3.3.1",
|
|
54
|
+
"typescript": "^4.7.3"
|
|
55
|
+
},
|
|
56
|
+
"dependencies": {
|
|
57
|
+
"@types/google.maps": "^3.49.2",
|
|
58
|
+
"@types/navermaps": "^3.0.16",
|
|
59
|
+
"classnames": "^2.3.1",
|
|
60
|
+
"style-inject": "^0.3.0"
|
|
61
|
+
},
|
|
62
|
+
"scripts": {
|
|
63
|
+
"storybook": "start-storybook -p 3000",
|
|
64
|
+
"build-storybook": "build-storybook",
|
|
65
|
+
"prebuild": "shx rm -rf ./dist",
|
|
66
|
+
"build": "rollup -c",
|
|
67
|
+
"postbuild": "shx rm -rf ./dist/dist"
|
|
68
|
+
}
|
|
69
|
+
}
|