Skip to content

Commit

Permalink
FEAT: google map 연동 성공
Browse files Browse the repository at this point in the history
  • Loading branch information
bianbbc87 committed Feb 4, 2024
1 parent 3b344f3 commit d48ef0b
Show file tree
Hide file tree
Showing 14 changed files with 294 additions and 35 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@ app.*.map.json
/android/app/debug
/android/app/profile
/android/app/release

# env
*.env
5 changes: 5 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
android:label="inglo"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">

<!-- Google Maps API key -->
<meta-data android:name="com.google.android.geo.API_KEY"
android:value="key"/>

<activity
android:name=".MainActivity"
android:exported="true"
Expand Down
1 change: 1 addition & 0 deletions ios/Flutter/Debug.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "Generated.xcconfig"
1 change: 1 addition & 0 deletions ios/Flutter/Release.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Generated.xcconfig"
44 changes: 44 additions & 0 deletions ios/Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '12.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}

def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end

File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
use_frameworks!
use_modular_headers!

flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
target 'RunnerTests' do
inherit! :search_paths
end
end

post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end
39 changes: 39 additions & 0 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
PODS:
- Flutter (1.0.0)
- flutter_config (0.0.1):
- Flutter
- google_maps_flutter_ios (0.0.1):
- Flutter
- GoogleMaps (< 9.0)
- GoogleMaps (6.2.1):
- GoogleMaps/Maps (= 6.2.1)
- GoogleMaps/Base (6.2.1)
- GoogleMaps/Maps (6.2.1):
- GoogleMaps/Base

DEPENDENCIES:
- Flutter (from `Flutter`)
- flutter_config (from `.symlinks/plugins/flutter_config/ios`)
- google_maps_flutter_ios (from `.symlinks/plugins/google_maps_flutter_ios/ios`)

SPEC REPOS:
trunk:
- GoogleMaps

EXTERNAL SOURCES:
Flutter:
:path: Flutter
flutter_config:
:path: ".symlinks/plugins/flutter_config/ios"
google_maps_flutter_ios:
:path: ".symlinks/plugins/google_maps_flutter_ios/ios"

SPEC CHECKSUMS:
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_config: f48f0d47a284f1791aacce2687eabb3309ba7a41
google_maps_flutter_ios: f135b968a67c05679e0a53538e900b5c174b0d99
GoogleMaps: 20d7b12be49a14287f797e88e0e31bc4156aaeb4

PODFILE CHECKSUM: 819463e6a0290f5a72f145ba7cde16e8b6ef0796

COCOAPODS: 1.15.0
156 changes: 141 additions & 15 deletions ios/Runner.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions ios/Runner.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import UIKit
import Flutter
import GoogleMaps // Add this import
import flutter_config // add env

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
Expand All @@ -8,6 +10,11 @@ import Flutter
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)

// TODO: Add your Google Maps API key
// env 파일 사용
GMSServices.provideAPIKey(FlutterConfigPlugin.env(for: "MAP_KEY"))

return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
}
13 changes: 9 additions & 4 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ import 'package:inglo/screens/signup/signup.dart';
import 'screens/signin/signin.dart';
import 'models/appbar/appbar.dart';

void main() => runApp(MyApp());
void main() async {
// dotenv용 code
WidgetsFlutterBinding.ensureInitialized(); // Required by FlutterConfig

runApp(MyApp());
}

class MyApp extends StatelessWidget {
@override
Expand All @@ -25,9 +30,9 @@ class _MainScreenState extends State<MainScreen> {

// 각 탭에 해당하는 페이지 위젯
final List<Widget> _pages = [
HomePage(),
NotificationsPage(),
MessagesPage(),
AppMap(),
LoginPage(),
AccountPage(),
MessagesPage(),
// 참고 페이지(나중에 삭제)
];
Expand Down
42 changes: 27 additions & 15 deletions lib/screens/home/home.dart
Original file line number Diff line number Diff line change
@@ -1,22 +1,34 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg_provider/flutter_svg_provider.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';

// homepage 생성
class HomePage extends StatelessWidget {
const HomePage({super.key});
class AppMap extends StatefulWidget {
const AppMap({Key? key}) : super(key: key);

@override
_AppMapState createState() => _AppMapState();
}

class _AppMapState extends State<AppMap> {
late GoogleMapController mapController;

final LatLng _center = const LatLng(45.521563, -122.677433);

void _onMapCreated(GoogleMapController controller) {
mapController = controller;
}

@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
image: DecorationImage(
image: Svg(
'assets/image/home/background.svg',
// size: Size(10, 10), // size 지정 하던 안 하던 동일하다.
),
)),
child: const Scaffold(

));
child: Scaffold(
body: GoogleMap(
onMapCreated: _onMapCreated,
initialCameraPosition: CameraPosition(
target: _center,
zoom: 11.0,
),
),
),
);
}
}
}
8 changes: 8 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_config:
dependency: "direct main"
description:
name: flutter_config
sha256: a07e6156bb6e776e29c6357be433155acda87d1dab1a3f787a72091a1b71ffbf
url: "https://pub.dev"
source: hosted
version: "2.0.2"
flutter_dotenv:
dependency: "direct main"
description:
Expand Down
2 changes: 2 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ dependencies:
google_maps_flutter: ^2.5.3
google_maps_flutter_web: ^0.5.4+3
flutter_dotenv: ^5.1.0
flutter_config: ^2.0.2

dev_dependencies:
flutter_test:
Expand All @@ -35,3 +36,4 @@ flutter:
- assets/icon/navigation/
- assets/image/background/
- assets/image/home/
- .env
3 changes: 3 additions & 0 deletions web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
<meta name="apple-mobile-web-app-title" content="inglo">
<link rel="apple-touch-icon" href="icons/Icon-192.png">

<!-- TODO: Add your Google Maps API key here -->
<script src="https://maps.googleapis.com/maps/api/js?key=key"></script>

<!-- Favicon -->
<link rel="icon" type="image/png" href="favicon.png"/>

Expand Down

0 comments on commit d48ef0b

Please sign in to comment.