diff --git a/app/build.gradle b/app/build.gradle
index 0d3806e..c4f9070 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -53,5 +53,6 @@ dependencies {
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
+ implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.naver.maps:map-sdk:3.16.2'
}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index d672d2b..eef2b3b 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -3,9 +3,10 @@
xmlns:tools="http://schemas.android.com/tools">
+
+
-
-
+ android:exported="true" />
-
-
-
+ android:exported="true" />
@@ -39,7 +36,6 @@
-
\ No newline at end of file
diff --git a/app/src/main/java/com/example/mocacong/activities/MainActivity.kt b/app/src/main/java/com/example/mocacong/activities/MainActivity.kt
index 001cc1c..b529bf8 100644
--- a/app/src/main/java/com/example/mocacong/activities/MainActivity.kt
+++ b/app/src/main/java/com/example/mocacong/activities/MainActivity.kt
@@ -2,8 +2,10 @@ package com.example.mocacong.activities
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
+import androidx.fragment.app.FragmentManager
import com.example.mocacong.R
import com.example.mocacong.databinding.ActivityMainBinding
+import com.example.mocacong.fragments.HomeFragment
import com.naver.maps.map.MapFragment
class MainActivity : AppCompatActivity() {
@@ -15,11 +17,15 @@ class MainActivity : AppCompatActivity() {
setContentView(binding.root)
- val fm = supportFragmentManager
- val mapFragment = fm.findFragmentById(R.id.map) as MapFragment?
- ?: MapFragment.newInstance().also {
- fm.beginTransaction().add(R.id.map, it).commit()
- }
+ createFragment()
+
+
+ }
+
+ fun createFragment(){
+ val transaction = supportFragmentManager.beginTransaction()
+ val homeFragment = HomeFragment()
+ transaction.replace(R.id.home, homeFragment).commit()
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/mocacong/fragments/HomeFragment.kt b/app/src/main/java/com/example/mocacong/fragments/HomeFragment.kt
new file mode 100644
index 0000000..d3efe9c
--- /dev/null
+++ b/app/src/main/java/com/example/mocacong/fragments/HomeFragment.kt
@@ -0,0 +1,108 @@
+package com.example.mocacong.fragments
+
+import android.os.Bundle
+import android.util.Log
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import androidx.fragment.app.Fragment
+import com.example.mocacong.R
+import com.example.mocacong.databinding.FragmentHomeBinding
+import com.naver.maps.map.*
+import com.naver.maps.map.util.FusedLocationSource
+
+
+class HomeFragment : Fragment(), OnMapReadyCallback {
+
+ private var _binding: FragmentHomeBinding? = null
+ private val binding get() = _binding!!
+
+ private lateinit var naverMap: NaverMap
+ private lateinit var locationSource: FusedLocationSource
+
+ companion object {
+ private const val LOCATION_PERMISSION_REQUEST_CODE = 1000
+ }
+
+
+ override fun onCreateView(
+ inflater: LayoutInflater, container: ViewGroup?,
+ savedInstanceState: Bundle?
+ ): View {
+ _binding = FragmentHomeBinding.inflate(inflater, container, false)
+ locationSource = FusedLocationSource(this, LOCATION_PERMISSION_REQUEST_CODE)
+
+ getMapFragment()
+ //setLocation()
+ return binding.root
+ }
+
+
+ private fun setLocation() {
+ naverMap.locationOverlay.performClick()
+ }
+
+
+ //위치 권한 요청
+ override fun onRequestPermissionsResult(
+ requestCode: Int,
+ permissions: Array,
+ grantResults: IntArray
+ ) {
+ Log.d("map", "들어왔다")
+ if (locationSource.onRequestPermissionsResult(requestCode, permissions, grantResults)) {
+ if (!locationSource.isActivated) { // 권한 거부됨
+ naverMap.locationTrackingMode = LocationTrackingMode.None
+ } else {
+ naverMap.locationTrackingMode = LocationTrackingMode.Follow // 현위치 버튼 컨트롤 활성
+ }
+ return
+ }
+ super.onRequestPermissionsResult(requestCode, permissions, grantResults)
+ }
+
+
+
+ private fun getMapFragment() {
+
+ //네이버 지도 Fragment 불러오기
+ val fm = childFragmentManager
+ val mapFragment = fm.findFragmentById(R.id.map) as MapFragment?
+ ?: MapFragment.newInstance().also {
+ fm.beginTransaction().add(R.id.map, it).commit()
+ }
+ mapFragment.getMapAsync(this)
+ }
+
+ override fun onMapReady(naverMap: NaverMap) {
+ //지도 객체 세팅
+ Log.d("DDD","객체 초기화")
+ this.naverMap = naverMap
+
+ //현위치 버튼 활성 및 줌 버튼 제거
+ naverMap.uiSettings.apply {
+ isZoomControlEnabled = false
+ isLocationButtonEnabled = true
+ }
+
+ naverMap.locationSource = locationSource
+
+
+ val locationOverlay = naverMap.locationOverlay
+ locationOverlay.isVisible = true
+
+ }
+
+
+
+
+ override fun onDestroyView() {
+ super.onDestroyView()
+ _binding = null
+ }
+
+
+
+
+
+}
\ No newline at end of file
diff --git a/app/src/main/res/drawable/fav_btn_img.xml b/app/src/main/res/drawable/fav_btn_img.xml
new file mode 100644
index 0000000..e460834
--- /dev/null
+++ b/app/src/main/res/drawable/fav_btn_img.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
diff --git a/app/src/main/res/drawable/search_icon.xml b/app/src/main/res/drawable/search_icon.xml
new file mode 100644
index 0000000..1716f83
--- /dev/null
+++ b/app/src/main/res/drawable/search_icon.xml
@@ -0,0 +1,5 @@
+
+
+
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index ff0b9fa..f610996 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -14,7 +14,7 @@
app:layout_constraintBottom_toTopOf="@id/bottomMenu"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
- android:id="@+id/map"
+ android:id="@+id/home"
/>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_map.xml b/app/src/main/res/layout/fragment_map.xml
index 605ea3b..e984239 100644
--- a/app/src/main/res/layout/fragment_map.xml
+++ b/app/src/main/res/layout/fragment_map.xml
@@ -1,6 +1,8 @@
\ No newline at end of file
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:id="@+id/map"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:name="com.naver.maps.map.MapFragment"
+ />
\ No newline at end of file