|
| 1 | +import 'dart:async'; |
| 2 | + |
1 | 3 | import 'package:flutter/foundation.dart';
|
2 | 4 | import 'package:flutter/gestures.dart';
|
3 | 5 | import 'package:flutter/material.dart';
|
4 | 6 | import 'package:flutter/rendering.dart';
|
5 | 7 | import 'package:flutter/services.dart';
|
| 8 | +import 'package:naver_map_plugin/naver_map_plugin.dart'; |
6 | 9 |
|
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); |
9 | 12 |
|
10 | 13 | @override
|
11 |
| - State<HomePage> createState() => _HomePageState(); |
| 14 | + State<NaverMapPage> createState() => _NaverMapPageState(); |
12 | 15 | }
|
13 | 16 |
|
14 |
| -class _HomePageState extends State<HomePage> { |
| 17 | +class _NaverMapPageState extends State<NaverMapPage> { |
| 18 | + Completer<NaverMapController> _controller = Completer(); |
| 19 | + MapType _mapType = MapType.Basic; |
| 20 | + |
15 | 21 | @override
|
16 | 22 | 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; |
21 | 25 |
|
22 | 26 | 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), |
27 | 45 |
|
28 |
| - ],), |
| 46 | + ], |
| 47 | + minZoom: 13, |
| 48 | + mapType: _mapType, |
| 49 | + ), |
| 50 | + ), |
| 51 | + // Container( |
| 52 | + // height: 400, |
| 53 | + // color: Colors.blueGrey, |
| 54 | + // ), |
| 55 | + ], |
| 56 | + ), |
29 | 57 | );
|
30 | 58 | }
|
| 59 | + |
| 60 | + void onMapCreated(NaverMapController controller) { |
| 61 | + if (_controller.isCompleted) _controller = Completer(); |
| 62 | + _controller.complete(controller); |
| 63 | + } |
31 | 64 | }
|
0 commit comments