mirror of
https://github.com/mollyim/osmdroid.git
synced 2025-05-13 07:10:36 +01:00
Fix Mapbox rester image api url. Add support for hightDPI. (#1873)
* Fix Mapbox rester image api url. Add support for hightDPI. According to the MapBox raster images API docs here: https://docs.mapbox.com/api/maps/raster-tiles/ The url for this api has changed to https://api.mapbox.com/v4/{tileset_id}/{zoom}/{x}/{y}{@2x}.{format} * small change to retrigger merge check. --------- Co-authored-by: xyz32 <xyz.relativity@gmail.com>
This commit is contained in:
parent
ddfef5ec55
commit
5cdc4e21f9
1 changed files with 26 additions and 18 deletions
|
@ -23,11 +23,12 @@ public class MapBoxTileSource extends OnlineTileSourceBase {
|
|||
//<meta-data android:name="MAPBOX_ACCESS_TOKEN" android:value="YOUR TOKEN" />
|
||||
private static final String ACCESS_TOKEN = "MAPBOX_ACCESS_TOKEN";
|
||||
|
||||
private static final String[] mapBoxBaseUrl = new String[]{
|
||||
"https://api.mapbox.com/styles/v1/mapbox/"};
|
||||
private static final String[] mapBoxBaseUrl = new String[]{
|
||||
"https://api.mapbox.com/v4/"};
|
||||
|
||||
private String mapBoxMapId = "";
|
||||
private String accessToken;
|
||||
private String highDPI = "";
|
||||
|
||||
/**
|
||||
* Creates a MapBox TileSource. You won't be able to use it until you set the access token and map id.
|
||||
|
@ -120,23 +121,22 @@ public class MapBoxTileSource extends OnlineTileSourceBase {
|
|||
return mapBoxMapId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTileURLString(final long pMapTileIndex) {
|
||||
StringBuilder url = new StringBuilder(getBaseUrl());
|
||||
url.append(getMapBoxMapId());
|
||||
url.append("/tiles/");
|
||||
url.append(MapTileIndex.getZoom(pMapTileIndex));
|
||||
url.append("/");
|
||||
url.append(MapTileIndex.getX(pMapTileIndex));
|
||||
url.append("/");
|
||||
url.append(MapTileIndex.getY(pMapTileIndex));
|
||||
//url.append(".png");
|
||||
//url.append("@2x"); //for high-res?
|
||||
url.append("?access_token=").append(getAccessToken());
|
||||
String res = url.toString();
|
||||
@Override
|
||||
public String getTileURLString(final long pMapTileIndex) {
|
||||
StringBuilder url = new StringBuilder(getBaseUrl());
|
||||
url.append(getMapBoxMapId());
|
||||
url.append("/");
|
||||
url.append(MapTileIndex.getZoom(pMapTileIndex));
|
||||
url.append("/");
|
||||
url.append(MapTileIndex.getX(pMapTileIndex));
|
||||
url.append("/");
|
||||
url.append(MapTileIndex.getY(pMapTileIndex));
|
||||
url.append(highDPI); //for high-DPI
|
||||
url.append(mImageFilenameEnding);
|
||||
url.append("?access_token=").append(getAccessToken());
|
||||
|
||||
return res;
|
||||
}
|
||||
return url.toString();
|
||||
}
|
||||
|
||||
public String getAccessToken() {
|
||||
return accessToken;
|
||||
|
@ -145,4 +145,12 @@ public class MapBoxTileSource extends OnlineTileSourceBase {
|
|||
public void setAccessToken(String accessTokeninput) {
|
||||
accessToken = accessTokeninput;
|
||||
}
|
||||
|
||||
public void enableHighDPI(boolean isHighDPI) {
|
||||
if (isHighDPI) {
|
||||
highDPI = "@2x";
|
||||
} else {
|
||||
highDPI = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue