Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Road and POI labels text cannot display when switch endpoint to .cn #1554

Closed
m-stephen opened this issue Jul 11, 2018 · 6 comments
Closed

Road and POI labels text cannot display when switch endpoint to .cn #1554

m-stephen opened this issue Jul 11, 2018 · 6 comments

Comments

@m-stephen
Copy link
Contributor

m-stephen commented Jul 11, 2018

Now I'm focus on navigation project inside China by using our navigation-ios SDK. When I switch the endpoint to .cn, all the roads and POI labels text cannot display:

image

After deep dive into this bug, I found that during the func mapView(_ mapView: MGLMapView, didFinishLoading style: MGLStyle) function in NavigationMapView.swift, our navigation SDK do a localized logic called self.mapView.localizeLabels().

In this function, I saw a couple of lines code:

        let localizedText = text.mgl_expressionLocalized(into: locale)
        if localizedText != text {
            layer.text = localizedText
        }

This function make the labels can be localized to the phone's region & language.
However, in .cn map, layers' properties is a little bit different from global side:

China layers sample:
image

This is our global layer properties' link.

As you see, the layer's from .cn only have the name_zh but in text.mgl_expressionLocalized(into: locale), it return the name_zh-Hans. I know this function is in our map SDK but I'm not very sure it should be fixed on client side or server side.

After talking with @zmofei, he said the .cn data is directly provided by EMG and it's hard to modify in a short term, so I think fix on client side is a better choice. Should we do some downgrade strategy if our layers do not contain name_zh-Hans property? @1ec5 @bsudekum

Our map SDK do not have this problem and it can read these properties well because it seems that call not the localized function. So if we need to fix on client side, it's better to fix in our map SDK not in navigation SDK.

cc: @chriswu42 @tony-cj

@1ec5
Copy link
Contributor

1ec5 commented Jul 12, 2018

I was unaware that China Streets differs from the rest-of-world Streets source in this way. Are there any other differences that we should be aware of? The navigation SDK makes a lot of assumptions about the Streets source’s fields and layers.

For this particular issue, we should introduce a special case in the map SDK that varies these lists of locale identifiers for the .cn API endpoint. The fix will complicate mapbox/mapbox-gl-native#11867 a bit, but I think that’s OK. Would you mind opening an issue about this, along with a link to the public documentation for this source, if it’s available? Thanks!

@m-stephen
Copy link
Contributor Author

m-stephen commented Jul 12, 2018

Just ask @zmofei to give a China street source.

Do you mean I should open a same ticket in mapbox-gl-native? @1ec5

@1ec5
Copy link
Contributor

1ec5 commented Jul 12, 2018

Yes, we should track this issue in mapbox-gl-native, since a proper fix would go into the map SDK.

In the meantime, we can also work around the issue in the navigaiton SDK. The code below currently uses the mul locale identifier for roads and nil for everything else. mul should result in Chinese in China, but as long as .cn is in use, we’d need to replace nil with the zh locale (not zh-CN):

// Road labels should match road signage.
let locale = layer.sourceLayerIdentifier == "road_label" ? Locale(identifier: "mul") : nil

@m-stephen
Copy link
Contributor Author

After thinking of our navigation SDK for supporting .cn map, and I think there should be a .cn network module like our map SDK(Refer to MGLNetworkConfiguration.h & MGLNetworkConfiguration.m).

It can make our SDK much easier to switch the endpoint: not only the map endpoint, also the api-direction, tts services endpoint.

For deep diving into mgl_expressionLocalizedIntoLocale function in our map SDK, I think it's better to do nothing in localizeLabels function when the map is switch the endpoint to .cn.

PR is here. @1ec5

@1ec5
Copy link
Contributor

1ec5 commented Jul 17, 2018

a proper fix would go into the map SDK

mapbox/mapbox-gl-native#12387 introduces a fallback from name_zh-Hans to name. I’ve proposed that it also fall back, opportunistically, from name_zh-Hans to name_zh-CN to name.

@m-stephen
Copy link
Contributor Author

Issue fixed and closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants