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

Hardcoded size value for symbols along the line #334

Open
mshubin opened this issue Jun 10, 2021 · 3 comments
Open

Hardcoded size value for symbols along the line #334

mshubin opened this issue Jun 10, 2021 · 3 comments

Comments

@mshubin
Copy link

mshubin commented Jun 10, 2021

Hi,

I have a rotated symbols which are placed along the line by using 'symbol-placement' and 'icon-rotation-alignment'. But I've noticed that these symbols appear only when zooming really close to my lines, which is problematic.
By reading the code there is a "magic number" test with a FIXME comment:

const extent = geom.getExtent();
const size = Math.sqrt(Math.max(
  Math.pow((extent[2] - extent[0]) / resolution, 2),
  Math.pow((extent[3] - extent[1]) / resolution, 2))
);
if (size > 150) {
   //FIXME Do not hard-code a size of 150
   ...
}

Do you know how you would like to fix it ?
I don't think that we really need this check, because we can still hide these symbols by using 'minzoom' attribute ? What do you think ?

Thank you in advance,

@ahocevar
Copy link
Member

To properly replace the hard-coded value with a style config option, you would have to use symbol-spacing. Then, instead of using the midpoint of the geometry, you would have to use getLength(), getCoordinateAtM() and the current resolution to determine one or more points along the line where the symbol would be placed.

@mshubin
Copy link
Author

mshubin commented Jun 14, 2021

I see for symbol-spacing argument but correct me if I'm wrong, in this part of code we have only access to RenderFeature and not the LineString geometry. So to use getLength() & getCoordinateAtM() I can use lineStringLength & lineStringCoordinateAtM methods from ol.geom.flat ?

@ahocevar
Copy link
Member

Yes exactly, you have to use the respective functions from ol/geom/flat.

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

No branches or pull requests

2 participants