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

Fire an event when a request for a glyph range PBF returns a bad response #9528

Open
jseppi opened this issue Apr 9, 2020 · 1 comment
Open

Comments

@jseppi
Copy link
Contributor

jseppi commented Apr 9, 2020

Motivation

I am trying to render font previews using a mapbox-gl map instance and a small custom style that just shows a single text label.

The way I do this is:

  • Create a map instance
  • Generate a style that takes a font name and some other parameters like color and preview text
  • Call map.setStyle(generatedStyle);
  • Assign a listener for the 'idle' event, that when triggered, will get the map canvas and save the canvas as a dataURL
  • Move on to rendering the next font

Here's a smallish proof-of-concept: https://jsbin.com/putowir/edit?html,js,console,output

It works well when all the fonts for which I want to generate previews exist. If, however, a font does not exist and the request for its glyph range(s) fails (with a 404 generally), the map never triggers its idle event. To get around this, I added a timeout so that if idle is not triggered before the timeout, the current font preview render is abandoned. You can simulate a bad font in the proof-of-concept by uncommenting the line // "BAD FONT",.

I think it would be nicer if the map instead triggered an event when a glyph request fails. Then, instead of using a timeout, I could listen for that that event, abandon the current font preview, and move on to the next one.

Design Alternatives

Design

Implementation

@pathmapper
Copy link
Contributor

If, however, a font does not exist and the request for its glyph range(s) fails (with a 404 generally), the map never triggers its idle event

I think the idle event is currently not triggered because affected tiles are not rendered at all -> #9546.

My understanding is that affected tiles should be rendered without labels (according to #662 (comment) bad glyph requests should not kill the entire tile).

So if affected tiles would be rendered without labels the idle event should be triggered.
An event which is triggered when a glyph request fails (as suggested here by @jseppi) would still be useful, e.g. to be able to notify the user of an app or trigger a fallback for this case.

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

No branches or pull requests

3 participants