java - 华为Map Kit Activity打开很慢

标签 java android kotlin mapkit huawei-mobile-services

当我将我的 Activity 更改为另一个有华为 map 的 Activity 时,打开速度非常慢。

huawei version is MED-LX9N

Android version is 10

Ram : 3.0 GB

and free space is 52 / 64 GB

当我点击更改 Activity 按钮时,它首先等待 3-5 秒。

然后我返回页面并再次返回 map 页面它只等待 1 秒。

我的代码:

  com.huawei.hms.maps.SupportMapFragment supportMapFragment = new com.huawei.hms.maps.SupportMapFragment();
            context.getSupportFragmentManager().beginTransaction().replace(fragmentId, supportMapFragment).commit();
            supportMapFragment.getMapAsync(huwaiMapReadyCallBack);

map 异步:

com.huawei.hms.location.FusedLocationProviderClient fusedLocationProviderClient = com.huawei.hms.location.LocationServices.getFusedLocationProviderClient(activity);

                fusedLocationProviderClient.getLastLocation().addOnSuccessListener(activity, location -> {

                    if (location != null) {

                        double currentLat = location.getLatitude();
                        double currentLong = location.getLongitude();

                        com.huawei.hms.maps.model.LatLng latLng = new com.huawei.hms.maps.model.LatLng(currentLat, currentLong);

                        com.huawei.hms.maps.CameraUpdate cameraUpdate = com.huawei.hms.maps.CameraUpdateFactory.newLatLngZoom(latLng, zoom);

                        huaweiMap.moveCamera(cameraUpdate);

                    }

                });

在 xml 上:

<fragment
                    android:id="@+id/map_fragment"
                    class="com.google.android.gms.maps.SupportMapFragment"
                    android:layout_width="match_parent"
                    android:layout_height="350dp" />

它工作但很慢我该如何解决这个问题?正常吗?

最佳答案

我在我的应用程序中使用了 Mapbox map Activity 。这在华为设备中打开也很慢。所以我将 map 加载的初始缩放级别设置为 14.0 以加快加载速度。现在可以了。

关于java - 华为Map Kit Activity打开很慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65435463/

相关文章:

java - CheckStyle SuppressionFilter 模块文件路径以实现 Eclipse 和 Maven 兼容性

java - 持久化 API 的类注释与接口(interface)

java - Android:更改其他类的数组值

android - 如何在 Android 中使用 Activity 代码到 Fragment 类中?

kotlin - 嵌套在通用父类中的类构造函数的功能引用

java - 使用 TransferManager 将大文件上传到 Amazon S3 存储桶的最佳方法

java - Hibernate和Oracle中的事务超时

android - 为什么 setDecorFitsSystemWindows 不起作用?

java - 对话框中的日历 View

memory-leaks - 使用内联函数创建匿名对象。它是否包含封闭类的泄漏?