Repository navigation
Update MGLVectorTileSource for Mapbox Streets v8 compatibility #11867
Description
MGLVectorTileSource currently hard-codes compatibility with Mapbox Streets source v6 and v7, particularly for the built-in label localization functionality. When v8 comes out, we’ll need to update MGLVectorTileSource to handle this version as well. In addition to rote version bumping, we’ll also have to account for the fact that name_* fields in v8 may be unset if the value would be identical to name or name_en (need to confirm the details). Finally, the VoiceOver accessibility code may need updates to recognize any new or renamed fields in v8.
mapbox-gl-native/platform/darwin/src/MGLVectorTileSource.mm
Lines 129 to 136 in d1dff1d
| - (BOOL)isMapboxStreets { | |
| NSURL *url = self.configurationURL; | |
| if (![url.scheme isEqualToString:@"mapbox"]) { | |
| return NO; | |
| } | |
| NSArray *identifiers = [url.host componentsSeparatedByString:@","]; | |
| return [identifiers containsObject:@"mapbox.mapbox-streets-v7"] || [identifiers containsObject:@"mapbox.mapbox-streets-v6"]; | |
| } |
mapbox-gl-native/platform/darwin/src/MGLVectorTileSource.mm
Lines 78 to 94 in d1dff1d
| /** | |
| An array of locale codes with dedicated name fields in the Mapbox Streets | |
| source. | |
| https://www.mapbox.com/vector-tiles/mapbox-streets-v7/#overview | |
| */ | |
| static NSArray * const MGLMapboxStreetsLanguages = @[ | |
| @"ar", @"de", @"en", @"es", @"fr", @"pt", @"ru", @"zh", @"zh-Hans", | |
| ]; | |
| /** | |
| Like `MGLMapboxStreetsLanguages`, but deanglicized for use with | |
| `+[NSBundle preferredLocalizationsFromArray:forPreferences:]`. | |
| */ | |
| static NSArray * const MGLMapboxStreetsAlternativeLanguages = @[ | |
| @"mul", @"ar", @"de", @"es", @"fr", @"pt", @"ru", @"zh", @"zh-Hans", | |
| ]; |
mapbox-gl-native/platform/ios/src/MGLMapAccessibilityElement.mm
Lines 80 to 93 in d1dff1d
| // Announce the kind of place or POI. | |
| if (attributes[@"type"]) { | |
| // FIXME: Unfortunately, these types aren’t a closed set that can be | |
| // localized, since they’re based on OpenStreetMap tags. | |
| NSString *type = [attributes[@"type"] stringByReplacingOccurrencesOfString:@"_" | |
| withString:@" "]; | |
| [facts addObject:type]; | |
| } | |
| // Announce the kind of airport, rail station, or mountain based on its | |
| // Maki image name. | |
| else if (attributes[@"maki"]) { | |
| // TODO: Localize Maki image names. | |
| [facts addObject:attributes[@"maki"]]; | |
| } |
- Detect v8 sources by URL: Update automatic Streets localization for v8/v11 data/styles #13481
- Enumerate v8
name_*languages: Update automatic Streets localization for v8/v11 data/styles #13481 - Coalesce
name_*key paths withnameorname_enin expressions when localizing labels: [iOS] Add fallbacks for name fields #12387 - Avoid making expressions too complex when relocalizing: [iOS] Add fallbacks for name fields #12387 (comment)
- (While we’re at it) Remove
-localizedKeysByKeyForPreferredLanguage:, which is unused: Fix English priority during label localization #11907 - Update MGLMapAccessibilityElement.mm with v8 field names: Update automatic Streets localization for v8/v11 data/styles #13481
- Consider defining an
MGLVectorTileSource.mapboxStreetsURLclass property
This work is not blocked by v8 launching; in fact, we should have it in place and released ahead of the launch, so that styles using v8 can take advantage of label localization.
Activity
1ec5 commentedon Jul 17, 2018
#12387 uses a coalescing expression to fall back from
name_*toname. I think that’ll get us into a good spot for basic Streets source v8 usage. However, it’s also possible that a future style would take advantage of expressions to implement bilingual labels likeLondon (Londres). In that case, we’ll have to be a bit less aggressive in localizing conditional expressions and string-concatenating expressions. But we can worry about that in a second pass, after addressing basic usage./cc @lloydsheng
1ec5 commentedon Aug 2, 2018
#12387 landed. #12387 (comment) describes how to more gracefully handle the case where a layer gets relocalized, which could be important for performance. The remaining work for this issue is tracked in the to-do list above.
1ec5 commentedon Nov 26, 2018
Here’s a gist where I had made some baby steps. The main task was allowing for multiple languages to be “preferred” on the client side. Hopefully these changes hook into the changes made in #12164.
friedbunny commentedon Dec 7, 2018
Looking at the Streets-v8 changelog, attributes have been moved around and added,
but it doesn’t appear to me that anything will break.elevation_m&elevation_ftare unchanged.road_labelhas been merged intoroad, but keeps the same attribute names.Update: whoops, spoke before I saw these:
mapbox-gl-native/platform/darwin/src/MGLStyle.mm
Lines 600 to 617 in 1b03654
1ec5 commentedon Dec 18, 2018
#13481 and #13525 have implemented the bulk of the work for this issue. The following task is unfinished, but it seems lower in priority:
stale commentedon May 23, 2020
This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.