Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

[core] Several methods assume style object is created #4527

Closed

Description

@tmpsantos

We have several methods that are currently crashing because map.setStyleURL is async. For instance addLayer, addClass, isLoaded and several others. We should have a signal (MapChangeDidFinishLoadingStyle?) emitted right after MapContext::loadStyleJSON.

On Android for instance MapChangeDidFinishLoadingMap is used to indicate that the style was loaded as a whole but we need something to indicate that the style JSON arrived (and the style object was created). Otherwise we might ended up rendering a partial state and later add a custom layer or class.

This new signal would be better implemented after we get rid of the context thread (#2909) because we can safely call view.notifyMapChange from MapContext::loadStyleJSON after that.

Finally, we should maybe throw an runtime exception when calling the methods that depend on a style when the style json is not yet loaded.

/cc @brunoabinader @jfirebaugh

Activity

  1. brunoabinader commented on Mar 31, 2016

    @brunoabinader
    Contributor

    Nice catch @tmpsantos - I think it would be useful if we can also add a onStyleLoaded observer that could e.g. trigger a callback on the client.

  2. self-assigned this
    on Mar 31, 2016
  3. 1ec5 commented on Sep 19, 2016

    @1ec5
    Contributor

    @friedbunny, for iOS/macOS, how does this relate to #2775? Do we need to add a new delegate method, or is an existing one suitable?

  4. friedbunny commented on Sep 19, 2016

    @friedbunny
    Contributor

    for iOS/macOS, how does this relate to #2775? Do we need to add a new delegate method, or is an existing one suitable?

    There isn’t currently a suitable delegate method. MapKit doesn’t care to inform you of style loading events, so there’s no analogue to draw upon.

  5. jfirebaugh commented on Sep 19, 2016

    @jfirebaugh
    Contributor

    I agree with the utility of a notification for this event -- it's style.load in gl-js. I'm less keen on expanding the MapChange enumeration, for reasons detailed in #6383, though I wouldn't block a PR for this on the full refactor suggested there.

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions