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

styleWillLoad delegate/callback Request #12824

Closed
akac opened this issue Sep 5, 2018 · 4 comments
Closed

styleWillLoad delegate/callback Request #12824

akac opened this issue Sep 5, 2018 · 4 comments
Labels
archived Archived because of inactivity Core The cross-platform C++ core, aka mbgl runtime styling

Comments

@akac
Copy link

akac commented Sep 5, 2018

Style changes - either through setStyleURL or through automatic style reloads - will lose programmatically added/customized layers, attributes. This is expected, but if we have a data stream that is live updating data we would like to know when the style is about to be loaded/reloaded so we can pause the data stream or any other work we are doing with the layers until the time that map has finished loading with the style. We sometimes also want to save the state of a layer or grab information from it before it goes away.

Current delegate methods get called after the style is set to nil - we would like a "will" callback that is called before the style is set to nil.

Platform:
iOS or Android
Mapbox SDK version:
4.x/6.x

Steps to trigger behavior

  1. Load a style
  2. Create a thread that updates layer data in realtime streaming from an endpoint
  3. Reload the style

Expected behavior

Get a callback that the style is about to go away.

Actual behavior

Get a callback after the style has already been set to nil.

@1ec5
Copy link
Contributor

1ec5 commented Sep 5, 2018

Are you adding the live stream of data to the map via a vector tile source, or more manually using a shape source or annotations?

When you use the runtime styling API in any way, the SDK stops reloading the style automatically but does continue to reload any vector tiles based on HTTP headers in the tile server’s response. If I’m not mistaken, -[MGLMapViewDelegate mapViewWillStartLoadingMap: and -[MGLMapViewDelegate mapViewDidFinishLoadingMap:] get called around such refreshes.

If it is the style rather than vector tiles that you want to observe, then you can use -[MGLMapViewDelegate mapView:didFinishLoadingStyle: to find out when the style finishes loading. If you need more granularity than that, consider key-value observing MGLMapView’s style key path.

Completion handlers for style loading are proposed in #6386 (comment), but that’s for manual style loading or reloading, rather than anything automatic on the part of the SDK.

@kkaefer
Copy link
Member

kkaefer commented Sep 25, 2018

Also see #6180

@kkaefer kkaefer added Core The cross-platform C++ core, aka mbgl runtime styling labels Sep 25, 2018
@stale stale bot added the archived Archived because of inactivity label Mar 25, 2019
@stale
Copy link

stale bot commented Mar 25, 2019

This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.

@stale stale bot closed this as completed Mar 25, 2019
@julianrex julianrex reopened this Aug 5, 2019
@stale stale bot removed the archived Archived because of inactivity label Aug 5, 2019
@stale stale bot added the archived Archived because of inactivity label Feb 1, 2020
@stale
Copy link

stale bot commented Feb 1, 2020

This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.

@stale stale bot closed this as completed Feb 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived Archived because of inactivity Core The cross-platform C++ core, aka mbgl runtime styling
Projects
None yet
Development

No branches or pull requests

4 participants