Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Не отображается UserLocation при возвращении по стеку #362

Open
Child0fTheSun opened this issue Nov 5, 2023 · 1 comment

Comments

@Child0fTheSun
Copy link

Child0fTheSun commented Nov 5, 2023

Добрый день!
У меня есть приложение, с 1 активити и фрагментами, которые переключаются между собой. На одном из фрагментов реализована карта и MapView. Проблема в том, что если перейти на другой фрагмент, а после вернуться обратно UserocationLayer исчезает и больше не рисуется

Прилагаю соответствующий код

private fun initMap() {
        mMapView = binding.mapView

        mMap = mMapView.mapWindow.map
        mMap.set2DMode(true)

        isMapReady = true

        onMapReady()
    }

    private fun onMapReady() {
        drawUserLocationMobileGPS()
        mMap.addCameraListener(this)
    }

    override fun onObjectAdded(userLocationView: UserLocationView) {
        setUserLocationLayerIcons(userLocationView)
    }

    override fun onObjectRemoved(userLocationView: UserLocationView) {
        setUserLocationLayerIcons(userLocationView)
    }

    override fun onObjectUpdated(userLocationView: UserLocationView, event: ObjectEvent) {
        setUserLocationLayerIcons(userLocationView)
    }

private fun setUserLocationLayerIcons(userLocationView: UserLocationView) {
        if (GPS == GPS_MOBILE) {
            cameraUserPosition()

            userLocationView.pin.setIcon(
                ImageProvider.fromBitmap(requireContext().getBitmapFromVectorDrawable(R.drawable.ic_user_arrow_51dp)),
                IconStyle().setAnchor(PointF(0.5f, 0.5f))
                    .setRotationType(RotationType.ROTATE)
                    .setZIndex(1f)
                    .setScale(1f)
            )
            userLocationView.arrow.setIcon(
                ImageProvider.fromBitmap(requireContext().getBitmapFromVectorDrawable(R.drawable.ic_user_arrow_51dp)),
                IconStyle().setAnchor(PointF(0.5f, 0.5f))
                    .setRotationType(RotationType.ROTATE)
                    .setZIndex(1f)
                    .setScale(1f)
            )

            userLocationView.accuracyCircle.fillColor = Color.TRANSPARENT
        }
    }
@YandexMapKit
Copy link
Collaborator

Пожалуйста, пришлите нам минимальный пример вашей ситуации. Вы можете выложить его проектом на GitHub, прикрепить к переписке в архиве или загрузить на Яндекс Диск и указать ссылку.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants