Switching the MKMapView display language
The Maps application has an option for showing labels in the local language instead of the system language, but this option isn’t available to MapKit.
The Mapbox Maps SDK for iOS does have an option for localizing labels into either the local language in each region or to one of nine languages globally (based on OpenStreetMap and Wikidata).
To change all the labels on the map to the system language, have your MGLMapViewDelegate
object implement the -mapView:didFinishLoadingStyle:
method, then call the -[MGLStyle localizeLabelsIntoLocale:]
method.
In Swift:
func mapView(_ mapView: MGLMapView, didFinishLoading style: MGLStyle) {
// Into the system language
style.localizeLabels(into: nil)
// Into Simplified Chinese
style.localizeLabels(into: Locale(identifier: "zh-Hans"))
// Into the local language where a given feature is located
style.localizeLabels(into: Locale(identifier: "mul"))
}
Or in Objective-C:
- (void)mapView:(MGLMapView *)mapView didFinishLoadingStyle:(MGLStyle *)style {
// Into the system language
[style localizeLabelsIntoLocale:nil];
// Into Simplified Chinese
[style localizeLabelsIntoLocale:[NSLocale localeWithLocaleIdentifier:@"zh-Hans"]];
// Into the local language where a given feature is located
[style localizeLabelsIntoLocale:[NSLocale localeWithLocaleIdentifier:@"mul"]];
}
There are also options for localizing certain kinds of features, such as only streets or only landmarks. See this document for more details.
The map will display in the language of the country it is displaying, often with English (or maybe your local language) as a second language. Open the Maps app on your phone and type in Dubai or Cairo, Egypt, for example, and you'll see Arabic text for cities and streets.
The same is true of other languages. Type Shanghai, China and you'll get Chinese text, Tokyo, Japan and you'll get Japanese text, etc.
There is (as of now) no open framework functions to manually change the languages of the input. I know that the openstreetmap API have some calls for this, but that would require rolling your own map handler.
Use googlesdk
for this. I do it, its too useful according to local location the map will convert into local language and if you worry about the annotation and multiple annotation you can implement all those things just like MKMapview