Skip to content

Commit 6500240

Browse files
authored
Merge pull request #15 from mj-studio-library/marker-cluster
Marker Clustering
2 parents 126e109 + a280feb commit 6500240

File tree

91 files changed

+3956
-2219
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+3956
-2219
lines changed

.eslintignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules/
2+
lib/
3+
expo-config-plugin/
4+
docs/

.eslintrc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"root": true,
3+
"extends": [
4+
"@react-native",
5+
"prettier"
6+
],
7+
"rules": {
8+
"prettier/prettier": [
9+
"error",
10+
{
11+
"quoteProps": "consistent",
12+
"singleQuote": true,
13+
"tabWidth": 2,
14+
"trailingComma": "es5",
15+
"useTabs": false
16+
}
17+
],
18+
"react-native/no-inline-styles": "off"
19+
}
20+
}

.github/workflows/ci.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ jobs:
2525
- name: Lint files
2626
run: yarn lint
2727

28-
- name: Typecheck files
29-
run: yarn typecheck
30-
3128
- name: Codegen
3229
run: yarn codegen
3330

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,6 @@ example/android/app/src/main/res/values/secret.xml
8282
example/ios/Secret.xcconfig
8383
.env
8484

85-
docs/
85+
docs/
86+
87+
example/.watchman-*

.husky/pre-commit

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
11
echo '🔥 pre-commit hook running...'
2-
yarn lint
3-
yarn typecheck
4-
yarn lint:clang
5-
yarn build:expo-config-plugin
6-
git add expo-config-plugin
2+
yarn lint

.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"quoteProps": "consistent",
3+
"singleQuote": true,
4+
"tabWidth": 2,
5+
"trailingComma": "es5",
6+
"useTabs": false
7+
}

CONTRIBUTING.md

Lines changed: 44 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,50 @@ Contributions are always welcome, no matter how large or small!
44

55
We want this community to be friendly and respectful to each other. Please follow it in all your interactions with the project. Before contributing, please read the [code of conduct](./CODE_OF_CONDUCT.md).
66

7+
### Scripts
8+
9+
The `package.json` file contains various scripts for common tasks:
10+
11+
**Installiation, Build**
12+
13+
- `yarn`: setup project by installing dependencies.
14+
- `yarn prepack`: build package (including docs, expo config plugin)
15+
- `yarn build:docs`: build documentation at `./docs`.
16+
- `yarn build:expo-config-plugin`: build expo config plugin.
17+
18+
**Validation**
19+
20+
- `yarn lint`: lint files with ESLint, ClangFormat, Ktlint, TypeScript
21+
- `yarn t`: alias for lint
22+
- `yarn test`: run unit tests with Jest
23+
- `yarn format:ios`: run formatter with ClangFormat, SwiftFormat for iOS codes
24+
- `yarn format:android`: run formatter with Ktlint for Android codes
25+
26+
**Example App Build, Manipluations**
27+
28+
- `yarn example start`: start the Metro server for the example app.
29+
- `yarn example android`: run the example app on Android.
30+
- `yarn example ios`: run the example app on iOS.
31+
- `yarn codegen:{android,ios}`: generate codegen output for development typing (this should be clean for running example app, prevetning redelcaration compile error)
32+
33+
**Architecture Convert**
34+
35+
- `new`: convert example project to new architecture
36+
- `old`: convert example project to old architecture
37+
- `new:pod`: convert example project to new architecture with pod install
38+
- `old:pod`: convert example project to old architecture with pod install
39+
40+
**Util**
41+
42+
- `yarn studio`: open android studio for example project
43+
- `yarn xcode`: open xcode for example project
44+
45+
**Codegen**
46+
47+
- `yarn codegen`: generate codegen spec for all platform
48+
- `yarn codegen:android`: generate android codegen spec
49+
- `yarn codegen:ios`: generate ios codegen spec
50+
751
## Development workflow
852

953
This project is a monorepo managed using [Yarn workspaces](https://yarnpkg.com/features/workspaces). It contains the following packages:
@@ -163,25 +207,6 @@ You can check generated docs with `yarn build:docs` command.
163207

164208
The documentation is published on push main branch automatically.
165209

166-
### Scripts
167-
168-
The `package.json` file contains various scripts for common tasks:
169-
170-
- `yarn`: setup project by installing dependencies.
171-
- `yarn typecheck`: type-check files with TypeScript.
172-
- `yarn lint`: lint files with ESLint.
173-
- `yarn format:clang`: format files with clang-format.
174-
- `yarn lint:clang`: lint files with clang-format.
175-
- `yarn test`: run unit tests with Jest.
176-
- `yarn example start`: start the Metro server for the example app.
177-
- `yarn example android`: run the example app on Android.
178-
- `yarn example ios`: run the example app on iOS.
179-
- `yarn codegen:{android,ios}`: generate codegen output for development typing (this should be clean for running example app, prevetning redelcaration compile error)
180-
- `yarn studio`: open android studio
181-
- `yarn studio:example`: open android studio for example project
182-
- `yarn xcode`: open xcode for example project
183-
- `yarn build:docs`: build documentation at `./docs`.
184-
185210
### Sending a pull request
186211

187212
> **Working on your first pull request?** You can learn how from this _free_ series: [How to Contribute to an Open Source Project on GitHub](https://app.egghead.io/playlists/how-to-contribute-to-an-open-source-project-on-github).

README.md

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
리액트 네이티브 [Naver Map](https://www.ncloud.com/product/applicationService/maps) 컴포넌트입니다.
2525

26-
<img src="https://raw.githubusercontent.com/mym0404/image-archive/master/202404152351235.webp" width="500" alt="preview">
26+
<img src="https://raw.githubusercontent.com/mym0404/image-archive/master/202404240329848.gif" width="400" alt="preview">
2727

2828
>[!NOTE]
2929
>마커 클러스터링을 개발중입니다.
@@ -388,7 +388,7 @@ yarn add react-native-permissions
388388
```
389389

390390
`react-native-permission`의 각 플랫폼별 설정 방법은 [사용법](https://github.com/zoontek/react-native-permissions#setup)을 직접 참고해
391-
`Podfile(iOS)`, `AndroidManifest.xml(Android)` 를 적절히 변경해주시길 바랍니다.
391+
`Podfile(iOS)`, `AndroidManifest.xml(Android)` 를 적절히 변경해주시길 바랍니다.
392392

393393
#### iOS
394394

@@ -490,7 +490,7 @@ useEffect(() => {
490490
/**
491491
* Note: Foreground permissions should be granted before asking for the background permissions
492492
* (your app can't obtain background permission without foreground permission).
493-
*/
493+
*/
494494
if(granted) {
495495
await Location.requestBackgroundPermissionsAsync();
496496
}
@@ -537,7 +537,7 @@ useEffect(() => {
537537
538538
> [!TIP]
539539
> `reuseIdentifier`는 전달하지 않아도 모두 자동으로 캐싱이 됩니다.
540-
>
540+
>
541541
> 되도록이면 마커는 모두 `width`, `height` prop을 사용해야합니다. 2번 타입의 경우 현재 debug/release 빌드의 크기가 `width`, `height`없이 다르게 나오는 현상이 있습니다.
542542
> release에서는 제대로 나옵니다.
543543
@@ -576,7 +576,7 @@ image={{httpUri: 'https://example.com/image.png'}}
576576
iOS(new arch)에선 현재 View들에 `collapsable=false`를 설정해야 동작합니다.
577577

578578
> [!TIP]
579-
> 마커의 생김새를 바꿔야 한다면 그것에 대한 의존성들을 제일 상위 자식의 `key`로 전달해야합니다.
579+
> 마커의 생김새를 바꿔야 한다면 그것에 대한 의존성들을 제일 상위 자식의 `key`로 전달해야합니다.
580580
581581
```tsx
582582
<NaverMapMarkerOverlay width={width} height={height} ...>
@@ -612,8 +612,6 @@ iOS에선 단순히 `UIView`를 `UIImage`로 캔버스에 그려 표시해줍니
612612
| Prop | iOS | Android |
613613
|--------------------------|-----|---------|
614614
| isLogoInteractionEnabled |||
615-
| isUseTextureViewAndroid |||
616-
| markerClustering | 📦 | 📦 |
617615
| fpsLimit | 📦 | 📦 |
618616
| gestureFrictions | 📦 | 📦 |
619617

@@ -631,7 +629,6 @@ iOS에선 단순히 `UIView`를 `UIImage`로 캔버스에 그려 표시해줍니
631629
|----------------------------|-----|---------|
632630
| screenToCoordinate | 📦 | 📦 |
633631
| coordinateToScreen | 📦 | 📦 |
634-
| clusterMarkers | 📦 | 📦 |
635632

636633
### Marker Common
637634

@@ -677,8 +674,8 @@ iOS에선 단순히 `UIView`를 `UIImage`로 캔버스에 그려 표시해줍니
677674
- [x] Release (23.04.11)
678675
- [x] Support Expo with config plugin (23.04.12)
679676
- [x] Docs
680-
- [ ] Implement Clustering <- 🔥
681-
- [ ] Implement MutlPath, Arrow, Geometry Overlays
677+
- [x] Implement Clustering (23.04.24)
678+
- [ ] Implement MutlPath, Arrow, Geometry Overlays <- 🔥
682679

683680
## Contributing
684681

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ dependencies {
110110
implementation "com.facebook.react:react-native:+"
111111
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
112112
implementation "com.naver.maps:map-sdk:${getExtOrDefault("sdkVersion")}"
113-
implementation "com.google.android.gms:play-services-location:${getExtOrDefault("locationServviceVersion")}"
113+
implementation "com.google.android.gms:play-services-location:${getExtOrDefault("locationServiceVersion")}"
114114
}
115115

116116
if (isNewArchitectureEnabled()) {

android/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ NaverMap_targetSdkVersion=31
44
NaverMap_compileSdkVersion=31
55
NaverMap_ndkversion=21.4.7075529
66
NaverMap_sdkVersion=3.18.0
7-
NaverMap_locationServviceVersion=21.2.0
7+
NaverMap_locationServiceVersion=21.2.0

android/src/main/java/com/mjstudio/reactnativenavermap/RNCNaverMapPackage.kt

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,19 @@ import com.mjstudio.reactnativenavermap.overlay.path.RNCNaverMapPathManager
1111
import com.mjstudio.reactnativenavermap.overlay.polygon.RNCNaverMapPolygonManager
1212
import com.mjstudio.reactnativenavermap.overlay.polyline.RNCNaverMapPolylineManager
1313

14-
class NaverMapViewPackage : ReactPackage {
15-
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
16-
return mutableListOf<ViewManager<*, *>>().apply {
17-
add(RNCNaverMapViewManager())
18-
add(RNCNaverMapMarkerManager())
19-
add(RNCNaverMapCircleManager())
20-
add(RNCNaverMapPolygonManager())
21-
add(RNCNaverMapPolylineManager())
22-
add(RNCNaverMapPathManager())
23-
}
24-
}
25-
26-
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
27-
return emptyList()
14+
class RNCNaverMapPackage : ReactPackage {
15+
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
16+
return mutableListOf<ViewManager<*, *>>().apply {
17+
add(RNCNaverMapViewManager())
18+
add(RNCNaverMapMarkerManager())
19+
add(RNCNaverMapCircleManager())
20+
add(RNCNaverMapPolygonManager())
21+
add(RNCNaverMapPolylineManager())
22+
add(RNCNaverMapPathManager())
2823
}
24+
}
2925

26+
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
27+
return emptyList()
28+
}
3029
}

android/src/main/java/com/mjstudio/reactnativenavermap/event/NaverMapCameraChangeEvent.kt

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,32 @@ import com.facebook.react.bridge.WritableMap
55
import com.facebook.react.uimanager.events.Event
66

77
class NaverMapCameraChangeEvent(
8-
surfaceId: Int,
9-
viewId: Int,
10-
private val latitude: Double,
11-
private val longitude: Double,
12-
private val zoom: Double,
13-
private val tilt: Double,
14-
private val bearing: Double,
15-
private val reason: Int,
8+
surfaceId: Int,
9+
viewId: Int,
10+
private val latitude: Double,
11+
private val longitude: Double,
12+
private val zoom: Double,
13+
private val tilt: Double,
14+
private val bearing: Double,
15+
private val reason: Int,
1616
) : Event<NaverMapCameraChangeEvent>(surfaceId, viewId) {
17-
override fun getEventName(): String = EVENT_NAME
18-
override fun canCoalesce(): Boolean = false
19-
override fun getCoalescingKey(): Short = 0
20-
override fun getEventData(): WritableMap = Arguments.createMap().apply {
21-
putDouble("latitude", latitude)
22-
putDouble("longitude", longitude)
23-
putDouble("zoom", zoom)
24-
putDouble("tilt", tilt)
25-
putDouble("bearing", bearing)
26-
putInt("reason", reason)
27-
}
17+
override fun getEventName(): String = EVENT_NAME
18+
19+
override fun canCoalesce(): Boolean = false
20+
21+
override fun getCoalescingKey(): Short = 0
2822

29-
companion object {
30-
const val EVENT_NAME = "onCameraChanged"
23+
override fun getEventData(): WritableMap =
24+
Arguments.createMap().apply {
25+
putDouble("latitude", latitude)
26+
putDouble("longitude", longitude)
27+
putDouble("zoom", zoom)
28+
putDouble("tilt", tilt)
29+
putDouble("bearing", bearing)
30+
putInt("reason", reason)
3131
}
32-
}
3332

33+
companion object {
34+
const val EVENT_NAME = "onCameraChanged"
35+
}
36+
}

android/src/main/java/com/mjstudio/reactnativenavermap/event/NaverMapInitializeEvent.kt

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ import com.facebook.react.bridge.WritableMap
55
import com.facebook.react.uimanager.events.Event
66

77
class NaverMapInitializeEvent(surfaceId: Int, viewId: Int) : Event<NaverMapInitializeEvent>(surfaceId, viewId) {
8-
override fun getEventName(): String = EVENT_NAME
9-
override fun canCoalesce(): Boolean = false
10-
override fun getCoalescingKey(): Short = 0
11-
override fun getEventData(): WritableMap = Arguments.createMap()
8+
override fun getEventName(): String = EVENT_NAME
129

13-
companion object {
14-
const val EVENT_NAME = "onInitialized"
15-
}
16-
}
10+
override fun canCoalesce(): Boolean = false
11+
12+
override fun getCoalescingKey(): Short = 0
1713

14+
override fun getEventData(): WritableMap = Arguments.createMap()
15+
16+
companion object {
17+
const val EVENT_NAME = "onInitialized"
18+
}
19+
}

android/src/main/java/com/mjstudio/reactnativenavermap/event/NaverMapOptionChangeEvent.kt

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ import com.facebook.react.bridge.WritableMap
55
import com.facebook.react.uimanager.events.Event
66

77
class NaverMapOptionChangeEvent(surfaceId: Int, viewId: Int) : Event<NaverMapOptionChangeEvent>(surfaceId, viewId) {
8-
override fun getEventName(): String = EVENT_NAME
9-
override fun canCoalesce(): Boolean = false
10-
override fun getCoalescingKey(): Short = 0
11-
override fun getEventData(): WritableMap = Arguments.createMap()
8+
override fun getEventName(): String = EVENT_NAME
129

13-
companion object {
14-
const val EVENT_NAME = "onOptionChanged"
15-
}
16-
}
10+
override fun canCoalesce(): Boolean = false
11+
12+
override fun getCoalescingKey(): Short = 0
1713

14+
override fun getEventData(): WritableMap = Arguments.createMap()
15+
16+
companion object {
17+
const val EVENT_NAME = "onOptionChanged"
18+
}
19+
}

android/src/main/java/com/mjstudio/reactnativenavermap/event/NaverMapOverlayTapEvent.kt

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,18 @@ import com.facebook.react.bridge.WritableMap
55
import com.facebook.react.uimanager.events.Event
66

77
class NaverMapOverlayTapEvent(
8-
surfaceId: Int,
9-
viewId: Int,
8+
surfaceId: Int,
9+
viewId: Int,
1010
) : Event<NaverMapOverlayTapEvent>(surfaceId, viewId) {
11-
override fun getEventName(): String = EVENT_NAME
12-
override fun canCoalesce(): Boolean = false
13-
override fun getCoalescingKey(): Short = 0
14-
override fun getEventData(): WritableMap = Arguments.createMap()
11+
override fun getEventName(): String = EVENT_NAME
1512

16-
companion object {
17-
const val EVENT_NAME = "onTapOverlay"
18-
}
19-
}
13+
override fun canCoalesce(): Boolean = false
14+
15+
override fun getCoalescingKey(): Short = 0
2016

17+
override fun getEventData(): WritableMap = Arguments.createMap()
18+
19+
companion object {
20+
const val EVENT_NAME = "onTapOverlay"
21+
}
22+
}

0 commit comments

Comments
 (0)