-
Notifications
You must be signed in to change notification settings - Fork 19.6k
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
feature: introduce projection to map #16364
Conversation
…e after projection
Thanks for your contribution! The pull request is marked to be Document changes are required in this PR. Please also make a PR to apache/echarts-doc for document changes and update the issue id in the PR description. When the doc PR is merged, the maintainers will remove the |
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.
LGTM. BTW, is there any plan to add some examples for this? It's a great feature!
@plainheart Sure! Examples are definitely needed! |
Congratulations! Your PR has been merged. Thanks for your contribution! 👍 |
Brief Information
This pull request is in the type of:
What does this PR do?
This Pull Request includes several enhancement for the map series and geo component.
Support LineString and MultiLineString in GeoJSON
Introduce custom projection methods
Previously we only use naive projection that linear mapping lng/lat coords to the screen space. In this PR we expose a new projection API in map/geo so developers can use more complex projection methods.
The interface:
Usually we only need the
project
andunproject
method. Here is an simple example of mercator projection:And we can use the massive projection methods from d3-geo
d3-geo also provides projection rotate. Using this method we can do things like put pacific in the center. But it's easy to get into antimeridian artifacts:
To solve this issue, we need to introduce the whole projection stream from d3 so it will handle the antimeridian clipping. That's what
projection.stream
.Basically it's only designed for d3-geo. But you can implenent it if you want. Check the stream interface description in https://github.com/d3/d3-geo#streams. The bonus of introducing the whole stream is that adaptive sampling will also be applied automatically
Without adpative sampling:
With adaptive sampling:
Some notes:
projection
can only be applied to GeoJSON source.aspectScale
will be ignored when projection is given.center
will use the projected code if projection is give.Limitations:
I haven't test other methods rather than
rotate
in theprojection
yet. Most of them are related to transforming to screen space. Liketranslate
,scale
,clipExtent
,fitExtent
,reflectX
,reflectY
,fitExtent
,fitWidth
,fitHeight
. They should not been used because they may conflicts with the builtin transform.Optimize label position calculation
Previously we calculate the position by using the center of feature bounding rect. It's very easing to have label position outside the polygon. In this PR I using centroid of the larges polygon as label position. There improvement is significantly
Before:
After:
Fixed issues
Map projection:
#10253
#12515
#3899
LineString:
#5530
#3432
Misc
Related test cases or examples to use the new APIs
See
Some screenshot
Animated:
map-projection.mp4
Others
Merging options
Other information