@@ -44,6 +44,9 @@ 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"
47
50
48
51
49
52
companion object {
@@ -95,23 +98,23 @@ class MapsFragment : Fragment() {
95
98
96
99
// Add and adjust the position of MyLocation button.
97
100
map.isMyLocationEnabled = true
98
- map.setPadding(0 , (resources.getFloat( R .dimen.padding_ratio) * autocompleteLayout.height).toInt(),0 ,0 )
99
-
101
+ map.setPadding(0 , (paddingRatio * autocompleteLayout.height).toInt(),0 ,0 )
102
+
100
103
fusedLocationClient.lastLocation.addOnSuccessListener(this .activity as Activity ) { location ->
101
104
// Got last known location. In some rare situations this can be null.
102
105
location?.let {
103
106
lastLocation = location
104
107
currentLatLng = LatLng (location.latitude, location.longitude)
105
108
map.animateCamera(CameraUpdateFactory .newLatLngZoom(
106
109
currentLatLng,
107
- resources.getFloat( R .dimen.zoom_value)
110
+ zoomValue
108
111
))
109
112
map.addMarker(MarkerOptions ()
110
113
.position(currentLatLng!! )
111
114
.title(getString(R .string.my_location_title)))
112
115
map.moveCamera(CameraUpdateFactory .newLatLngZoom(
113
116
currentLatLng,
114
- resources.getFloat( R .dimen.zoom_value)
117
+ zoomValue
115
118
))
116
119
setPlacesSearchBias()
117
120
} ? : run {
@@ -130,7 +133,7 @@ class MapsFragment : Fragment() {
130
133
}
131
134
132
135
override fun onError (status : Status ) {
133
- Log .e(" Mapfragment " , " An error occurred: $status " )
136
+ Log .e(fragmentTag , " An error occurred: $status " )
134
137
}
135
138
})
136
139
}
@@ -149,14 +152,13 @@ class MapsFragment : Fragment() {
149
152
map = googleMap
150
153
map.uiSettings.isZoomControlsEnabled = true
151
154
setUpMap()
152
-
153
155
}
154
156
155
157
private val searchPlacesCallback = OnMapReadyCallback { map ->
156
158
targetMarker?.remove()
157
159
map.moveCamera(CameraUpdateFactory .newLatLngZoom(
158
160
targetLatLng,
159
- resources.getFloat( R .dimen.zoom_value)
161
+ zoomValue
160
162
))
161
163
targetMarker = map.addMarker(MarkerOptions ()
162
164
.position(targetLatLng)
0 commit comments