I use Yandex MapKit in my app. My mapView is on a fragment. It works well. Zoom also works. But a mark which I added with addPlacemark() is not displayed. I cannot resolve this issue.
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
}`
The problen is svg-image. Yandex MapKit does not work with this format I changed it on png. Now placemark works.