gpt4 book ai didi

android - 如何在使用 MapBox 加载 map 之前防止黑屏闪烁?

转载 作者:太空宇宙 更新时间:2023-11-03 10:58:51 26 4
gpt4 key购买 nike

我正在将 Mapbox 加载到我的 fragment 中,当从 DrawerLayout 中单击时将启动该 fragment 。

  @Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.map_fragment, container, false);


}

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);

bindUI(getView()); mapView = view.findViewById(R.id.mapView);

mapView.onCreate(savedInstanceState);
mapView.getMapAsync(map -> {
mapboxMap = map;

setUpMap();
});

}

@Override
public void onStart() {
super.onStart();
mapView.onStart();

}

@Override
public void onStop() {
super.onStop();
mapView.onStop();

}


@Override
public void onDestroy() {
super.onDestroy();
mapView.onDestroy();
}

@Override
public void onResume() {
super.onResume();
mapView.onResume();
}

@Override
public void onPause() {
super.onPause();
mapView.onPause();
}

@Override
public void onLowMemory() {
super.onLowMemory();
mapView.onLowMemory();
}

@Override
public void onDestroyView() {
super.onDestroyView();
mapView.onDestroy();

}

@Override
public void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
mapView.onSaveInstanceState(outState);
}

这是我在 fragment 中使用 Mapbox 加载 map 所用的代码。每当我从抽屉布局更改 fragment 时,黑屏闪烁,然后加载 map 。

如果我正在加载其他 fragment 而不是 Map fragment ,它可以正常工作。

提前致谢

最佳答案

本身不可能的接缝,但您可以根据 mapBox 的文档进行变通。

引用THIS DOC: Troubleshoot raster image with black background

Why black backgrounds appear: The black background that appears is thepart of the raster image that does not contain any data. Generally araster image is a rectangular grid of pixels. When you are workingwith data that is not rectangular, there are pixels within the gridthat don't contain any data. These pixels are expressed as NoDatavalues and represent the absence of data. GeoTIFFs that are uploadedto Mapbox Studio are displayed as JPEG to save space and make mapsload quickly. Since JPEG cannot display transparency, NoData valuesappear black.

It's not possible to change the appearance of NoData values withinMapbox Studio, but there are two strategies you can use to resolve theissue outside of Mapbox Studio. First, you can use Mapbox GL JS toretrieve a PNG instead of a JPEG. If that doesn't work, you can editthe original image using Rasterio.

关于android - 如何在使用 MapBox 加载 map 之前防止黑屏闪烁?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50094790/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com