-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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 MercatorCoordinate meterInMercatorCoordinateUnits method #8524
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great. I think it's ok to close #8516 and wait for this to go out in the next release. You've answered the original question and if we merge the docs change then we'd have to remember to remove those lines in a few weeks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks the pr and trying to eliminate these magic numbers from the examples!
I think it would be good if the method had a :
- more descriptive name (scale means a lot of different things already)
- if the we can solve the need without adding a magicish factor that is hard to explain. I think it might be better if this converted values in well defined units rather than providing a factor
Do you have any ideas on how we could make these things clearer?
Or do you think this need could be solved by adding something to LngLat instead?
Good comments @ansis. I don't have all the answers or solution, I'm also open to any suggestions you or anyone else has.
If we keep the method as is, then maybe
Okay, so if we instead provided a function like
🤔 I wish I did!:
Since this method is related to the coordinate system used by MercatorCoordinate (0 to 1 or web mercator), I think it's best to have it here. Placing it over with LngLat I think would lead to more confusion. |
@andrewharvey hmm, throwing out some more ideas:
or just keeping what you have already but renaming it to or
|
Good suggestions @ansis . I'm not against putting this method on I think
Then the answer to what is a meterInMercatorCoordinateUnits quite simply becomes the scale to convert data in meters to scale: modelAsMercatorCoordinate.meterInMercatorCoordinateUnits() |
I've just updated the PR with this, let me know what you think. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
All the examples have been moved to https://github.com/mapbox/mapbox-gl-js-docs so those changes need to be moved to a separate pr. This should be good to merge then! |
40cfa3f
to
f8ded79
Compare
Thanks Ansis, I've dropped out the example from here and will open a PR over at the docs repo for the example update.. |
Launch Checklist
an extension to #8516 to add a toScale method to MercatorCoordinate, which abstracts finding the scale value to convert read world units in meters to MercatorCoordinate (0 to 1).
This makes things easier for the developer, as they no longer need to do this calculation themselves when using the custom layers api.