@@ -44,13 +44,13 @@ class MapsFragment : Fragment() {
44
44
private lateinit var autocompleteFragment : AutocompleteSupportFragment
45
45
private var currentLatLng : LatLng ? = null
46
46
private var targetMarker : Marker ? = null
47
- private val zoomValue = 14f
48
- private val paddingRatio = 1.5
49
- private val fragmentTag = " Mapfragment"
50
47
51
48
52
49
companion object {
53
50
private const val LOCATION_PERMISSION_REQUEST_CODE = 1
51
+ private const val ZOOM_VALUE = 14f
52
+ private const val PADDING_RATIO = 1.5
53
+ private const val FRAGMENT_TAG = " Mapfragment"
54
54
}
55
55
56
56
override fun onRequestPermissionsResult (requestCode : Int ,
@@ -98,7 +98,7 @@ class MapsFragment : Fragment() {
98
98
99
99
// Add and adjust the position of MyLocation button.
100
100
map.isMyLocationEnabled = true
101
- map.setPadding(0 , (paddingRatio * autocompleteLayout.height).toInt(),0 ,0 )
101
+ map.setPadding(0 , (PADDING_RATIO * autocompleteLayout.height).toInt(),0 ,0 )
102
102
103
103
fusedLocationClient.lastLocation.addOnSuccessListener(this .activity as Activity ) { location ->
104
104
// Got last known location. In some rare situations this can be null.
@@ -107,14 +107,14 @@ class MapsFragment : Fragment() {
107
107
currentLatLng = LatLng (location.latitude, location.longitude)
108
108
map.animateCamera(CameraUpdateFactory .newLatLngZoom(
109
109
currentLatLng,
110
- zoomValue
110
+ ZOOM_VALUE
111
111
))
112
112
map.addMarker(MarkerOptions ()
113
113
.position(currentLatLng!! )
114
114
.title(getString(R .string.my_location_title)))
115
115
map.moveCamera(CameraUpdateFactory .newLatLngZoom(
116
116
currentLatLng,
117
- zoomValue
117
+ ZOOM_VALUE
118
118
))
119
119
setPlacesSearchBias()
120
120
} ? : run {
@@ -133,7 +133,7 @@ class MapsFragment : Fragment() {
133
133
}
134
134
135
135
override fun onError (status : Status ) {
136
- Log .e(fragmentTag , " An error occurred: $status " )
136
+ Log .e(FRAGMENT_TAG , " An error occurred: $status " )
137
137
}
138
138
})
139
139
}
@@ -158,7 +158,7 @@ class MapsFragment : Fragment() {
158
158
targetMarker?.remove()
159
159
map.moveCamera(CameraUpdateFactory .newLatLngZoom(
160
160
targetLatLng,
161
- zoomValue
161
+ ZOOM_VALUE
162
162
))
163
163
targetMarker = map.addMarker(MarkerOptions ()
164
164
.position(targetLatLng)
0 commit comments