所以,当我使用我的 MapBox 地图时,Tiles 会覆盖在我的折线和多边形上,所以它们看不到。
有没有办法修改这种行为?
这是我正在使用的代码:
public class MapBoxOnlineTileProvider extends UrlTileProvider {
private static final String[] FORMATS;
static {
final String[] servers = new String[] { "a", "b", "c", "d" };
final String[] formats = new String[servers.length];
for (int i = 0; i < servers.length; i++) {
formats[i] = String.format(
"%%s://%s.tiles.mapbox.com/v3/%%s/%%d/%%d/%%d.png",
servers[i]);
}
FORMATS = formats;
}
// ------------------------------------------------------------------------
// Instance Variables
// ------------------------------------------------------------------------
private String mMapIdentifier;
private boolean mUseSSL;
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
public MapBoxOnlineTileProvider(final String mapIdentifier) {
this(mapIdentifier, false);
}
public MapBoxOnlineTileProvider(final String mapIdentifier,
final boolean useSSL) {
super(256, 256);
this.mMapIdentifier = mapIdentifier;
this.mUseSSL = useSSL;
}
// ------------------------------------------------------------------------
// Public Methods
// ------------------------------------------------------------------------
public String getMapIdentifier() {
return this.mMapIdentifier;
}
public void setMapIdentifier(final String anIdentifier) {
this.mMapIdentifier = anIdentifier;
}
public boolean isSSLEnabled() {
return this.mUseSSL;
}
public void setSSLEnabled(final boolean enableSSL) {
this.mUseSSL = enableSSL;
}
@Override
public URL getTileUrl(final int x, final int y, final int z) {
final String f = FORMATS[new Random().nextInt(FORMATS.length)];
final String p = this.mUseSSL ? "https" : "http";
try {
System.out.println(String
.format(f, p, this.mMapIdentifier, z, x, y));
return new URL(String.format(f, p, this.mMapIdentifier, z, x, y));
} catch (final MalformedURLException e) {
e.printStackTrace();
return null;
}
}
}
设置覆盖:
final MapBoxOnlineTileProvider provider = new MapBoxOnlineTileProvider(MAP_ID);
final TileOverlayOptions overlay = new TileOverlayOptions().tileProvider(provider);
mMap.addTileOverlay(overlay);