@react-native-kakao/map 2.2.1

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.
Files changed (68) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +42 -0
  3. package/RNCKakaoMap.podspec +56 -0
  4. package/android/build.gradle +117 -0
  5. package/android/gradle.properties +1 -0
  6. package/android/src/main/AndroidManifest.xml +1 -0
  7. package/android/src/main/AndroidManifestNew.xml +2 -0
  8. package/android/src/main/java/net/mjstudio/rnkakao/map/RNCKakaoMapModule.kt +24 -0
  9. package/android/src/main/java/net/mjstudio/rnkakao/map/RNCKakaoMapPackage.kt +37 -0
  10. package/android/src/newarch/KakaoMapSpec.kt +6 -0
  11. package/android/src/oldarch/KakaoMapSpec.kt +13 -0
  12. package/ios/Component/Map/RNCKakaoMapView.h +24 -0
  13. package/ios/Component/Map/RNCKakaoMapView.mm +208 -0
  14. package/ios/Component/Map/RNCKakaoMapViewManager.mm +19 -0
  15. package/ios/NativeModule/RNCKakaoMap.h +7 -0
  16. package/ios/NativeModule/RNCKakaoMap.mm +19 -0
  17. package/ios/NativeModule/RNCKakaoMapManager.swift +7 -0
  18. package/ios/Util/Util.h +97 -0
  19. package/lib/commonjs/component/KakaoMapView.js +54 -0
  20. package/lib/commonjs/component/KakaoMapView.js.map +1 -0
  21. package/lib/commonjs/index.js +38 -0
  22. package/lib/commonjs/index.js.map +1 -0
  23. package/lib/commonjs/spec/NativeKakaoMap.js +9 -0
  24. package/lib/commonjs/spec/NativeKakaoMap.js.map +1 -0
  25. package/lib/commonjs/spec/RNCKakaoMapViewNativeComponent.js +15 -0
  26. package/lib/commonjs/spec/RNCKakaoMapViewNativeComponent.js.map +1 -0
  27. package/lib/commonjs/type/type.js +2 -0
  28. package/lib/commonjs/type/type.js.map +1 -0
  29. package/lib/commonjs/util/Const.js +14 -0
  30. package/lib/commonjs/util/Const.js.map +1 -0
  31. package/lib/commonjs/util/Util.js +15 -0
  32. package/lib/commonjs/util/Util.js.map +1 -0
  33. package/lib/module/component/KakaoMapView.js +48 -0
  34. package/lib/module/component/KakaoMapView.js.map +1 -0
  35. package/lib/module/index.js +26 -0
  36. package/lib/module/index.js.map +1 -0
  37. package/lib/module/spec/NativeKakaoMap.js +3 -0
  38. package/lib/module/spec/NativeKakaoMap.js.map +1 -0
  39. package/lib/module/spec/RNCKakaoMapViewNativeComponent.js +10 -0
  40. package/lib/module/spec/RNCKakaoMapViewNativeComponent.js.map +1 -0
  41. package/lib/module/type/type.js +2 -0
  42. package/lib/module/type/type.js.map +1 -0
  43. package/lib/module/util/Const.js +8 -0
  44. package/lib/module/util/Const.js.map +1 -0
  45. package/lib/module/util/Util.js +9 -0
  46. package/lib/module/util/Util.js.map +1 -0
  47. package/lib/typescript/src/component/KakaoMapView.d.ts +25 -0
  48. package/lib/typescript/src/component/KakaoMapView.d.ts.map +1 -0
  49. package/lib/typescript/src/index.d.ts +10 -0
  50. package/lib/typescript/src/index.d.ts.map +1 -0
  51. package/lib/typescript/src/spec/NativeKakaoMap.d.ts +7 -0
  52. package/lib/typescript/src/spec/NativeKakaoMap.d.ts.map +1 -0
  53. package/lib/typescript/src/spec/RNCKakaoMapViewNativeComponent.d.ts +32 -0
  54. package/lib/typescript/src/spec/RNCKakaoMapViewNativeComponent.d.ts.map +1 -0
  55. package/lib/typescript/src/type/type.d.ts +8 -0
  56. package/lib/typescript/src/type/type.d.ts.map +1 -0
  57. package/lib/typescript/src/util/Const.d.ts +8 -0
  58. package/lib/typescript/src/util/Const.d.ts.map +1 -0
  59. package/lib/typescript/src/util/Util.d.ts +3 -0
  60. package/lib/typescript/src/util/Util.d.ts.map +1 -0
  61. package/package.json +117 -0
  62. package/src/component/KakaoMapView.tsx +82 -0
  63. package/src/index.ts +43 -0
  64. package/src/spec/NativeKakaoMap.ts +8 -0
  65. package/src/spec/RNCKakaoMapViewNativeComponent.ts +38 -0
  66. package/src/type/type.ts +7 -0
  67. package/src/util/Const.ts +7 -0
  68. package/src/util/Util.ts +11 -0
package/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 MJ Studio
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,42 @@
1
+ <p align="center">
2
+ <a href="https://rnkakao.dev">
3
+ <img width="160px" src="https://raw.githubusercontent.com/mym0404/image-archive/master/202404201234177.webp"><br/>
4
+ </a>
5
+ <h1 align="center">React Native Kakao Map</h1>
6
+ <p align="center">
7
+ <a href="https://www.npmjs.com/package/@react-native-kakao/core"><img src="https://img.shields.io/npm/dm/@react-native-kakao/core.svg?style=flat-square" alt="NPM downloads"></a>
8
+ <a href="https://www.npmjs.com/package/@react-native-kakao/core"><img src="https://img.shields.io/npm/v/@react-native-kakao/core.svg?style=flat-square" alt="NPM version"></a>
9
+ <a href="/LICENSE"><img src="https://img.shields.io/npm/l/@react-native-kakao/core.svg?style=flat-square" alt="License"></a>
10
+ <a href="https://github.com/lerna-lite/lerna-lite"><img src="https://img.shields.io/badge/maintained%20with-lerna--lite-e137ff?style=flat-square" alt="License"></a>
11
+ <h3 align="center">Native Kakao SDK All In One Solution</h3>
12
+ </p>
13
+ </p>
14
+ <a href="https://rnkakao.dev">Documentation</a>
15
+
16
+
17
+ ## Documentation
18
+
19
+ - [Quick Start](https://rnkakao.dev)
20
+
21
+ ## Contributing
22
+
23
+ - [Contributing](https://github.com/mym0404/react-native-kakao/blob/main/CONTRIBUTING.md)
24
+ - [Issues](https://github.com/mym0404/react-native-kakao/issues)
25
+ - [PRs](https://github.com/mym0404/react-native-kakao/pulls)
26
+ - [Documentation](https://rnkakao.dev)
27
+ - [Code of Conduct](https://github.com/mym0404/react-native-kakao/blob/main/CODE_OF_CONDUCT.md)
28
+
29
+ ## License
30
+
31
+ - See [LICENSE](/LICENSE)
32
+
33
+ ---
34
+
35
+ <p align="center">
36
+ <a href="https://mjstudio.net/">
37
+ <img width="75px" src="https://raw.githubusercontent.com/mym0404/image-archive/master/202404201239152.webp">
38
+ </a>
39
+ <p align="center">
40
+ Built and maintained by <a href="https://mjstudio.net/">MJ Studio</a>.
41
+ </p>
42
+ </p>
@@ -0,0 +1,56 @@
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+ corePackage = JSON.parse(File.read(File.join(__dir__, "..", "core", "package.json")))
5
+ sdk_version = corePackage['sdkVersions']['ios']['map']
6
+
7
+ folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
8
+
9
+ Pod::Spec.new do |s|
10
+ s.name = "RNCKakaoMap"
11
+ s.version = package["version"]
12
+ s.summary = package["description"]
13
+ s.homepage = package["homepage"]
14
+ s.license = package["license"]
15
+ s.authors = package["author"]
16
+
17
+ s.platforms = { :ios => min_ios_version_supported }
18
+ s.source = { :git => "https://github.com/mym0404/react-native-kakao.git", :tag => "#{s.version}" }
19
+
20
+ s.source_files = "ios/**/*.{h,m,mm}"
21
+
22
+ # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
23
+ # See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
24
+ if respond_to?(:install_modules_dependencies, true)
25
+ install_modules_dependencies(s)
26
+ else
27
+ s.dependency "React-Core"
28
+
29
+ # Don't install the dependencies when we run `pod install` in the old architecture.
30
+ if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
31
+ s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
32
+ s.pod_target_xcconfig = {
33
+ "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
34
+ "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
35
+ "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
36
+ }
37
+ s.dependency "React-RCTFabric"
38
+ s.dependency "React-Codegen"
39
+ s.dependency "RCT-Folly"
40
+ s.dependency "RCTRequired"
41
+ s.dependency "RCTTypeSafety"
42
+ s.dependency "ReactCommon/turbomodule/core"
43
+ end
44
+ end
45
+
46
+ # Override Version by User
47
+ if defined?($KakaoMapSDKVersion)
48
+ Pod::UI.puts "#{s.name}: Using user specified Kakao SDK version '#{$KakaoMapSDKVersion}'"
49
+ sdk_version = $KakaoMapSDKVersion
50
+ end
51
+
52
+ s.dependency 'RNCKakaoCore'
53
+
54
+ # Kakao dependencies
55
+ s.dependency 'KakaoMapsSDK', sdk_version
56
+ end
@@ -0,0 +1,117 @@
1
+ apply from: file('./../../core/android/package-json.gradle')
2
+ def Versions = project.ext.RNCKakaoSdkVersions
3
+ Project coreProject = project.ext.getWorkspaceProject("core")
4
+
5
+ buildscript {
6
+ // Buildscript is evaluated before everything else so we can't use getExtOrDefault
7
+ def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["Kakao_kotlinVersion"]
8
+
9
+ repositories {
10
+ google()
11
+ mavenCentral()
12
+ }
13
+
14
+ dependencies {
15
+ classpath "com.android.tools.build:gradle:7.2.1"
16
+ // noinspection DifferentKotlinGradleVersion
17
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
18
+ }
19
+ }
20
+
21
+ def isNewArchitectureEnabled() {
22
+ return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
23
+ }
24
+
25
+ apply plugin: "com.android.library"
26
+ apply plugin: "kotlin-android"
27
+
28
+ if (isNewArchitectureEnabled()) {
29
+ apply plugin: "com.facebook.react"
30
+ }
31
+
32
+ def supportsNamespace() {
33
+ def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
34
+ def major = parsed[0].toInteger()
35
+ def minor = parsed[1].toInteger()
36
+
37
+ // Namespace support was added in 7.3.0
38
+ return (major == 7 && minor >= 3) || major >= 8
39
+ }
40
+
41
+ android {
42
+ if (supportsNamespace()) {
43
+ namespace "net.mjstudio.rnkakao.map"
44
+
45
+ sourceSets {
46
+ main {
47
+ manifest.srcFile "src/main/AndroidManifestNew.xml"
48
+ }
49
+ }
50
+ }
51
+
52
+ compileSdkVersion Versions.compileSdk
53
+
54
+ defaultConfig {
55
+ minSdkVersion Versions.minSdk
56
+ targetSdkVersion Versions.targetSdk
57
+ buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
58
+ }
59
+
60
+ buildFeatures {
61
+ buildConfig true
62
+ }
63
+
64
+ buildTypes {
65
+ release {
66
+ minifyEnabled false
67
+ }
68
+ }
69
+
70
+ lintOptions {
71
+ disable "GradleCompatible"
72
+ }
73
+
74
+ compileOptions {
75
+ sourceCompatibility JavaVersion.VERSION_1_8
76
+ targetCompatibility JavaVersion.VERSION_1_8
77
+ }
78
+
79
+
80
+ sourceSets {
81
+ main {
82
+ if (isNewArchitectureEnabled()) {
83
+ java.srcDirs += [
84
+ "src/newarch",
85
+ // This is needed to build Kotlin project with NewArch enabled
86
+ "${project.buildDir}/generated/source/codegen/java"
87
+ ]
88
+ } else {
89
+ java.srcDirs += ["src/oldarch"]
90
+ }
91
+ }
92
+ }
93
+ }
94
+
95
+ repositories {
96
+ mavenCentral()
97
+ google()
98
+ }
99
+
100
+ dependencies {
101
+ // For < 0.71, this will be from the local maven repo
102
+ // For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
103
+ //noinspection GradleDynamicVersion
104
+ implementation "com.facebook.react:react-native:+"
105
+ implementation "org.jetbrains.kotlin:kotlin-stdlib:${Versions.kotlin}"
106
+
107
+ api coreProject
108
+ implementation "com.kakao.maps.open:android:${Versions.map}"
109
+ }
110
+
111
+ if (isNewArchitectureEnabled()) {
112
+ react {
113
+ jsRootDir = file("../src/")
114
+ libraryName = "RNCKakaoMap"
115
+ codegenJavaPackageName = "net.mjstudio.rnkakao.map"
116
+ }
117
+ }
@@ -0,0 +1 @@
1
+ Kakao_kotlinVersion=1.7.0
@@ -0,0 +1 @@
1
+ <manifest package="net.mjstudio.rnkakao.map"></manifest>
@@ -0,0 +1,2 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ </manifest>
@@ -0,0 +1,24 @@
1
+ package net.mjstudio.rnkakao.map
2
+
3
+ import com.facebook.react.bridge.Promise
4
+ import com.facebook.react.bridge.ReactApplicationContext
5
+ import com.kakao.vectormap.KakaoMapSdk
6
+
7
+ class RNCKakaoMapModule internal constructor(context: ReactApplicationContext) :
8
+ KakaoMapSpec(context) {
9
+ override fun getName(): String {
10
+ return NAME
11
+ }
12
+
13
+ override fun initializeKakaoMapSDK(
14
+ appKey: String,
15
+ promise: Promise,
16
+ ) {
17
+ KakaoMapSdk.init(reactApplicationContext, appKey)
18
+ promise.resolve(42)
19
+ }
20
+
21
+ companion object {
22
+ const val NAME = "RNCKakaoMap"
23
+ }
24
+ }
@@ -0,0 +1,37 @@
1
+ package net.mjstudio.rnkakao.map
2
+
3
+ import com.facebook.react.TurboReactPackage
4
+ import com.facebook.react.bridge.NativeModule
5
+ import com.facebook.react.bridge.ReactApplicationContext
6
+ import com.facebook.react.module.model.ReactModuleInfo
7
+ import com.facebook.react.module.model.ReactModuleInfoProvider
8
+
9
+ class RNCKakaoMapPackage : TurboReactPackage() {
10
+ override fun getModule(
11
+ name: String,
12
+ reactContext: ReactApplicationContext,
13
+ ): NativeModule? {
14
+ return if (name == RNCKakaoMapModule.NAME) {
15
+ RNCKakaoMapModule(reactContext)
16
+ } else {
17
+ null
18
+ }
19
+ }
20
+
21
+ override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
22
+ return ReactModuleInfoProvider {
23
+ val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
24
+ val isTurboModule: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
25
+ moduleInfos[RNCKakaoMapModule.NAME] =
26
+ ReactModuleInfo(
27
+ RNCKakaoMapModule.NAME,
28
+ RNCKakaoMapModule.NAME,
29
+ false, // canOverrideExistingModule
30
+ false, // needsEagerInit
31
+ false, // isCxxModule
32
+ isTurboModule, // isTurboModule
33
+ )
34
+ moduleInfos
35
+ }
36
+ }
37
+ }
@@ -0,0 +1,6 @@
1
+ package net.mjstudio.rnkakao.map
2
+
3
+ import com.facebook.react.bridge.ReactApplicationContext
4
+
5
+ abstract class KakaoMapSpec internal constructor(context: ReactApplicationContext) :
6
+ NativeKakaoMapSpec(context)
@@ -0,0 +1,13 @@
1
+ package net.mjstudio.rnkakao.map
2
+
3
+ import com.facebook.react.bridge.Promise
4
+ import com.facebook.react.bridge.ReactApplicationContext
5
+ import com.facebook.react.bridge.ReactContextBaseJavaModule
6
+
7
+ abstract class KakaoMapSpec internal constructor(context: ReactApplicationContext) :
8
+ ReactContextBaseJavaModule(context) {
9
+ abstract fun initializeKakaoMapSDK(
10
+ appKey: String,
11
+ promise: Promise,
12
+ )
13
+ }
@@ -0,0 +1,24 @@
1
+ //
2
+ // RNCKakaoMapView.h
3
+ // RNCKakaoMap
4
+ //
5
+ // Created by mj on 5/5/24.
6
+ //
7
+
8
+ #import "RCTFabricComponentsPlugins.h"
9
+ #import "Util.h"
10
+ #import <KakaoMapsSDK/KakaoMapsSDK-Swift.h>
11
+ #import <KakaoMapsSDK/KakaoMapsSDK.h>
12
+ #import <React/RCTViewComponentView.h>
13
+ #import <React/UIView+ComponentViewProtocol.h>
14
+ #import <UIKit/UIKit.h>
15
+ #import <react/renderer/components/RNCKakaoMapSpec/ComponentDescriptors.h>
16
+ #import <react/renderer/components/RNCKakaoMapSpec/EventEmitters.h>
17
+ #import <react/renderer/components/RNCKakaoMapSpec/Props.h>
18
+ #import <react/renderer/components/RNCKakaoMapSpec/RCTComponentViewHelpers.h>
19
+
20
+ @interface RNCKakaoMapView : RCTViewComponentView
21
+
22
+ @property(nonatomic, assign) double cameraAnimationDuration;
23
+
24
+ @end
@@ -0,0 +1,208 @@
1
+ //
2
+ // RNCKakaoMapView.m
3
+ // RNCKakaoMap
4
+ //
5
+ // Created by mj on 5/5/24.
6
+ //
7
+
8
+ #import "RNCKakaoMapView.h"
9
+
10
+ using namespace facebook::react;
11
+
12
+ NSString* MAP_VIEW_NAME = @"mapview";
13
+ NSString* MAP_VIEW_INFO_SKYVIEW_NAME = @"skyview";
14
+ NSString* MAP_VIEW_INFO_MAP_NAME = @"map";
15
+ NSString* APP_NAME = @"openmap";
16
+
17
+ @interface RNCKakaoMapView () <RCTRNCKakaoMapViewViewProtocol, MapControllerDelegate>
18
+ @end
19
+
20
+ @implementation RNCKakaoMapView {
21
+ BOOL _isAuthSuccess;
22
+ KMViewContainer* _container;
23
+ KMController* _controller;
24
+ BOOL _shouldForceUpdatePropsForInitialRender;
25
+ }
26
+
27
+ - (instancetype)initWithFrame:(CGRect)frame {
28
+ if (self = [super initWithFrame:frame]) {
29
+ static const auto defaultProps = std::make_shared<const RNCKakaoMapViewProps>();
30
+ _props = defaultProps;
31
+
32
+ _container = [[KMViewContainer alloc] init];
33
+ _controller = [[KMController alloc] initWithViewContainer:_container];
34
+ [_controller clearDiskCache];
35
+ _controller.delegate = self;
36
+
37
+ [_controller prepareEngine];
38
+ self.contentView = _container;
39
+ }
40
+
41
+ return self;
42
+ }
43
+
44
+ - (void)dealloc {
45
+ [_controller pauseEngine];
46
+ [_controller resetEngine];
47
+ }
48
+
49
+ - (KakaoMap*)map {
50
+ return static_cast<KakaoMap*>([_controller getView:MAP_VIEW_NAME]);
51
+ }
52
+
53
+ - (void)updateProps:(Props::Shared const&)props oldProps:(Props::Shared const&)oldProps {
54
+ BOOL (^check)(BOOL) = ^(BOOL condition) {
55
+ if (!self.map)
56
+ return NO;
57
+ return self->_shouldForceUpdatePropsForInitialRender || condition;
58
+ };
59
+ const auto& p = *std::static_pointer_cast<RNCKakaoMapViewProps const>(_props);
60
+ const auto& n = *std::static_pointer_cast<RNCKakaoMapViewProps const>(props);
61
+
62
+ _cameraAnimationDuration = n.cameraAnimationDuration;
63
+
64
+ if (check(p.baseMapType != n.baseMapType))
65
+ [self.map changeViewInfoWithAppName:APP_NAME viewInfoName:getNsStr(n.baseMapType)];
66
+ if (check(p.overlays != n.overlays)) {
67
+ if (has(n.overlays, "hill_shading")) {
68
+ [self.map showOverlay:@"hill_shading"];
69
+ } else {
70
+ [self.map hideOverlay:@"hill_shading"];
71
+ }
72
+ if (has(n.overlays, "roadview_line")) {
73
+ [self.map showOverlay:@"roadview_line"];
74
+ } else {
75
+ [self.map hideOverlay:@"roadview_line"];
76
+ }
77
+ if (has(n.overlays, "bicycle_road")) {
78
+ [self.map showOverlay:@"bicycle_road"];
79
+ } else {
80
+ [self.map hideOverlay:@"bicycle_road"];
81
+ }
82
+ if (has(n.overlays, "hybrid")) {
83
+ [self.map showOverlay:@"hybrid"];
84
+ } else {
85
+ [self.map hideOverlay:@"hybrid"];
86
+ }
87
+ }
88
+
89
+ if (check(p.camera != n.camera))
90
+ [self moveCamera:n.camera noAnimation:_shouldForceUpdatePropsForInitialRender];
91
+ if (check(p.cameraMinLevel != n.cameraMinLevel && isValidNumber(n.cameraMinLevel)))
92
+ [self.map setCameraMinLevel:n.cameraMinLevel];
93
+ if (check(p.cameraMaxLevel != n.cameraMaxLevel && isValidNumber(n.cameraMaxLevel)))
94
+ [self.map setCameraMaxLevel:n.cameraMaxLevel];
95
+ if (check(p.buildingScale != n.buildingScale))
96
+ [self.map setBuildingScale:n.buildingScale];
97
+ if (check(p.poiEnabled != n.poiEnabled))
98
+ [self.map setPoiEnabled:n.poiEnabled];
99
+ if (check(p.poiClickable != n.poiClickable))
100
+ [self.map setPoiClickable:n.poiClickable];
101
+ if (check(p.poiScale != n.poiScale))
102
+ [self.map setPoiScale:n.poiScale == "small" ? PoiScaleTypeSmall
103
+ : n.poiScale == "regular" ? PoiScaleTypeRegular
104
+ : n.poiScale == "large" ? PoiScaleTypeLarge
105
+ : PoiScaleTypeXLarge];
106
+ if (check(p.language != n.language))
107
+ [self.map setLanguage:n.language == "en" ? @"en" : @"ko"];
108
+
109
+ if (check(p.isShowScaleBar != n.isShowScaleBar)) {
110
+ if (n.isShowScaleBar) {
111
+ [self.map showScaleBar];
112
+ } else {
113
+ [self.map hideScaleBar];
114
+ }
115
+ }
116
+ if (check(p.isShowCompass != n.isShowCompass)) {
117
+ if (n.isShowCompass) {
118
+ [self.map showCompass];
119
+ } else {
120
+ [self.map hideCompass];
121
+ }
122
+ }
123
+ [super updateProps:props oldProps:oldProps];
124
+ if (self.map && _shouldForceUpdatePropsForInitialRender) {
125
+ _shouldForceUpdatePropsForInitialRender = NO;
126
+ }
127
+ }
128
+
129
+ - (void)moveCamera:(const RNCKakaoMapViewCameraStruct&)c noAnimation:(BOOL)noAnimation {
130
+ CameraUpdate* update =
131
+ [CameraUpdate makeWithTarget:makePoint(c.lat, c.lng)
132
+ zoomLevel:getDoubleOrDefault(c.zoomLevel, self.map.zoomLevel)
133
+ rotation:getDoubleOrDefault(c.rotation, self.map.rotationAngle)
134
+ tilt:getDoubleOrDefault(c.tilt, self.map.tiltAngle)
135
+ mapView:self.map];
136
+
137
+ if (self.cameraAnimationDuration != 0 && !noAnimation) {
138
+ [self.map animateCameraWithCameraUpdate:update
139
+ options:CameraAnimationOptions{
140
+ .autoElevation = YES,
141
+ .consecutive = NO,
142
+ .durationInMillis =
143
+ (NSUInteger)self.cameraAnimationDuration}
144
+ callback:^{
145
+ }];
146
+ } else {
147
+ [self.map moveCamera:update
148
+ callback:^{
149
+ }];
150
+ }
151
+ }
152
+
153
+ - (void)addViews {
154
+ MapviewInfo* info = [[MapviewInfo alloc] initWithViewName:MAP_VIEW_NAME
155
+ appName:APP_NAME
156
+ viewInfoName:MAP_VIEW_INFO_MAP_NAME
157
+ defaultPosition:makePoint(37.402001, 127.108678)
158
+ defaultLevel:17
159
+ enabled:YES];
160
+ [_controller addView:info];
161
+ }
162
+
163
+ @end
164
+
165
+ @implementation RNCKakaoMapView (MapControllerDelegate)
166
+ - (void)authenticationSucceeded {
167
+ _isAuthSuccess = YES;
168
+ if (!_controller.isEngineActive) {
169
+ [_controller activateEngine];
170
+ }
171
+ }
172
+ - (void)authenticationFailed:(NSInteger)errorCode desc:(NSString*)desc {
173
+ NSLog(@"[RNCKakaoMapView] authenticationFailed %d, %@ retry...", (int)errorCode, desc);
174
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)),
175
+ dispatch_get_main_queue(), ^{
176
+ [self->_controller prepareEngine];
177
+ });
178
+ }
179
+
180
+ - (void)addViewSucceeded:(NSString*)viewName viewInfoName:(NSString*)viewInfoName {
181
+ if ([viewName isEqualToString:MAP_VIEW_NAME]) {
182
+ _shouldForceUpdatePropsForInitialRender = YES;
183
+ [self updateProps:_props oldProps:_props];
184
+ }
185
+ }
186
+ - (void)addViewFailed:(NSString*)viewName viewInfoName:(NSString*)viewInfoName {
187
+ NSLog(@"add view failed %@ %@", viewName, viewInfoName);
188
+ }
189
+ - (void)containerDidResized:(CGSize)size {
190
+ self.map.viewRect = CGRectMake(0, 0, size.width, size.height);
191
+ }
192
+ - (void)viewWillDestroyed:(ViewBase*)view {
193
+ }
194
+ @end
195
+
196
+ @implementation RNCKakaoMapView (ReactNative)
197
+
198
+ //- (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args {
199
+ //}
200
+
201
+ Class<RCTComponentViewProtocol> RNCKakaoMapViewCls(void) {
202
+ return RNCKakaoMapView.class;
203
+ }
204
+ + (ComponentDescriptorProvider)componentDescriptorProvider {
205
+ return concreteComponentDescriptorProvider<RNCKakaoMapViewComponentDescriptor>();
206
+ }
207
+
208
+ @end
@@ -0,0 +1,19 @@
1
+ //
2
+ // RNCKakaoMapViewManager.h
3
+ // RNCKakaoMap
4
+ //
5
+ // Created by mj on 5/5/24.
6
+ //
7
+
8
+ #import <Foundation/Foundation.h>
9
+ #import <React/RCTUIManager.h>
10
+ #import <React/RCTViewManager.h>
11
+
12
+ @interface RNCKakaoMapViewManager : RCTViewManager
13
+ @end
14
+
15
+ @implementation RNCKakaoMapViewManager
16
+
17
+ RCT_EXPORT_MODULE()
18
+
19
+ @end
@@ -0,0 +1,7 @@
1
+ #import "RNCKakaoMapSpec.h"
2
+ #import <KakaoMapsSDK/KakaoMapsSDK-Swift.h>
3
+ #import <KakaoMapsSdk/KakaoMapsSdk.h>
4
+
5
+ @interface RNCKakaoMap : NSObject <NativeKakaoMapSpec>
6
+
7
+ @end
@@ -0,0 +1,19 @@
1
+ #import "RNCKakaoMap.h"
2
+
3
+ @implementation RNCKakaoMap
4
+
5
+ - (void)initializeKakaoMapSDK:(NSString*)appKey
6
+ resolve:(RCTPromiseResolveBlock)resolve
7
+ reject:(RCTPromiseRejectBlock)reject {
8
+ [SDKInitializer InitSDKWithAppKey:appKey];
9
+ resolve(@(42));
10
+ }
11
+
12
+ RCT_EXPORT_MODULE()
13
+
14
+ - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
15
+ (const facebook::react::ObjCTurboModule::InitParams&)params {
16
+ return std::make_shared<facebook::react::NativeKakaoMapSpecJSI>(params);
17
+ }
18
+
19
+ @end
@@ -0,0 +1,7 @@
1
+ // import Foundation
2
+ // import React
3
+ ////import RNCKakaoCore
4
+ //
5
+ // @objc public class RNCKakaoMapManager: NSObject {
6
+ // @objc public static let shared = RNCKakaoMapManager()
7
+ // }