Azure-Samples / AzureMapsCodeSamples

A set of code samples for the Azure Maps web control.
https://samples.azuremaps.com
MIT License
322 stars 449 forks source link

Anti-aliasing question #149

Closed Jxlle closed 2 days ago

Jxlle commented 3 days ago

I've recently upgraded to the latest version of the Azure Maps Control package, but I have some issues with the new anti-aliasing (AA) setting on the PolygonLayer. When enabling the setting, my polygons get a dark border around them, as if there is an additional LineLayer drawn with this data source. I don't know if this is by design, so I'll first give my setting and explain it a bit more.

My PolygonLayer consists of several shapes, all rectangles, that are placed next to each other. The shapes share corners, meaning that adjacent shapes share two identical coordinates. This means that there is no space between them. The expected visualization of these shapes is a big rectangle of a singular color, consisting of several smaller rectangles (Because each rectangle has the same fillColor value (and no fillPattern)). However, when enabling the anti-aliasing setting on the layer, I see borders around each shape:

image

When disabling the setting, the borders dissapear:

image

Is it possible that the AA does not take the adjacent shapes into account (which I would expect not to be the case as to how AA usually works)? Or is this effect due to the shapes overlapping?

rbrundritt commented 3 days ago

First off, just set the fillAntialias option to false, as that is the only solution here.

History of this issue:

I came across this a while back, before this option was added to Azure Maps. There is a long story behind it, but basically, the root cause of the issue is not antialiasing specifically, but some other oddity in WebGL (Azure Maps uses MapLibre which is originally a fork of Mapbox gl js, and this issue goes back to at least 2016, and exists in all of them still). This issue doesn't appear too often. You are only the third person that I have had encounter this and mention it in the Azure Maps community in the last 7 years. The first time I didn't think much of it, the second time it came up (last winter) I spent a few days diving into this and eventually figured out the disabling antialiasing helped resolve this issue (or make it less visible). Once I figured that out I reached out to the Azure Maps team and recommended that they expose an option to disable antialiasing so that there is a workaround for this issue for the few data sets that encounter it. This feature is set to true by default as that's what it has been under the hood since the beginning of Azure Maps, and we didn't want to modify the behavior of existing apps, especially since this issue only appears in rare situations. So that new feature was added to provide an option to address this issue, and not the cause of it.

Jxlle commented 2 days ago

Thanks for the info @rbrundritt! Guess I'll close this issue as your answer is clear!