Yandex MapKit. Kotlin. Markierung wird nicht angezeigtAndroid

Forum für diejenigen, die für Android programmieren
Anonymous
 Yandex MapKit. Kotlin. Markierung wird nicht angezeigt

Post by Anonymous »

Ich verwende Yandex MapKit in meiner App. Meine MapView befindet sich auf einem Fragment. Es funktioniert gut. Zoom funktioniert auch.
Aber eine Markierung, die ich mit addPlacemark() hinzugefügt habe, wird nicht angezeigt. Ich kann dieses Problem nicht lösen.

Code: Select all

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
}`

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post