3

When I change my activity to another activity which has huawei map it is very slow to open.

huawei version is MED-LX9N

Android version is 10

Ram : 3.0 GB

and free space is 52 / 64 GB

When I click the change activity button it waits 3-5 seconds at first.

Then I back to page and return the map page again it waits only 1 seconds.

my code:

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

on map async:

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);

                    }

                });

on xml:

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

It works but very slow how can i solve this issue ? Is it normal ?

petrov.aleksandr
  • 622
  • 1
  • 5
  • 24
ALKIN ÇAKIRALAR
  • 237
  • 2
  • 14

3 Answers3

1

I have used Mapbox map activity in my app. This is also very slow to open in Huawei devices. So I set the initial zoom level of map load to 14.0 to load faster. That's working now.

1

Yes, it is normal that the first loading is slower. It will be optimized later.

The method @pushpo rani mentioned, to adjust the zoom level, is valid only for tiles. It affects the number of tiles to be downloaded for the first-screen map. If the number of tiles to be downloaded is large, the download speed is low. If the number is small, the speed is higher.

zhangxaochen
  • 32,744
  • 15
  • 77
  • 108
1

It looks like the slow load occurs when loading the map for the first time and is caused by the zoom level.

You can set the default map zoom level in the XML by adding map:cameraZoom=”14”. More information on map instance creation Here.

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:map="http://schemas.android.com/apk/res-auto"
    android:id="@+id/mapfragment_mapfragmentdemo"
    class="com.huawei.hms.maps.SupportMapFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    map:cameraZoom="14" />

If you want to change the zoom level after creation, you can refer to this guide.

float zoom = 14.0f;
CameraUpdate cameraUpdate2 = CameraUpdateFactory.zoomTo(zoom);
Zinna
  • 1,947
  • 2
  • 5
  • 20