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

Add example using addProtocol to transform vector tile feature properties #5370

Merged
merged 6 commits into from
Jan 17, 2025

Conversation

neodescis
Copy link
Collaborator

Provides an example of how to solve #4198 using addProtocol.

IMO, this should be favored over #5343 and #4199.

Launch Checklist

  • Confirm your changes do not include backports from Mapbox projects (unless with compliant license) - if you are not sure about this, please ask!
  • Briefly describe the changes in this PR.
  • Link to related issues.
  • Include before/after visuals or gifs if this PR includes visual changes.
  • Write tests for all new functionality.
  • Document any changes to public APIs.
  • Post benchmark scores.
  • Add an entry to CHANGELOG.md under the ## main section.

@neodescis
Copy link
Collaborator Author

@wipfli, check this out. This is how I solved the problem using addProtocol. I believe this is cleaner than our other approach. I'm curious to hear what you think!

Copy link

codecov bot commented Jan 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.95%. Comparing base (f1d58f2) to head (8e92646).
Report is 22 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5370      +/-   ##
==========================================
+ Coverage   91.84%   91.95%   +0.10%     
==========================================
  Files         282      282              
  Lines       38908    38908              
  Branches     6827     6820       -7     
==========================================
+ Hits        35735    35777      +42     
+ Misses       3046     3003      -43     
- Partials      127      128       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

hash: 'map'
});

map.setTransformRequest((url, resourceType) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't this return something in "regular" cases?

Copy link
Collaborator Author

@neodescis neodescis Jan 17, 2025

Choose a reason for hiding this comment

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

If a request transform doesn't return, or returns undefined/null, then nothing happens and the original request parameters are used. I can add the return undefined to be clear though.

Copy link
Collaborator

@HarelM HarelM left a comment

Choose a reason for hiding this comment

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

This is a very nice examples!

@HarelM
Copy link
Collaborator

HarelM commented Jan 17, 2025

It would be interesting to see how this example can be done in a worker thread instead of the main thread, but this is a "nice to have".
In any case, I think the other two PRs can be closed, this is a good enough way to solve this I think...

@neodescis neodescis enabled auto-merge (squash) January 17, 2025 21:55
@neodescis neodescis merged commit 3f28408 into maplibre:main Jan 17, 2025
16 of 17 checks passed
@neodescis neodescis deleted the add-protocol-features-transform branch January 17, 2025 22:00
@wipfli
Copy link
Contributor

wipfli commented Jan 19, 2025

Amazing, thanks for writing this example @neodescis. It great to see how this works with add protocol, and also it is interesting to have now an example which uses import in the html. I always wondered how to do this...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants