Skip to content
Snippets Groups Projects
Commit 51a66ad9 authored by Ethan Charles Vasquez's avatar Ethan Charles Vasquez
Browse files

added map

parent cbdc5864
No related branches found
No related tags found
No related merge requests found
...@@ -4,12 +4,12 @@ plugins { ...@@ -4,12 +4,12 @@ plugins {
} }
android { android {
compileSdk 32 compileSdk 33
defaultConfig { defaultConfig {
applicationId "com.example.androidfinalproject" applicationId "com.example.androidfinalproject"
minSdk 21 minSdk 21
targetSdk 32 targetSdk 33
versionCode 1 versionCode 1
versionName "1.0" versionName "1.0"
...@@ -33,11 +33,18 @@ android { ...@@ -33,11 +33,18 @@ android {
dependencies { dependencies {
implementation 'androidx.core:core-ktx:1.7.0' implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.appcompat:appcompat:1.5.1' implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.7.0' implementation 'com.google.android.material:material:1.7.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.3'
implementation 'androidx.navigation:navigation-ui-ktx:2.5.3'
implementation 'androidx.compose.ui:ui:1.4.0-alpha01'
testImplementation 'junit:junit:4.13.2' testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3' androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'com.google.maps.android:maps-compose:2.7.2'
implementation 'com.google.android.gms:play-services-maps:18.1.0'
implementation 'androidx.fragment:fragment-ktx:1.5.4'
} }
\ No newline at end of file
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
package="com.example.androidfinalproject"> package="com.example.androidfinalproject">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<application <application
android:allowBackup="true" android:allowBackup="true"
...@@ -13,6 +16,15 @@ ...@@ -13,6 +16,15 @@
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/Theme.AndroidFinalProject" android:theme="@style/Theme.AndroidFinalProject"
tools:targetApi="31"> tools:targetApi="31">
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyD4Vdbg7DwxEJkRtIj4Rk_00WHZxVzOUIY" />
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:exported="true"> android:exported="true">
......
package com.example.androidfinalproject
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import com.google.android.gms.maps.CameraUpdateFactory
import com.google.android.gms.maps.GoogleMap
import com.google.android.gms.maps.OnMapReadyCallback
import com.google.android.gms.maps.SupportMapFragment
import com.google.android.gms.maps.model.LatLng
import com.google.android.gms.maps.model.LatLngBounds
class MapFragment : Fragment(), OnMapReadyCallback {
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val view = inflater.inflate(R.layout.fragment_map, container, false)
var mapFragment : SupportMapFragment?=null
mapFragment = requireFragmentManager().findFragmentById(R.id.maps) as SupportMapFragment?
mapFragment?.getMapAsync(this)
return view
}
override fun onMapReady(gMap: GoogleMap) {
val australiaBounds = LatLngBounds(
LatLng((-44.0), 113.0), // SW bounds
LatLng((-10.0), 154.0) // NE bounds
)
gMap.moveCamera(CameraUpdateFactory.newLatLngZoom(australiaBounds.center, 10f))
}
}
\ No newline at end of file
...@@ -6,13 +6,13 @@ ...@@ -6,13 +6,13 @@
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".MainActivity"> tools:context=".MainActivity">
<TextView <androidx.fragment.app.FragmentContainerView
android:layout_width="wrap_content" android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_height="wrap_content" android:layout_width="0dp"
android:text="Hello World!" android:layout_height="0dp" app:navGraph="@navigation/nav_graph" app:defaultNavHost="true"
android:id="@+id/fragment"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent" />
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MapFragment">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="SELECT LOCATION"
android:textColor="#2196F3"
android:textSize="35sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.fragment.app.FragmentContainerView
android:id="@+id/maps"
android:layout_width="match_parent"
android:layout_height="500dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView"
android:name="com.google.android.gms.maps.SupportMapFragment"></androidx.fragment.app.FragmentContainerView>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/nav_graph"
app:startDestination="@id/mapFragment">
<fragment
android:id="@+id/mapFragment"
android:name="com.example.androidfinalproject.MapFragment"
android:label="fragment_map"
tools:layout="@layout/fragment_map" />
</navigation>
\ No newline at end of file
<resources> <resources>
<string name="app_name">AndroidFinalProject</string> <string name="app_name">AndroidFinalProject</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
</resources> </resources>
\ No newline at end of file
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