我使用自定义UrlTileProvider从MapBox加载切片。
public class MapboxTileProvider extends UrlTileProvider {
public MapboxTileProvider(int width, int height) {
super(width, height);
}
@Override
public URL getTileUrl(int x, int y, int z) {
try {
return new URL(String.format(MAP_BASE_URL, z, x, y));
} catch (MalformedURLException e) {
throw new RuntimeException("Failed constructing map tile URL", e);
}
} }
它正确加载,但我看到的是默认的Google磁贴与MapBox的重叠。 (那些黄色的道路肯定来自谷歌地图)
如何禁用默认图块并防止加载?
我使用如下初始化的嵌套SupportMapFragment:
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
FragmentManager fm = getChildFragmentManager();
mapFragment = (SupportMapFragment) fm.findFragmentById(R.id.map_container);
if (mapFragment == null) {
mapFragment = SupportMapFragment.newInstance();
fm.beginTransaction().replace(R.id.map_container, mapFragment).commit();
}
}
@Override
public void onResume() {
super.onResume();
if (map == null) {
map = mapFragment.getMap();
map.clear();
map.addTileOverlay(new TileOverlayOptions().tileProvider(new MapboxTileProvider(MapboxTileProvider.MAP_TILE_DIMENSION, MapboxTileProvider.MAP_TILE_DIMENSION)));
}
}
答案 0 :(得分:2)
你可以使用:
map.setMapType(GoogleMap.MAP_TYPE_NONE);
参考文献: https://developers.google.com/android/reference/com/google/android/gms/maps/GoogleMap#setMapType(int) https://developers.google.com/android/reference/com/google/android/gms/maps/GoogleMap#MAP_TYPE_NONE