У меня есть карта Google, реализованная в моем приложении (во фрагменте), когда я открываю этот фрагмент, он просто показывает серый экран, пока я получаю правильную широту, долготу
Код
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
val root = inflater.inflate(R.layout.fragment_map_to_customer, container, false)
customerAddressArgument = requireArguments().getString("customerAddressArgument").toString()
// Google Maps
var mapView = root.findViewById(R.id.map) as MapView
mapView.getMapAsync(this)
mapView.onCreate(arguments)
return root
}
override fun onMapReady(googleMap: GoogleMap) {
mMap = googleMap
// mMap.uiSettings.isZoomControlsEnabled = true
val geoCoder = Geocoder(context)
var address = geoCoder.getFromLocationName(customerAddressArgument, 1)!![0]
val latLng = LatLng(address.latitude, address.longitude)
mMap!!.addMarker(MarkerOptions().position(latLng).title("Location"))
mMap!!.animateCamera(CameraUpdateFactory.newLatLng(latLng))
Log.d("latLng20:", latLng.toString()) <-- return: **D/latLng20:: lat/lng: (-6.3946055,106.7947916)**
Toast.makeText(
context,
address.latitude.toString() + " " + address.longitude,
Toast.LENGTH_LONG
).show()
}
latLng
в Google сайт карты
Есть идеи?
mapView.onCreate(arguments)
, я не нашел его в документах? - person Pavel Poley   schedule 09.02.2021Log.d("latLng20:", latLng.toString()) <-- return: **D/latLng20:: lat/lng: (-6.3946055,106.7947916)**
- person mafortis   schedule 09.02.2021mMap.onResume()
части - person mafortis   schedule 09.02.2021