Skip to content

Commit e5dcbf1

Browse files
author
Langston Smith
authored
Added .baseUrl() to Places Plugin's PlaceOptions builder (#1116)
1 parent 04a5625 commit e5dcbf1

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

plugin-places/src/main/java/com/mapbox/mapboxsdk/plugins/places/autocomplete/model/PlaceOptions.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* <li><strong>Full screen mode</strong>: will place all the search history, results, and injected
3030
* places into a view which has a width equal to the app width.</li>
3131
* <li><strong>Card view mode</strong>: the place search history, results, and injected places in
32-
* an Android Support Library {@link android.support.v7.widget.CardView}</li>
32+
* into a {@link androidx.cardview.widget.CardView}</li>
3333
* </ul>
3434
*
3535
* @since 0.1.0
@@ -190,6 +190,16 @@ public abstract class PlaceOptions implements Parcelable {
190190
@Nullable
191191
public abstract String hint();
192192

193+
/**
194+
* Optionally change the base URL of the geocoding request
195+
* to something other then the default Mapbox one.
196+
*
197+
* @return base url of geocoding request
198+
* @since 0.12.0
199+
*/
200+
@Nullable
201+
public abstract String baseUrl();
202+
193203
/**
194204
* Build a new instance of the {@link PlaceOptions} class using this method. It will return the
195205
* {@link Builder} which can be used to customize the users experience.
@@ -429,6 +439,16 @@ public Builder addInjectedFeature(CarmenFeature carmenFeature) {
429439
*/
430440
public abstract Builder hint(@Nullable String hint);
431441

442+
/**
443+
* Optionally change the base URL of the geocoding request
444+
* to something other then the default Mapbox one.
445+
*
446+
* @param baseUrl base url of geocoding request
447+
* @return this builder instance for chaining options together
448+
* @since 0.12.0
449+
*/
450+
public abstract Builder baseUrl(@Nullable String baseUrl);
451+
432452
abstract PlaceOptions autoBuild();
433453

434454
/**

plugin-places/src/main/java/com/mapbox/mapboxsdk/plugins/places/autocomplete/viewmodel/PlaceAutocompleteViewModel.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ public void buildGeocodingRequest(String accessToken) {
4343
geocoderBuilder = MapboxGeocoding.builder().autocomplete(true);
4444
geocoderBuilder.accessToken(accessToken);
4545
geocoderBuilder.limit(placeOptions.limit());
46+
if (placeOptions.baseUrl() != null) {
47+
geocoderBuilder.baseUrl(placeOptions.baseUrl());
48+
}
4649

4750
// Proximity
4851
Point proximityPoint = placeOptions.proximity();

0 commit comments

Comments
 (0)