Skip to content
Snippets Groups Projects
Commit faa67d43 authored by Lauren Bricker's avatar Lauren Bricker
Browse files

prepping for adding mapbox as an activity

parent c199f891
No related branches found
No related tags found
1 merge request!2Mapbox sync
......@@ -2,8 +2,77 @@
Experimenting with a Android Sensing and Location.
Things you can do with this:
## SensorActivity Exercise
- Make the Gyroscope work
- Add another sensor to `SensorActivity`
- Add more data to the `LocationActivity` screen
- Store state of the on/off switches in `SharedPreferences`
- Add a map with [Mapbox](https://www.mapbox.com/)
\ No newline at end of file
## LocationActivity Exercise
About:
- Mapbox is a provider of custom online maps and location services.
- This project uses the Mapbox Android SDK to display an interactive map.
- Once the user grants location permissions, the map can be re-centered
by the "Find My Location Button" to the device's coordinates.
Precise Location is required to display the long/lat.
- Noteworthy files to look at:
- location_layout.xml > <com.mapbox.maps.MapView...
- LocationActivity.java > customizeMapAppearance()
- Module Level build.gradle > line 37 (declares mapbox dependency)
- Mapbox SDK requires a public key (for inflating MapView XML) and secret key (for Mapbox Maven
dependency).
- Sources consulted:
https://docs.mapbox.com/android/maps/guides/install/
https://stackoverflow.com/questions/38501402/hide-credentials-for-all-projects-in-build-gradle
https://docs.gradle.org/current/userguide/organizing_gradle_projects.html#declare_properties_in_gradle_properties_file
TODOs:
1. Configure Mapbox Credentials:
a. Register for a free account on Mapbox.
b. Note your default public access key from https://account.mapbox.com/access-tokens/,
then create a string resource value (app/src/main/res/values > create new XML file with a name
of your choice). In that file, copy and paste your public key in the new file after
declaring <string name="mapbox_access_token">... Make sure to not include it in git tracking.
c. Go back to https://account.mapbox.com/access-tokens/ and create another key. Scopes should
include all Public Scopes and DOWNLOADS:READ. Note the secret key after it is created.
d. Create a local file at $HOME/.gradle, called 'gradle.properties'. Put your secret key there
in the format: MAPBOX_SECRET_TOKEN=YOUR_SECRET_TOKEN and save the file. 'MAPBOX_SECRET_TOKEN'
is referred to in settings.gradle for downloading the Mapbox dependency.
- Note: You should be able to see gradle.properties (Global Properties on your left sidebar now).
- To find where Gradle is installed, go to:
- Mac: Android Studio > Preferences > Build Execution Deployment (~/.gradle)
- Windows: File > Settings > Build Execution Deployment (C:\Users\<username>\.gradle)
2. Code: Show the location on the Map.
a. Insert this XML object
<com.mapbox.maps.MapView
android:id="@+id/map_view"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/actual_location"
app:mapbox_cameraTargetLat="40.7128"
app:mapbox_cameraTargetLng="-74.0060"
app:mapbox_cameraZoom="8.0">
</com.mapbox.maps.MapView>
inside location_layout.xml. This will be the map displayed on the screen.
b. Use the location grabbed from the user's device and display it on the map
when the user presses the "Find My Location" button.
c. Handle the case where the user did not turn on location permissions but tries
to click the "Find My Location" button.
\ No newline at end of file
......@@ -9,7 +9,7 @@ android {
minSdkVersion 26
targetSdkVersion 31
buildToolsVersion "29.0.0"
buildToolsVersion "30.0.3"
versionCode 1
versionName "1.0"
}
......
......@@ -5,7 +5,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.4'
classpath 'com.android.tools.build:gradle:7.1.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
......@@ -17,11 +17,6 @@ allprojects {
mavenCentral()
}
// gradle.projectsEvaluated{
// tasks.withType(JavaCompile){
// options.compilerArgs << "-Xlint:deprecation"
// }
// }
}
task clean(type: Delete) {
......
#Mon Oct 04 21:36:06 PDT 2021
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment