-
Notifications
You must be signed in to change notification settings - Fork 127
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
[Help wanted] Changing the language of the map on a custom style #250
Comments
Exposing the style layers in Flutter is a good idea in principle. I have thought about this before, also on exposing the layers properties (read-only). That may not be directly relevant for your use case, but I'm documenting it here just in case. My initial approach was to just get the style JSON from the native libraries and implement one method on the Flutter side to parse this into dart objects. However, MapLibre on iOS does not support getting the full style JSON, so you have to write native iOS code for iterating through the style objects, somehow pass them to the Flutter side (probably by converting them to JSON first on the native side), and then on the Dart/Flutter side parse that JSON into Dart objects. Since there are quite a lot of properties for style layers, we might need to auto-generate this code somehow. For changing a specific property of a style layer, see #138 where I implemented this for layer visibility. I guess the code for setting the language would be similar. So we might again need (auto-generated) native code with a huge switch statement setting the right property on the native objects, depending on the concrete property name. So in pseudo-code something like this:
(Such code already exists in the form of the LayerPropertyConverter files, which are generated by a script) But I'd also be happy if someone finds an easier solution. Does that make sense? |
@JulianBissekkou I just noticed that @martinale14 seems to be working on such a generic mechanism for setting layout properties, using the LayerPropertyConverter generated by a script, in flutter-mapbox-gl/maps#1333 |
We are currently having problems changing the language of the map. We quickly debugged the android code and saw that the language is only applied if the layer is a mapbox style layer.
This is not the case and I am sure that this might not be the case for many other developers using maplibre.
Changing the language of a style is still something new to me, but I have an idea how this could work out:
Correct me If i am wrong, but we need access to the layers of a style and we would expose
mapView.style.layers
on iOS andmapView.getStyle().getLayers()
on Android. (Web has a similar api as well)On dart side we can then update specific layers to apply the new language.
Some example code that can be called from the dart sdk:
Exposing the style layers might be useful for other customizations :)
The text was updated successfully, but these errors were encountered: