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

how to show a line cuted off a short piece at begin or end #5146

Closed
roshomon opened this issue Dec 2, 2024 · 10 comments
Closed

how to show a line cuted off a short piece at begin or end #5146

roshomon opened this issue Dec 2, 2024 · 10 comments
Labels
enhancement New feature or request PR is more than welcomed Extra attention is needed

Comments

@roshomon
Copy link
Contributor

roshomon commented Dec 2, 2024

In maplibre, is there any way to draw a line that's shorter than its actual length in pixel unit, just like CIMGeometricEffectCut in ArcGIS Maps SDK for js,
Any reply would be greatly appreciated!

@roshomon roshomon changed the title how to achieve effect of [CIMGeometricEffectCut] how to show a line cuted off a short piece at begin or end Dec 3, 2024
@HarelM
Copy link
Collaborator

HarelM commented Dec 3, 2024

There is the dash-array and line-pattern
See here for example:
https://maplibre.org/maplibre-style-spec/layers/#line-dasharray
Let me know if this is what you were looking for.

@HarelM HarelM added the need more info Further information is requested label Dec 3, 2024
@roshomon
Copy link
Contributor Author

roshomon commented Dec 4, 2024

thanks for reply!
just like this
Image
dash-array cannot cut only in begin and end.
Maybe it can do it by calculating line length in screen. For example, the length of a line is 100px, I'll cut 10px in the begin and the end. The line-dasharray is [0,10,80,10]. But it cannot solve so many lines in a layer. Also line-dasharray don't support data expressions

@HarelM
Copy link
Collaborator

HarelM commented Dec 4, 2024

Will the following feature request solve this issue?

@roshomon
Copy link
Contributor Author

roshomon commented Dec 4, 2024

After a fashion, data-driven styling for line-dasharray paired with calculating line length can solve the problem. However, it will add a lot of work to calculate and store length of every line. If the source data update frequently, it would be even more difficult

@HarelM
Copy link
Collaborator

HarelM commented Dec 4, 2024

I'm honestly not sure I understand the requirement to be honest from a map designer perspective...

@roshomon
Copy link
Contributor Author

roshomon commented Dec 4, 2024

Actually,the requirement is to show icons with transparent backgrounds at the ends of line. The icons is in a point layer over a line layer. Now the result is
Image
My ideal result is
Image
So is there a good way in MapLibre style?

@HarelM
Copy link
Collaborator

HarelM commented Dec 4, 2024

Wouldn't it be easier to fill the inside of the icon?

@roshomon
Copy link
Contributor Author

roshomon commented Dec 4, 2024

The icons are drawn dynamically and have many kinds,at the same time I want to keep the transparent background of icon as many icons have no obvious border ,just like this:
Image
so can't fill inside.

@HarelM
Copy link
Collaborator

HarelM commented Dec 4, 2024

Well this is currently not possible.
You'll need to define a style spec definition and probably implement it if you want it done.
See here:
https://maplibre.org/maplibre-style-spec/layers/
And obliviously the maplibre-style-spec repo.

I would advise to simply create a circle layer as a background to all the icons and continue to the next problem, but that might just be me...

@HarelM HarelM added enhancement New feature or request PR is more than welcomed Extra attention is needed and removed need more info Further information is requested labels Dec 4, 2024
@roshomon
Copy link
Contributor Author

roshomon commented Dec 6, 2024

ok thanks for relay and professional advise. Maybe I should think about the design of line crossing icon is good in geographic map, as the
design inspiration is from electrical connect graph.
Image

@roshomon roshomon closed this as completed Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request PR is more than welcomed Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants