当我将我的活动改为另一个有华为地图的活动时,打开的速度非常慢。
华为版本为MED-LX9N Android版本是10 Ram : 3.0 GB 自由空间为52 / 64 GB
当我单击“更改活动”按钮时,它首先等待3-5秒。
然后我返回到页面,并再次返回地图页,它只等待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" />它工作得很慢,我怎么能解决这个问题呢?这正常吗?
发布于 2020-12-24 08:25:24
我在我的应用程序中使用了Mapbox地图活动。在华为设备上,这也是非常缓慢的。因此,我将地图加载的初始缩放级别设置为14.0,以便更快地加载。现在起作用了。
发布于 2020-12-24 08:53:56
是的,第一次加载速度慢是正常的。稍后将对其进行优化。
@pushpo rani提到的调整缩放级别的方法仅对瓷砖有效。它会影响第一个屏幕地图下载的瓷砖数量。如果要下载的瓷砖数量很大,则下载速度很慢。如果数字很小,速度就会更高。
发布于 2020-12-29 03:40:38
看起来慢加载是在第一次加载地图时发生的,并且是由缩放级别造成的。
您可以通过添加map:cameraZoom=“14”来设置XML中的默认地图缩放级别。更多关于地图实例创建这里的信息。
<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" />如果要在创建后更改缩放级别,可以参考此指南。
float zoom = 14.0f;
CameraUpdate cameraUpdate2 = CameraUpdateFactory.zoomTo(zoom);https://stackoverflow.com/questions/65435463
复制相似问题