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

[style] Improve update layer support #85

Merged
merged 7 commits into from
Feb 17, 2021

Conversation

nishant-karajgikar
Copy link
Contributor

@nishant-karajgikar nishant-karajgikar commented Feb 5, 2021

PRs must be submitted under the terms of our Contributor License Agreement CLA.

Pull request checklist:

  • Briefly describe the changes in this PR.
  • Write tests for all new functionality. If tests were not written, please explain why.
  • Add example if relevant.
  • Document any changes to public APIs.
  • Apply changelog label ('breaking change', 'bug 🪲', 'build', 'docs', 'feature 🍏', 'performance ⚡', 'testing 💯') or use the label 'skip changelog'
  • Add an entry inside this element for inclusion in the mapbox-maps-ios changelog: <changelog>Allow a developer to synchronously update a layer with one API call -- no longer have to retrieve and re-add a layer.</changelog>.

Summary of changes

This PR improves the way layers can be updated by introducing a new updateLayer() method which accepts a closure as a parameter. The method takes care of retrieving the layer from the style, passing it to the mutating closure, then applies the changes to the style.

User impact (optional)

Updating a layer is much simpler now:

self.mapView.style.updateLayer(id: "land", type: BackgroundLayer.self) { (layer) in
    layer.paint?.backgroundColor = .constant(.init(color: .blue))
}

@nishant-karajgikar nishant-karajgikar added the feature 🍏 When working on a new feature or feature enhancement label Feb 5, 2021
@nishant-karajgikar nishant-karajgikar self-assigned this Feb 5, 2021
Mapbox/MapboxMapsStyle/Style.swift Show resolved Hide resolved
Mapbox/MapboxMapsStyle/Style.swift Outdated Show resolved Hide resolved
Base automatically changed from nishantk/generate-integration-tests to main February 8, 2021 18:51
@nishant-karajgikar nishant-karajgikar changed the title [style] [wip] Improve update layer support [style] Improve update layer support Feb 17, 2021
@nishant-karajgikar nishant-karajgikar marked this pull request as ready for review February 17, 2021 18:01
@codecov
Copy link

codecov bot commented Feb 17, 2021

Codecov Report

Merging #85 (02ccc29) into main (27d85bf) will decrease coverage by 28.22%.
The diff coverage is 6.25%.

Impacted file tree graph

@@             Coverage Diff             @@
##             main      #85       +/-   ##
===========================================
- Coverage   77.16%   48.93%   -28.23%     
===========================================
  Files         101      101               
  Lines        5658     5683       +25     
===========================================
- Hits         4366     2781     -1585     
- Misses       1292     2902     +1610     
Flag Coverage Δ
Examples ?
unit-tests 48.93% <6.25%> (-0.31%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
Mapbox/MapboxMapsStyle/Style.swift 4.86% <0.00%> (-48.93%) ⬇️
Mapbox/MapboxMapsStyle/Types/Value.swift 61.11% <50.00%> (-22.23%) ⬇️
Mapbox/MapboxMapsStyle/Layers.swift 0.00% <0.00%> (-100.00%) ⬇️
Mapbox/MapboxMapsStyle/Generated/Terrain.swift 0.00% <0.00%> (-100.00%) ⬇️
Mapbox/MapboxMapsFoundation/AccountManager.swift 0.00% <0.00%> (-100.00%) ⬇️
Mapbox/MapboxMapsFoundation/MapboxLogoView.swift 1.02% <0.00%> (-97.58%) ⬇️
...rnaments/ScaleBar/MapboxScaleBarOrnamentView.swift 16.26% <0.00%> (-73.21%) ⬇️
.../Events/MapboxMobileEvents+TelemetryProtocol.swift 0.00% <0.00%> (-66.67%) ⬇️
Mapbox/MapboxMapsSnapshot/Snapshotter.swift 0.00% <0.00%> (-49.51%) ⬇️
...pboxMapsFoundation/Events/EventsStringTokens.swift 0.00% <0.00%> (-43.75%) ⬇️
... and 21 more

@nishant-karajgikar nishant-karajgikar merged commit f496226 into main Feb 17, 2021
@nishant-karajgikar nishant-karajgikar deleted the nishantk/update-layer-support branch February 17, 2021 21:08
persidskiy pushed a commit that referenced this pull request Feb 24, 2023
* Update PointAnnotationManager.swift

* Fix clusterOptions not being passed to PointAnnotationManager initializer.

Co-authored-by: Mai Mai <mai.mai@mapbox.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature 🍏 When working on a new feature or feature enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants