Не отображается метка на карте в приложении.
Created by: Allizar
Всем доброго дня!
Делаю учебный проект по геолокации. Вывожу карту Yandex во fragment. . Карта отображается, zoom работает. А вот метка, которую добавляю, не отображается. Есть идеи, почему?
Привожу код.
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View {
_binding = FragmentMainBinding.inflate(inflater, container, false)
val view = binding.root
checkPermission()
fusedClient = LocationServices.getFusedLocationProviderClient(requireContext())
fusedClient.getCurrentLocation(
Priority.PRIORITY_HIGH_ACCURACY,
object : CancellationToken() {
override fun onCanceledRequested(p0: OnTokenCanceledListener) =
CancellationTokenSource().token
override fun isCancellationRequested() = false
}).addOnSuccessListener { location: Location? ->
if (location != null) {
currentLatitude = location.latitude
currentLongitude = location.longitude
binding.mapview.mapWindow.map.move(
CameraPosition(
Point(currentLatitude, currentLongitude),
/* zoom = */ 16.0f,
/* azimuth = */ 0f,
/* tilt = */ 0f
)
)
val imageProvider = ImageProvider.fromResource(requireContext(), ic_action_name)
val placemark = binding.mapview.mapWindow.map.mapObjects.addPlacemark()
placemark.geometry = Point(currentLatitude, currentLongitude)
placemark.setIcon(imageProvider)
placemark.setText("Обязательно к посещению!")
} else {
Toast.makeText(requireContext(), "NO COORDINATES", Toast.LENGTH_SHORT).show()
}
}
return view
}