Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

google maps api integration #156

Merged
merged 21 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
6af5373
google maps api integration
cathli66 Feb 21, 2024
6e415b5
gets current user location
cathli66 Feb 22, 2024
a537de1
fixed server format
cathli66 Feb 22, 2024
2e980db
Removed old code + documentation
cathli66 Feb 24, 2024
339f828
added custom marker and test circle drawing
cathli66 Feb 26, 2024
0a26ffb
Merge branch 'master' into cl893/gameplay-map
cathli66 Feb 26, 2024
76badff
redirected details navigation from journey to nav bar
cathli66 Feb 28, 2024
6fb5f36
added recenter camera feature and two buttons on map (both currently …
cathli66 Feb 28, 2024
bc0286c
expanding challenge picture button
cathli66 Feb 28, 2024
14def24
added flutter env file to store api keys, added key to iOS build file
cathli66 Mar 1, 2024
97d3d31
adding dummy .env file so that remote branch will build
cathli66 Mar 1, 2024
fe9de4d
Merge branch 'master' into cl893/gameplay-map
cathli66 Mar 2, 2024
1f5ca79
editing game/.gitignore to include .env file
cathli66 Mar 2, 2024
7efd579
Updated API key instructions for readme
cathli66 Mar 5, 2024
d0c06f6
Merge branch 'master' into cl893/gameplay-map
cathli66 Mar 5, 2024
155cc7d
check platform before setting Android map renderer
cathli66 Mar 6, 2024
c1a1b01
Small bug fix
cathli66 Mar 6, 2024
f986982
fixed flutter formatting
cathli66 Mar 7, 2024
968e021
Merge branch 'master' into cl893/gameplay-map
cathli66 Mar 8, 2024
5402f7e
minor changes to profile page overflow, set up navigation
cathli66 Mar 8, 2024
0ee753b
Merge branch 'master' into cl893/gameplay-map
cathli66 Mar 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ Make sure Node.js, Flutter, and Docker are installed!
npm run setup
```

### API Keys for Flutter
```
To access the Google Maps in the CornellGo app, you need two Google Maps API Keys. One is for Android and one is for iOS. Ask a TPM for the .env file with the keys and the instructions to add it into the app.
```

### Run project in container

```
Expand Down
3 changes: 3 additions & 0 deletions game/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,6 @@ app.*.map.json
/android/app/debug
/android/app/profile
/android/app/release

# Secret API Keys
*.env
2 changes: 2 additions & 0 deletions game/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'com.google.gms.google-services'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
apply from: project(':flutter_config').projectDir.getPath() + "/dotenv.gradle"


android {
compileSdkVersion 33
Expand Down
6 changes: 6 additions & 0 deletions game/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>
<application android:label="CornellGO!" android:icon="@mipmap/ic_launcher">

<meta-data android:name="com.google.android.geo.API_KEY"
android:value="@string/ANDROID_MAP_API_KEY" />

<activity android:name=".MainActivity" android:exported="true" android:launchMode="singleTop" android:theme="@style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
Expand All @@ -23,5 +28,6 @@
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data android:name="flutterEmbedding" android:value="2" />

</application>
</manifest>
Binary file added game/assets/icons/userlocation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions game/ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import UIKit
import Flutter
import Firebase
import GoogleMaps
import flutter_config

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
Expand All @@ -10,6 +12,7 @@ import Firebase
) -> Bool {
GeneratedPluginRegistrant.register(with: self)
FirebaseApp.configure()
GMSServices.provideAPIKey(FlutterConfigPlugin.env(for: "IOS_MAP_API_KEY"))
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
51 changes: 48 additions & 3 deletions game/lib/api/geopoint.dart
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
import 'dart:async';
import 'dart:io' show Platform;
import 'package:geolocator/geolocator.dart';

class GeoPoint {
static bool didMakeRequest = false;
double _lat = 0;
double _long = 0;
double _heading = 0;

double get lat => _lat;
double get long => _long;
double get heading => _heading;

static bool _isRequestingLocationPermissions = false;
static bool _isRequestingLocation = false;

GeoPoint(double lat, double long) {
GeoPoint(
double lat,
double long,
double heading,
) {
_lat = lat;
_long = long;
_heading = heading;
}

static Future<GeoPoint?> current() async {
Expand All @@ -37,7 +46,7 @@ class GeoPoint {
if (permission == LocationPermission.denied) {
permission = await Geolocator.requestPermission();
if (permission == LocationPermission.denied) {
return Future.error('Location permissions are denied');
return Future.error('Location services are disabled.');
}
}
if (permission == LocationPermission.deniedForever) {
Expand All @@ -46,7 +55,7 @@ class GeoPoint {
'Location permissions are permanently denied, we cannot request permissions.');
}
final pos = await Geolocator.getCurrentPosition();
return GeoPoint(pos.latitude, pos.longitude);
return GeoPoint(pos.latitude, pos.longitude, pos.heading);
} catch (e) {
return Future.error(e.toString());
}
Expand All @@ -59,4 +68,40 @@ class GeoPoint {
double bearingTo(GeoPoint other) {
return Geolocator.bearingBetween(_lat, _long, other._lat, other._long);
}

static LocationSettings getLocationSettings() {
late LocationSettings locationSettings;

if (Platform.isAndroid) {
locationSettings = AndroidSettings(
accuracy: LocationAccuracy.high,
distanceFilter: 100,
forceLocationManager: true,
intervalDuration: const Duration(seconds: 10),
//(Optional) Set foreground notification config to keep the app alive
//when going to the background
foregroundNotificationConfig: const ForegroundNotificationConfig(
notificationText:
"CornellGO will continue to receive your location even when you aren't using it",
notificationTitle: "Running in Background",
enableWakeLock: true,
));
} else if (Platform.isIOS || Platform.isMacOS) {
locationSettings = AppleSettings(
accuracy: LocationAccuracy.high,
activityType: ActivityType.fitness,
distanceFilter: 100,
pauseLocationUpdatesAutomatically: true,
// Only set to true if our app will be started up in the background.
showBackgroundLocationIndicator: false,
);
} else {
locationSettings = LocationSettings(
accuracy: LocationAccuracy.high,
distanceFilter: 100,
);
}

return locationSettings;
}
}
54 changes: 37 additions & 17 deletions game/lib/challenges/challenges_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:flutter/src/foundation/key.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter/src/widgets/placeholder.dart';
import 'challenge_cell.dart';
import 'package:game/journeys/filter_form.dart';

class ChallengesPage extends StatefulWidget {
const ChallengesPage({Key? key}) : super(key: key);
Expand All @@ -12,6 +13,17 @@ class ChallengesPage extends StatefulWidget {
}

class _ChallengesPageState extends State<ChallengesPage> {
void openFilter() {
showModalBottomSheet(
context: context,
isScrollControlled: true,
builder: (
BuildContext context,
) {
return FilterForm();
});
}

/* Dummy code, to be replaced */
final cells = [
ChallengeCell(
Expand Down Expand Up @@ -93,25 +105,33 @@ class _ChallengesPageState extends State<ChallengesPage> {
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
padding: EdgeInsets.zero,
color: Color.fromARGB(76, 217, 217, 217),
height: 30,
child: TextButton.icon(
onPressed: () {},
icon: Icon(
Icons.tune,
color: Color.fromARGB(204, 0, 0, 0),
size: 12,
),
label: Text(
"filter",
style: TextStyle(
color: Color.fromARGB(204, 0, 0, 0),
fontSize: 12,
fontFamily: 'Lato',
fontWeight: FontWeight.w600,
onPressed: openFilter,
icon: Icon(
Icons.filter_list_rounded,
color: Color.fromARGB(255, 0, 0, 0),
size: 20.0,
),
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all<Color>(
Color.fromARGB(153, 217, 217, 217)),
padding: MaterialStateProperty.all(
EdgeInsets.only(right: 16.0, left: 16.0),
),
shape: MaterialStateProperty.all(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(3.0),
)),
),
),
),
label: Text(
"Filter By",
style: TextStyle(
color: Color.fromARGB(255, 0, 0, 0),
fontSize: 15,
fontFamily: 'Inter',
),
)),
),
],
),
Expand Down
Loading
Loading