public final class MapLocale
extends java.lang.Object
MapLocale object builds off of the Locale object and provides additional
geographical information particular to the Mapbox Maps SDK. Like Locale, MapLocale can be used to
make the map locale sensitive.
The MapLocale object can be used to acquire the matching Locale's map language; useful for
translating the map language into one of the supported ones found in MapLocale.Languages.
You'll also be able to get bounding box information for that same country so the map's starting position target can adjust itself over the device's Locale country.
A handful of MapLocale's are already constructed and offered through this class as static
variables. If a country is missing and you'd like to add it, you can use one of the
MapLocale constructors to build a valid map locale. Once this is done, you need to add it
to the Locale cache using addMapLocale(Locale, MapLocale) where the first
parameter is the Locale object which matches up with your newly created
MapLocale.
| Modifier and Type | Class and Description |
|---|---|
static interface |
MapLocale.Languages |
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
ARABIC
Arabic (if available)
|
static MapLocale |
BRAZIL
Useful constant for country.
|
static MapLocale |
CANADA
Useful constant for country.
|
static MapLocale |
CANADA_FRENCH
Useful constant for country.
|
static MapLocale |
CHINA
Useful constant for country.
|
static java.lang.String |
CHINESE
Chinese (if available)
|
static MapLocale |
CHINESE_HANS
Useful constant for country.
|
static MapLocale |
CHINESE_HANT
Useful constant for country.
|
static java.lang.String |
ENGLISH
English (if available)
|
static MapLocale |
FRANCE
Useful constant for country.
|
static java.lang.String |
FRENCH
French (if available)
|
static java.lang.String |
GERMAN
German (if available)
|
static MapLocale |
GERMANY
Useful constant for country.
|
static MapLocale |
JAPAN
Useful constant for country.
|
static java.lang.String |
JAPANESE
Japanese (if available)
|
static MapLocale |
KOREA
Useful constant for country.
|
static java.lang.String |
KOREAN
Korean (if available)
|
static java.lang.String |
LOCAL_NAME
The name (or names) used locally for the place.
|
static MapLocale |
PORTUGAL
Useful constant for country.
|
static java.lang.String |
PORTUGUESE
Portuguese (if available)
|
static MapLocale |
RUSSIA
Useful constant for country.
|
static java.lang.String |
RUSSIAN
Russian (if available)
|
static java.lang.String |
SIMPLIFIED_CHINESE
Simplified Chinese (if available)
|
static MapLocale |
SPAIN
Useful constant for country.
|
static java.lang.String |
SPANISH
Spanish (if available)
|
static MapLocale |
TAIWAN
Useful constant for country.
|
static MapLocale |
UK
Useful constant for country.
|
static MapLocale |
US
Useful constant for country.
|
| Constructor and Description |
|---|
MapLocale(com.mapbox.mapboxsdk.geometry.LatLngBounds countryBounds)
Construct a new MapLocale instance by passing in a LatLngBounds object.
|
MapLocale(java.lang.String mapLanguage)
Construct a new MapLocale instance using one of the map languages found in
MapLocale.Languages. |
MapLocale(java.lang.String mapLanguage,
com.mapbox.mapboxsdk.geometry.LatLngBounds countryBounds)
/**
Construct a new MapLocale instance using one of the map languages found in
MapLocale.Languages
and also passing in a LatLngBounds object. |
| Modifier and Type | Method and Description |
|---|---|
static void |
addMapLocale(java.util.Locale locale,
MapLocale mapLocale)
When creating a new MapLocale, you'll need to associate a
Locale so that
Locale.getDefault() will find the correct corresponding MapLocale. |
com.mapbox.mapboxsdk.geometry.LatLngBounds |
getCountryBounds()
Returns a
LatLngBounds which represents the viewport bounds which allow for the entire
viewing of a country within the devices viewport. |
java.lang.String |
getMapLanguage()
Returns the Map Language which can be fed directly into
textField in runtime styling to
change language. |
static MapLocale |
getMapLocale(java.util.Locale locale)
Passing in a Locale, you are able to receive the
MapLocale object which it is currently
paired with. |
static MapLocale |
getMapLocale(java.util.Locale locale,
boolean acceptFallback)
Passing in a Locale, you are able to receive the
MapLocale object which it is currently
paired with. |
public static final java.lang.String LOCAL_NAME
public static final java.lang.String ENGLISH
public static final java.lang.String FRENCH
public static final java.lang.String ARABIC
public static final java.lang.String SPANISH
public static final java.lang.String GERMAN
public static final java.lang.String PORTUGUESE
public static final java.lang.String RUSSIAN
public static final java.lang.String CHINESE
public static final java.lang.String SIMPLIFIED_CHINESE
public static final java.lang.String JAPANESE
public static final java.lang.String KOREAN
public static final MapLocale FRANCE
public static final MapLocale GERMANY
public static final MapLocale JAPAN
public static final MapLocale KOREA
public static final MapLocale CHINA
public static final MapLocale TAIWAN
public static final MapLocale CHINESE_HANS
public static final MapLocale CHINESE_HANT
public static final MapLocale UK
public static final MapLocale US
public static final MapLocale CANADA
public static final MapLocale CANADA_FRENCH
public static final MapLocale RUSSIA
public static final MapLocale SPAIN
public static final MapLocale PORTUGAL
public static final MapLocale BRAZIL
public MapLocale(@NonNull
java.lang.String mapLanguage)
MapLocale.Languages.mapLanguage - a non-null string which is allowed from MapLocale.Languagespublic MapLocale(@NonNull
com.mapbox.mapboxsdk.geometry.LatLngBounds countryBounds)
countryBounds - non-null LatLngBounds object which wraps around the countrypublic MapLocale(@NonNull
java.lang.String mapLanguage,
@Nullable
com.mapbox.mapboxsdk.geometry.LatLngBounds countryBounds)
MapLocale.Languages
and also passing in a LatLngBounds object.mapLanguage - a non-null string which is allowed from MapLocale.LanguagescountryBounds - LatLngBounds object which wraps around the country@NonNull public java.lang.String getMapLanguage()
textField in runtime styling to
change language.@Nullable public com.mapbox.mapboxsdk.geometry.LatLngBounds getCountryBounds()
LatLngBounds which represents the viewport bounds which allow for the entire
viewing of a country within the devices viewport.LatLngBounds which can be used when user locations unknown but locale ispublic static void addMapLocale(@NonNull
java.util.Locale locale,
@NonNull
MapLocale mapLocale)
Locale so that
Locale.getDefault() will find the correct corresponding MapLocale.@Nullable public static MapLocale getMapLocale(@NonNull java.util.Locale locale)
MapLocale object which it is currently
paired with. If this returns null, there was no matching MapLocale to go along with the
passed in Locale. If you expected a non-null result, you should make sure you used
addMapLocale(Locale, MapLocale) before making this call.locale - the locale which you'd like to receive its matching MapLocale if one exists@Nullable public static MapLocale getMapLocale(@NonNull java.util.Locale locale, boolean acceptFallback)
MapLocale object which it is currently
paired with. If this returns null, there was no matching MapLocale to go along with the
passed in Locale. If you expected a non-null result, you should make sure you used
addMapLocale(Locale, MapLocale) before making this call.locale - the locale which you'd like to receive its matching MapLocale if one existsacceptFallback - whether the locale should fallback to the first declared that matches the language,
the fallback locale can be added with addMapLocale(Locale, MapLocale)MapLocale if one exists, otherwise nullgetMapLocaleFallback(Locale)