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

Add -mapView:didFinishLoadingStyle: delegate methods - #6636

Merged
friedbunny merged 2 commits into
masterfrom
fb-style-loading-delegate
Oct 11, 2016
Merged

friedbunny merged 2 commits into
masterfrom
fb-style-loading-delegate

Conversation

@friedbunny

Copy link
Copy Markdown
Contributor

Fixes #6412 by implementing -mapView:didFinishLoadingStyle: delegate methods, made possible at the core level by #6371.

Also adds MGLStyle.description and a private MGLStyle.URL property, which are useful when debugging:

<MGLStyle: 0x60800001e0a0; name = "Mapbox Dark", URL = "mapbox://styles/mapbox/dark-v9”>

/cc @1ec5

@friedbunny friedbunny added iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS runtime styling labels Oct 7, 2016
@friedbunny friedbunny added this to the ios-v3.4.0 milestone Oct 7, 2016
@friedbunny friedbunny self-assigned this Oct 7, 2016
@mention-bot

Copy link
Copy Markdown

@friedbunny, thanks for your PR! By analyzing the history of the files in this pull request, we identified @1ec5, @incanus and @boundsj to be potential reviewers.

@incanus incanus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add some internal commentary around the fact that the setStyleJSON() functionality in core performs a reset on the internal impl->styleURL, which means this SDK call can come back empty (or whatever the equivalent is in the bindings).


@interface MGLStyle()
@property (nonatomic, weak) MGLMapView *mapView;
@property (readonly, copy, nullable) NSURL *URL;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine for now, but it would be nice to make this public at some point, especially once we have #6386.

Comment thread platform/ios/src/MGLMapViewDelegate.h Outdated
methods. Changes to sources or layers of the current style do not cause this
method to be called.

This method can be used to initiate runtime styling changes that will be

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don’t use the term “runtime styling” in API or API documentation. How about “modify the layout or appearance of the current style before the map view is displayed to the user”?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe also emphasize that this is the earliest opportunity to make those changes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Went with your suggested wording in 335fa5f.

@1ec5

1ec5 commented Oct 7, 2016

Copy link
Copy Markdown
Contributor

We should add some internal commentary around the fact that the setStyleJSON() functionality in core performs a reset on the internal impl->styleURL, which means this SDK call can come back empty (or whatever the equivalent is in the bindings).

We don’t currently expose any way for the developer to use setStyleJSON(). Once we do in #6386, we may want to allow style URLs to be nullable everywhere. But this PR publicly deals in MGLStyle objects, not style URLs, and the private URL property is safely nullable.

@incanus

incanus commented Oct 7, 2016 •

Copy link
Copy Markdown
Contributor

We don’t currently expose any way for the developer to use setStyleJSON().

Right, but my point is to catch things later, when we need to expose this and it looks like a simple core wiring but actually breaks the functionality in this PR.

@1ec5

1ec5 commented Oct 7, 2016

Copy link
Copy Markdown
Contributor

OK, I’ve added a note to #6386 (comment) to track the expected fallout. I see all the necessary nullable qualifiers in the code added by this PR, in any case.

@friedbunny

Copy link
Copy Markdown
Contributor Author

How does this look to y’all now, @incanus and @1ec5?

@1ec5

1ec5 commented Oct 8, 2016 •

Copy link
Copy Markdown
Contributor
  • Update the iOS and macOS changelogs

return @(self.mapView.mbglMap->getStyleName().c_str());
}

- (NSURL *)URL {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I was thinking of in #6636 (review) is just a comment here, something like:

    // note that if `mbglMap->setStyleJSON()` is ever wired up, this can return unexpected results

@friedbunny friedbunny Oct 8, 2016 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unexpected in what sense? The private definition of this property says it’s nullable. Is there an expectation that URL will end up returning something in the future that isn’t a URL or null?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, misunderstood. Carry on! 👍

@friedbunny

Copy link
Copy Markdown
Contributor Author

How’s this for changelogging?

  • Added the -mapView:didFinishLoadingStyle: delegate method, which offers the earliest opportunity to modify the layout or appearance of the current style before the map view is displayed to the user. (#6636)

@1ec5

1ec5 commented Oct 8, 2016

Copy link
Copy Markdown
Contributor

There's more than one delegate protocol in the library, so best to mention MGLMapViewDelegate by name. Otherwise, that's perfect.

Example: <MGLStyle: 0x60800001e0a0; name = "Mapbox Dark", URL = "mapbox://styles/mapbox/dark-v9">

- Adds an internal `URL` property.
@friedbunny
friedbunny force-pushed the fb-style-loading-delegate branch from 335fa5f to 695358b Compare October 10, 2016 18:17
@friedbunny

Copy link
Copy Markdown
Contributor Author

Added changelog entries and squashed back down to the basic commits.

@1ec5 1ec5 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯🗳

@friedbunny
friedbunny merged commit 5f969e3 into master Oct 11, 2016
@friedbunny
friedbunny deleted the fb-style-loading-delegate branch October 11, 2016 17:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS runtime styling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants