Closed mollymerp closed 7 years ago
This would also be good for parity with MapKit in the iOS and macOS SDKs. (MapKit’s MKOverlayPathRenderer.lineDashPattern
property is measured in screen points.)
@mollymerp sounds like this is the best option.
If we do this, is it possible to also refactor the function behavior of line-dasharray
to interpolate at integer zoom levels (similar to the behavior of layout number properties), as opposed to being piecewise? I believe that the reason this wasn't done in the first place is that line dasharrays are rendered like line patterns, so we matched the function behavior of line patterns. However, since we are generating the line-dasharray images in the renderer, would it not be possible to generate a new line-dasharray image at every integer zoom level, based on the interpolated value?
If it is possible to implement this ^, I think it would greatly reduce the burden on designers for matching line-dasharray
to line-width
, because it would then be possible to match the stops and base values. I think this would also more closely match user expectations for the line-dasharray
values (I think it's currently the only number property that is piecewise).
FWIW though, I do personally already write line-dasharray
values as functions about 50% of the time, because it is often desirable for the proportions of lines and gaps to change across zoom levels (e.g. it's often desirable for gaps to tighten up as you increase zoom level).
This issue was moved to mapbox/mapbox-gl-js#4158
After discussing with @ansis and @jfirebaugh it seems that the most straight-forward way to make data-driven
line-width
andline-dasharray
possible, would be to change the units ofline-dasharray
to absolute pixels (from relative units ofline-width
) becauseThis would introduce some complexity in stying lines with
line-dasharray
because they would need additional zoom functions to stay in sync with line-width to make sure theline-dasharray
appears consistent as the map zooms. This seems like a reasonable tradeoff to keeping property function evaluation consistent across all paint properties (we'd need to introduce many exceptions to the current code path ifline-dasharray
stays a relative value).Interested to hear thoughts on this! cc @lucaswoj @nickidlugash
Previous discussion on the possible approaches to solving this problem here: https://github.com/mapbox/mapbox-gl-js/issues/3682