Reputation: 312
I use custom UrlTileProvider to load tiles from 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);
}
} }
It loads correctly, but what I see is that default Google tiles are overlapping MapBox's ones.
(those yellow roads are definitely from google maps)
How can I disable default tiles and prevent them from loading?
I use nested SupportMapFragment initialized like this:
@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)));
}
}
Upvotes: 1
Views: 405
Reputation: 3540
you can just use:
map.setMapType(GoogleMap.MAP_TYPE_NONE);
Refs: 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
Upvotes: 2