Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Expose endpoint change option for snapshotter #13508

Merged
merged 1 commit into from
Dec 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import android.support.annotation.UiThread;
import android.support.v4.content.res.ResourcesCompat;
import android.text.Html;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.ViewGroup;
Expand Down Expand Up @@ -99,6 +100,7 @@ public static class Options {
private CameraPosition cameraPosition;
private boolean showLogo = true;
private String localIdeographFontFamily;
private String apiBaseUrl;

/**
* @param width the width of the image
Expand Down Expand Up @@ -191,6 +193,18 @@ public Options withLocalIdeographFontFamily(String fontFamily) {
return this;
}

/**
* Specifies the URL used for API endpoint.
*
* @param apiBaseUrl The base of our API endpoint
* @return the mutated {@link Options}
*/
@NonNull
public Options withApiBaseUrl(String apiBaseUrl) {
this.apiBaseUrl = apiBaseUrl;
return this;
}

/**
* @return the width of the image
*/
Expand Down Expand Up @@ -242,6 +256,13 @@ public String getLocalIdeographFontFamily() {
return localIdeographFontFamily;
}

/**
* @return The base of our API endpoint
*/
@Nullable
public String getApiBaseUrl() {
return apiBaseUrl;
}
}

/**
Expand All @@ -259,6 +280,11 @@ public MapSnapshotter(@NonNull Context context, @NonNull Options options) {
telemetry.onAppUserTurnstileEvent();
}
FileSource fileSource = FileSource.getInstance(context);
String apiBaseUrl = options.getApiBaseUrl();
if (!TextUtils.isEmpty(apiBaseUrl)) {
fileSource.setApiBaseUrl(apiBaseUrl);
}

String programCacheDir = FileSource.getInternalCachePath(context);

nativeInitialize(this, fileSource, options.pixelRatio, options.width,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public class MapSnapshotterActivity extends AppCompatActivity {
private GridLayout grid;
private List<MapSnapshotter> snapshotters = new ArrayList<>();


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down Expand Up @@ -69,7 +68,7 @@ private void startSnapShot(final int row, final int column) {

// Optionally the style
.withStyle((column + row) % 2 == 0 ? Style.MAPBOX_STREETS : Style.DARK)
.withLocalIdeographFontFamily("sans-serif");
.withLocalIdeographFontFamily("sans-serif");

// Optionally the visible region
if (row % 2 == 0) {
Expand Down