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

Android textField do not work #63

Closed
NodeGIS opened this issue Apr 12, 2021 · 7 comments
Closed

Android textField do not work #63

NodeGIS opened this issue Apr 12, 2021 · 7 comments
Labels
android bug Something isn't working

Comments

@NodeGIS
Copy link

NodeGIS commented Apr 12, 2021

Migrating from MapBox to MapLibre, I found that SymbolLayer's PropertyFactory.textField(Expression.get("xxxx") does not work, if set prop for feature, the geomerty and label can not show!

My code as this:

Style.Builder bd = new Style.Builder();
bd.fromJson("{}");
mapboxMap.setStyle(bd, new Style.OnStyleLoaded() {
    @Override
    public void onStyleLoaded(@NonNull Style style) {
		GeoJsonSource source = new GeoJsonSource("mysource");
		style.addSource(source);
		Layer labelLayer = new SymbolLayer("label-layer","mysource");
        labelLayer.setProperties(PropertyFactory.textField(Expression.get("name")),
                PropertyFactory.textColor(Color.RED),
                PropertyFactory.textSize(18f)
              );
	     JsonObject prop = new JsonObject();
		 prop.addProperty("name","mytext");
		 List<Feature> features = new ArrayList<>();
         Feature feature =  Feature.fromGeometry(Point.fromLngLat(113,21),prop );
         features.add(feature);
         FeatureCollection featureCollection = FeatureCollection.fromFeatures(features);
         source.setGeoJson(featureCollection);
        }
    });
})
@wipfli
Copy link
Contributor

wipfli commented Jul 1, 2022

Is this still an issue, @NodeGIS? If yes, do you have an idea what might cause the problem?

@Neo003
Copy link

Neo003 commented Aug 29, 2022

Same problem here. I've found that set the textFont property does the trick.

@Balcan
Copy link

Balcan commented Dec 20, 2022

Hi, just found the same problem. I tried using the textFont property as suggested by @Neo003 but it did not work for me.

@louwers louwers added the bug Something isn't working label Jan 25, 2023
@tvaknin
Copy link

tvaknin commented Jan 23, 2024

I encountered a similar issue myself. After investing hours into the problem, I discovered that it is tied to the source of your glyphs server in Maplibre.

Maplibre does not default to using certain fonts; instead, it relies on the configuration specified in style.json. Consequently, it's crucial to ensure that your server can properly return the specified fonts. Failure to do so may result in an error message similar to the one below:

The error message associated with this issue might look like:

2024-01-23 11:08:27.414 10552-10750 Mbgl E {GLThread 558}[Style]: Failed to load glyph range 0-255 for font stack Noto Sans Italic,Noto Sans Bold: HTTP status code 403

https://your-ip/fonts/Noto%20Sans%20Italic%2cNoto%20Sans%20Bold/0-255.pbf

If the server cannot return the written type.

To address this, it's essential to ensure that your server can successfully return the multiple fonts, preventing HTTP status code 403 errors.

It would be nice if Maplibre would use a default for the text font, I don't think the current behavior is a bug but it's
very misleading, one wouldn't think that this text font is taken by the style URL and uses the font returned by the server map.

@louwers
Copy link
Collaborator

louwers commented Jan 23, 2024

Thanks for sharing this @tvaknin! Isn't it using Noto Sans Italic,Noto Sans Bold as a default font?

In any case, if someone wants to see this behavior changed, please open a new issue with the details. I agree that it doesn't look like a bug.

@louwers louwers closed this as completed Jan 23, 2024
@tvaknin
Copy link

tvaknin commented Jan 23, 2024

@louwers Indeed there is a default but it's not clear that it relies on a map server to fetch the default one.
A better approach in my opinion is to use some default internal source.

@wipfli
Copy link
Contributor

wipfli commented Jan 27, 2024

Might be off-topic, but let me still mention that Noto Sans Italic,Noto Sans Bold means that MapLibre Native is requesting the font Noto Sans Italic,Noto Sans Bold from the server. Then, it is up to the server to have a default or fallback mechanism. The client, i.e., MapLibre Native, does not do font fallback chain handling. Either the server gives the client something, or it gives nothing...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants