From 701a628835c5705d75efd74cba9ae8aae781bafe Mon Sep 17 00:00:00 2001 From: KIMSEONGMIN <128333586+Brian0KIM@users.noreply.github.com> Date: Tue, 3 Dec 2024 01:44:01 +0900 Subject: [PATCH] map screen --- dartFront/pubspec.yaml | 1 + front/.gitignore | 2 + front/android/app/build.gradle | 17 ++- .../android/app/src/main/AndroidManifest.xml | 6 ++ front/lib/main.dart | 7 +- front/lib/map_screen.dart | 35 ++++++ front/pubspec.lock | 101 ++++++++++++++++++ front/pubspec.yaml | 2 + front/web/index.html | 4 + 9 files changed, 169 insertions(+), 6 deletions(-) create mode 100644 front/lib/map_screen.dart diff --git a/dartFront/pubspec.yaml b/dartFront/pubspec.yaml index 4244619..125a476 100644 --- a/dartFront/pubspec.yaml +++ b/dartFront/pubspec.yaml @@ -9,6 +9,7 @@ dependencies: dio: ^5.4.0 envied: ^0.5.3 url_launcher: ^6.2.5 + google_maps_flutter: ^2.10.0 assets: - assets/data/ diff --git a/front/.gitignore b/front/.gitignore index 29a3a50..2ffacbd 100644 --- a/front/.gitignore +++ b/front/.gitignore @@ -41,3 +41,5 @@ app.*.map.json /android/app/debug /android/app/profile /android/app/release + +.env diff --git a/front/android/app/build.gradle b/front/android/app/build.gradle index d1c4f44..812b81f 100644 --- a/front/android/app/build.gradle +++ b/front/android/app/build.gradle @@ -4,7 +4,13 @@ plugins { // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. id "dev.flutter.flutter-gradle-plugin" } - +def localProperties = new Properties() +def localPropertiesFile = rootProject.file('local.properties') +if (localPropertiesFile.exists()) { + localPropertiesFile.withReader('UTF-8') { reader -> + localProperties.load(reader) + } +} android { namespace = "com.example.front" compileSdk = flutter.compileSdkVersion @@ -24,12 +30,13 @@ android { applicationId = "com.example.front" // You can update the following values to match your application needs. // For more information, see: https://flutter.dev/to/review-gradle-config. - minSdk = flutter.minSdkVersion + minSdk = 20 targetSdk = flutter.targetSdkVersion versionCode = flutter.versionCode versionName = flutter.versionName + resValue "string", "GOOGLE_MAPS_API_KEY", localProperties['GOOGLE_MAPS_API_KEY'] } - + buildTypes { release { // TODO: Add your own signing config for the release build. @@ -38,6 +45,10 @@ android { } } } +dependencies { // 여기에 dependencies 블록 추가 + implementation 'com.google.android.gms:play-services-maps:18.2.0' + implementation 'com.google.android.gms:play-services-location:21.2.0' +} flutter { source = "../.." diff --git a/front/android/app/src/main/AndroidManifest.xml b/front/android/app/src/main/AndroidManifest.xml index e60fc63..66d699a 100644 --- a/front/android/app/src/main/AndroidManifest.xml +++ b/front/android/app/src/main/AndroidManifest.xml @@ -1,8 +1,14 @@ + + + + { } try { - //final Uri url = Uri.parse('http://10.0.2.2:8081/user/login'); - final Uri url = Uri.parse('http://localhost:8081/user/login');// 로그인 API 주소 + final Uri url = Uri.parse('http://10.0.2.2:8081/user/login'); + //final Uri url = Uri.parse('http://localhost:8081/user/login');// 로그인 API 주소 final response = await http.post( url, headers: {'Content-Type': 'application/json'}, @@ -207,7 +208,7 @@ class _NavigationBarScreenState extends State { _pages = [ const ComplaintServiceScreen(), // 민원 화면 const BusScreen(), // 버스 화면 - const Center(child: Text('지도 화면')), // 지도 화면 + const MapScreen(), // 지도 화면 const StationScreen(), // 정류장 화면 UserInfoScreen( userName: widget.userName, diff --git a/front/lib/map_screen.dart b/front/lib/map_screen.dart new file mode 100644 index 0000000..8d98700 --- /dev/null +++ b/front/lib/map_screen.dart @@ -0,0 +1,35 @@ +import 'package:google_maps_flutter/google_maps_flutter.dart'; +import 'package:flutter/material.dart'; + +class MapScreen extends StatefulWidget { + const MapScreen({super.key}); + + @override + State createState() => _MapScreenState(); +} + +class _MapScreenState extends State { + static const CameraPosition _kGooglePlex = CameraPosition( + target: LatLng(37.2485, 127.0778), // 경희대학교 국제캠퍼스 좌표 + zoom: 14.4746, + ); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('캠퍼스 지도'), + ), + body: GoogleMap( + mapType: MapType.normal, + initialCameraPosition: _kGooglePlex, + myLocationEnabled: true, + myLocationButtonEnabled: true, + zoomControlsEnabled: true, + onMapCreated: (GoogleMapController controller) { + // 필요한 경우 컨트롤러 저장 + }, + ), + ); + } +} \ No newline at end of file diff --git a/front/pubspec.lock b/front/pubspec.lock index 40f9d68..15204ad 100644 --- a/front/pubspec.lock +++ b/front/pubspec.lock @@ -118,6 +118,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.6" + csslib: + dependency: transitive + description: + name: csslib + sha256: "09bad715f418841f976c77db72d5398dc1253c21fb9c0c7f0b0b985860b2d58e" + url: "https://pub.dev" + source: hosted + version: "1.0.2" cupertino_icons: dependency: "direct main" description: @@ -179,6 +187,14 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_dotenv: + dependency: "direct main" + description: + name: flutter_dotenv + sha256: b7c7be5cd9f6ef7a78429cabd2774d3c4af50e79cb2b7593e3d5d763ef95c61b + url: "https://pub.dev" + source: hosted + version: "5.2.1" flutter_lints: dependency: "direct dev" description: @@ -187,11 +203,24 @@ packages: url: "https://pub.dev" source: hosted version: "4.0.0" + flutter_plugin_android_lifecycle: + dependency: transitive + description: + name: flutter_plugin_android_lifecycle + sha256: "9b78450b89f059e96c9ebb355fa6b3df1d6b330436e0b885fb49594c41721398" + url: "https://pub.dev" + source: hosted + version: "2.0.23" flutter_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" get: dependency: transitive description: @@ -216,6 +245,62 @@ packages: url: "https://pub.dev" source: hosted version: "6.2.1" + google_maps: + dependency: transitive + description: + name: google_maps + sha256: "4d6e199c561ca06792c964fa24b2bac7197bf4b401c2e1d23e345e5f9939f531" + url: "https://pub.dev" + source: hosted + version: "8.1.1" + google_maps_flutter: + dependency: "direct main" + description: + name: google_maps_flutter + sha256: "209856c8e5571626afba7182cf634b2910069dc567954e76ec3e3fb37f5e9db3" + url: "https://pub.dev" + source: hosted + version: "2.10.0" + google_maps_flutter_android: + dependency: transitive + description: + name: google_maps_flutter_android + sha256: bccf64ccbb2ea672dc62a61177b315a340af86b0228564484b023657544a3fd5 + url: "https://pub.dev" + source: hosted + version: "2.14.11" + google_maps_flutter_ios: + dependency: transitive + description: + name: google_maps_flutter_ios + sha256: "6f798adb0aa1db5adf551f2e39e24bd06c8c0fbe4de912fb2d9b5b3f48147b02" + url: "https://pub.dev" + source: hosted + version: "2.13.2" + google_maps_flutter_platform_interface: + dependency: transitive + description: + name: google_maps_flutter_platform_interface + sha256: a951981c22d790848efb9f114f81794945bc5c06bc566238a419a92f110af6cb + url: "https://pub.dev" + source: hosted + version: "2.9.5" + google_maps_flutter_web: + dependency: transitive + description: + name: google_maps_flutter_web + sha256: ff39211bd25d7fad125d19f757eba85bd154460907cd4d135e07e3d0f98a4130 + url: "https://pub.dev" + source: hosted + version: "0.5.10" + html: + dependency: transitive + description: + name: html + sha256: "1fc58edeaec4307368c60d59b7e15b9d658b57d7f3125098b6294153c75337ec" + url: "https://pub.dev" + source: hosted + version: "0.15.5" http: dependency: "direct main" description: @@ -408,6 +493,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" + sanitize_html: + dependency: transitive + description: + name: sanitize_html + sha256: "12669c4a913688a26555323fb9cec373d8f9fbe091f2d01c40c723b33caa8989" + url: "https://pub.dev" + source: hosted + version: "2.1.0" sky_engine: dependency: transitive description: flutter @@ -445,6 +538,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.2" + stream_transform: + dependency: transitive + description: + name: stream_transform + sha256: "14a00e794c7c11aa145a170587321aedce29769c08d7f58b1d141da75e3b1c6f" + url: "https://pub.dev" + source: hosted + version: "2.1.0" string_scanner: dependency: transitive description: diff --git a/front/pubspec.yaml b/front/pubspec.yaml index f9d5419..b6e4fc1 100644 --- a/front/pubspec.yaml +++ b/front/pubspec.yaml @@ -38,6 +38,8 @@ dependencies: # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.8 no_context_navigation: ^3.0.0 + google_maps_flutter: ^2.10.0 + flutter_dotenv: ^5.2.1 dev_dependencies: flutter_test: diff --git a/front/web/index.html b/front/web/index.html index b7b5203..9a44ed7 100644 --- a/front/web/index.html +++ b/front/web/index.html @@ -26,6 +26,10 @@ + + + +