Skip to content

Commit b285233

Browse files
committed
네이버 맵 추가함
MainActivity.kt 안에 뭔가를 적으면 지도가 적용이 안돼서 주석처리함. (안드로이드 method channel 연결 하려면 MainActivity.kt의 주석을 해제 해야한다.)
1 parent e9eb4b7 commit b285233

File tree

7 files changed

+302
-140
lines changed

7 files changed

+302
-140
lines changed

android/app/src/main/AndroidManifest.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<!-- 네이버 맵 id -->
1818
<meta-data
1919
android:name="com.naver.maps.map.CLIENT_ID"
20-
android:value="YOUR_CLIENT_ID_HERE" />
20+
android:value="ydk44hjjcw" />
2121

2222
<activity
2323
android:theme="@style/MyCustomTheme"

android/app/src/main/kotlin/com/yumyum/inmat/MainActivity.kt

+23-23
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,27 @@ import io.flutter.plugin.common.MethodChannel
99
import io.flutter.plugins.GeneratedPluginRegistrant
1010

1111
class MainActivity : FlutterActivity() {
12-
private val CHANNEL ="com.yumyum.inmat/channels"
13-
14-
override fun onCreate(savedInstanceState: Bundle?) {
15-
super.onCreate(savedInstanceState)
16-
GeneratedPluginRegister.registerGeneratedPlugins(FlutterEngine(this@MainActivity))
17-
MethodChannel(flutterEngine?.dartExecutor!!,CHANNEL).setMethodCallHandler{ call, _ ->
18-
if(call.method.equals("goToSecondActivity")){
19-
goToSecondActivity()
20-
}
21-
}
22-
23-
}
24-
25-
private fun goToSecondActivity(){
26-
startActivity(Intent(this@MainActivity,SecondActivity::class.java))
27-
}
28-
29-
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
30-
flutterEngine
31-
.platformViewsController
32-
.registry
33-
.registerViewFactory("<platform-view-type>", NativeViewFactory())
34-
}
12+
// private val CHANNEL ="com.yumyum.inmat/channels"
13+
//
14+
// override fun onCreate(savedInstanceState: Bundle?) {
15+
// super.onCreate(savedInstanceState)
16+
// GeneratedPluginRegister.registerGeneratedPlugins(FlutterEngine(this@MainActivity))
17+
// MethodChannel(flutterEngine?.dartExecutor!!,CHANNEL).setMethodCallHandler{ call, _ ->
18+
// if(call.method.equals("goToSecondActivity")){
19+
// goToSecondActivity()
20+
// }
21+
// }
22+
//
23+
// }
24+
//
25+
// private fun goToSecondActivity(){
26+
// startActivity(Intent(this@MainActivity,SecondActivity::class.java))
27+
// }
28+
//
29+
// override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
30+
// flutterEngine
31+
// .platformViewsController
32+
// .registry
33+
// .registerViewFactory("<platform-view-type>", NativeViewFactory())
34+
// }
3535
}

ios/Podfile.lock

+10
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ PODS:
3434
- AppAuth/Core (~> 1.4)
3535
- GTMSessionFetcher/Core (~> 1.5)
3636
- GTMSessionFetcher/Core (1.7.2)
37+
- naver_map_plugin (0.9.4):
38+
- Flutter
39+
- NMapsMap
40+
- NMapsMap (3.16.0)
3741
- shared_preferences_ios (0.0.1):
3842
- Flutter
3943
- Toast (4.0.0)
@@ -46,6 +50,7 @@ DEPENDENCIES:
4650
- geolocator_apple (from `.symlinks/plugins/geolocator_apple/ios`)
4751
- google_maps_flutter_ios (from `.symlinks/plugins/google_maps_flutter_ios/ios`)
4852
- google_sign_in_ios (from `.symlinks/plugins/google_sign_in_ios/ios`)
53+
- naver_map_plugin (from `.symlinks/plugins/naver_map_plugin/ios`)
4954
- shared_preferences_ios (from `.symlinks/plugins/shared_preferences_ios/ios`)
5055

5156
SPEC REPOS:
@@ -55,6 +60,7 @@ SPEC REPOS:
5560
- GoogleSignIn
5661
- GTMAppAuth
5762
- GTMSessionFetcher
63+
- NMapsMap
5864
- Toast
5965

6066
EXTERNAL SOURCES:
@@ -72,6 +78,8 @@ EXTERNAL SOURCES:
7278
:path: ".symlinks/plugins/google_maps_flutter_ios/ios"
7379
google_sign_in_ios:
7480
:path: ".symlinks/plugins/google_sign_in_ios/ios"
81+
naver_map_plugin:
82+
:path: ".symlinks/plugins/naver_map_plugin/ios"
7583
shared_preferences_ios:
7684
:path: ".symlinks/plugins/shared_preferences_ios/ios"
7785

@@ -88,6 +96,8 @@ SPEC CHECKSUMS:
8896
GoogleSignIn: 3c68388ac221f379676e8f1cb115df3aaf73b93f
8997
GTMAppAuth: 4d8f864896f3646f0c33baf38a28362f4c601e15
9098
GTMSessionFetcher: 5595ec75acf5be50814f81e9189490412bad82ba
99+
naver_map_plugin: d1d67733c56b20b88270d9da51218e18fa916232
100+
NMapsMap: a2593320fca2bb09e521c05b4dffee4da42e96ed
91101
shared_preferences_ios: 548a61f8053b9b8a49ac19c1ffbc8b92c50d68ad
92102
Toast: 91b396c56ee72a5790816f40d3a94dd357abc196
93103

ios/Runner/Info.plist

+11
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@
2323
<string>지도 마커를 위해 위치정보를 얻습니다.</string>
2424
<key>NSLocationAlwaysUsageDescription</key>
2525
<string>This app needs access to location when in the background.</string>
26+
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
27+
<string>Always and When In Use Usage</string>
28+
29+
<!-- 네이버 맵 -->
30+
<key>NMFClientId</key>
31+
<string>ydk44hjjcw</string>
32+
<key>io.flutter.embedded_views_preview</key>
33+
<true/>
34+
<key>NSAllowsArbitraryLoads</key>
35+
<true/>
36+
2637

2738

2839
<!-- 원래 ios 설정 -->

lib/_sample/naver_map/main.dart

+27-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,33 @@ class MyApp extends StatelessWidget {
1212
Widget build(BuildContext context) {
1313
return MaterialApp(
1414
title: '네이버 맵',
15-
home: const HomePage(),
15+
home: const Home(),
16+
);
17+
}
18+
}
19+
20+
class Home extends StatefulWidget {
21+
const Home({Key? key}) : super(key: key);
22+
23+
@override
24+
State<Home> createState() => _HomeState();
25+
}
26+
27+
class _HomeState extends State<Home> {
28+
@override
29+
Widget build(BuildContext context) {
30+
return Scaffold(
31+
appBar: AppBar(),
32+
body: Column(
33+
children: [
34+
CupertinoButton(
35+
child: Text("이동"),
36+
onPressed: () {
37+
Navigator.push(context,
38+
CupertinoPageRoute(builder: (context) => NaverMapPage()));
39+
}),
40+
],
41+
),
1642
);
1743
}
1844
}

lib/_sample/naver_map/naver.dart

+46-13
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,64 @@
1+
import 'dart:async';
2+
13
import 'package:flutter/foundation.dart';
24
import 'package:flutter/gestures.dart';
35
import 'package:flutter/material.dart';
46
import 'package:flutter/rendering.dart';
57
import 'package:flutter/services.dart';
8+
import 'package:naver_map_plugin/naver_map_plugin.dart';
69

7-
class HomePage extends StatefulWidget {
8-
const HomePage({Key? key}) : super(key: key);
10+
class NaverMapPage extends StatefulWidget {
11+
const NaverMapPage({Key? key}) : super(key: key);
912

1013
@override
11-
State<HomePage> createState() => _HomePageState();
14+
State<NaverMapPage> createState() => _NaverMapPageState();
1215
}
1316

14-
class _HomePageState extends State<HomePage> {
17+
class _NaverMapPageState extends State<NaverMapPage> {
18+
Completer<NaverMapController> _controller = Completer();
19+
MapType _mapType = MapType.Basic;
20+
1521
@override
1622
Widget build(BuildContext context) {
17-
// This is used in the platform side to register the view.
18-
const String viewType = '<platform-view-type>';
19-
// Pass parameters to the platform side.
20-
const Map<String, dynamic> creationParams = <String, dynamic>{};
23+
double longitude = 126.65667;
24+
double latitude = 37.45132;
2125

2226
return Scaffold(
23-
appBar: AppBar(
24-
title: Text("네이버 맵"),
25-
),
26-
body: Column(children: [
27+
appBar: AppBar(title: const Text('NaverMap Test')),
28+
body: Column(
29+
children: [
30+
// Container(
31+
// height: 400,
32+
// color: Colors.blueGrey,
33+
// ),
34+
Container(
35+
height: 300,
36+
child: NaverMap(
37+
initialCameraPosition:
38+
CameraPosition(target: LatLng(latitude, longitude), zoom: 17),
39+
// scrollGestureEnable:false,
40+
// rotationGestureEnable:false,
41+
//zoomGestureEnable:false,
42+
onMapCreated: onMapCreated,
43+
markers: [
44+
Marker(markerId: '가게1', position: LatLng(latitude, longitude),width: 30,height: 40),
2745

28-
],),
46+
],
47+
minZoom: 13,
48+
mapType: _mapType,
49+
),
50+
),
51+
// Container(
52+
// height: 400,
53+
// color: Colors.blueGrey,
54+
// ),
55+
],
56+
),
2957
);
3058
}
59+
60+
void onMapCreated(NaverMapController controller) {
61+
if (_controller.isCompleted) _controller = Completer();
62+
_controller.complete(controller);
63+
}
3164
}

0 commit comments

Comments
 (0)