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

Add -mapView:didFinishLoadingStyle: delegate methods #6636

Merged
merged 2 commits into from
Oct 11, 2016

Conversation

friedbunny
Copy link
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

@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.

Copy link
Contributor

@incanus incanus left a comment

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).

@@ -34,6 +34,7 @@

@interface MGLStyle()
@property (nonatomic, weak) MGLMapView *mapView;
@property (readonly, copy, nullable) NSURL *URL;
Copy link
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.

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
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
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
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
Copy link
Contributor

1ec5 commented Oct 7, 2016

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
Copy link
Contributor

incanus commented Oct 7, 2016

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
Copy link
Contributor

1ec5 commented Oct 7, 2016

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
Contributor Author

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

@1ec5
Copy link
Contributor

1ec5 commented Oct 8, 2016

  • Update the iOS and macOS changelogs

@@ -92,6 +93,10 @@ - (NSString *)name {
return @(self.mapView.mbglMap->getStyleName().c_str());
}

- (NSURL *)URL {
Copy link
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

Copy link
Contributor Author

@friedbunny friedbunny Oct 8, 2016

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
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
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
Copy link
Contributor

1ec5 commented Oct 8, 2016

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
Contributor Author

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

Copy link
Contributor

@1ec5 1ec5 left a comment

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