public final class MapLocale extends 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 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 String |
CHINESE
Chinese (if available)
|
static MapLocale |
CHINESE_HANS
Useful constant for country.
|
static MapLocale |
CHINESE_HANT
Useful constant for country.
|
static String |
ENGLISH
English (if available)
|
static MapLocale |
FRANCE
Useful constant for country.
|
static String |
FRENCH
French (if available)
|
static String |
GERMAN
German (if available)
|
static MapLocale |
GERMANY
Useful constant for country.
|
static MapLocale |
JAPAN
Useful constant for country.
|
static String |
JAPANESE
Japanese (if available)
|
static MapLocale |
KOREA
Useful constant for country.
|
static String |
KOREAN
Korean (if available)
|
static String |
LOCAL_NAME
The name (or names) used locally for the place.
|
static MapLocale |
PORTUGAL
Useful constant for country.
|
static String |
PORTUGUESE
Portuguese (if available)
|
static MapLocale |
RUSSIA
Useful constant for country.
|
static String |
RUSSIAN
Russian (if available)
|
static String |
SIMPLIFIED_CHINESE
Simplified Chinese (if available)
|
static MapLocale |
SPAIN
Useful constant for country.
|
static 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(LatLngBounds countryBounds)
Construct a new MapLocale instance by passing in a LatLngBounds object.
|
MapLocale(String mapLanguage)
Construct a new MapLocale instance using one of the map languages found in
MapLocale.Languages. |
MapLocale(String mapLanguage,
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(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. |
LatLngBounds |
getCountryBounds()
Returns a
LatLngBounds which represents the viewport bounds which allow for the entire
viewing of a country within the devices viewport. |
String |
getMapLanguage()
Returns the Map Language which can be fed directly into
textField in runtime styling to
change language. |
static MapLocale |
getMapLocale(Locale locale)
Passing in a Locale, you are able to receive the
MapLocale object which it is currently
paired with. |
static MapLocale |
getMapLocale(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 String LOCAL_NAME
public static final String ENGLISH
public static final String FRENCH
public static final String ARABIC
public static final String SPANISH
public static final String GERMAN
public static final String PORTUGUESE
public static final String RUSSIAN
public static final String CHINESE
public static final String SIMPLIFIED_CHINESE
public static final String JAPANESE
public static final 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(String mapLanguage)
MapLocale.Languages.mapLanguage - a non-null string which is allowed from MapLocale.Languagespublic MapLocale(LatLngBounds countryBounds)
countryBounds - non-null LatLngBounds object which wraps around the countrypublic MapLocale(String mapLanguage, 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 countrypublic String getMapLanguage()
textField in runtime styling to
change language.public 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(Locale locale, MapLocale mapLocale)
Locale so that
Locale.getDefault() will find the correct corresponding MapLocale.public static MapLocale getMapLocale(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 existspublic static MapLocale getMapLocale(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)© 2015–2019 Mapbox. All rights reserved.