GithubHelp home page GithubHelp logo

Comments (9)

jasondavies avatar jasondavies commented on July 28, 2024

Just noticed the commit comment in 86a1b8a that mentions this.

from polymaps.

mbostock avatar mbostock commented on July 28, 2024

See WebKit Bug 35211 for more information. There are some clumsy workarounds, such as using 257x257 tiles that overlap by 1 pixel, or rounding images to exact pixel boundaries, but it's difficult to get right.

from polymaps.

RandomEtc avatar RandomEtc commented on July 28, 2024

I have some experience mitigating this issue in Modest Maps. Modest Maps JS avoids this using position and size rounding as Mike describes, but there isn't a complex transform stack at play there so it was easier to implement. It does introduce some visual stability issues when smoothly animating the zoom, but in general I think it looks better. If anyone wants to take this on in a fork/branch I'll gladly help out with testing and merging.

from polymaps.

jasondavies avatar jasondavies commented on July 28, 2024

Sounds interesting. Am I right in thinking we need to detect and round fractional pixel positions that result from the container transforms applied here? https://github.com/jasondavies/polymaps/blob/master/src/Layer.js#L72

As well as the individual tile transforms applied further down. For integral zooms this can be done, but I'm not sure about fractional zooms, any ideas?

As for the 1px overlap hack, is that simple to use? I've generated a huge tileset of 256x256 tiles so I'd rather set the tile size in polymaps than regenerate the tileset. I've tried map.tileSize({x: 255, y: 255}) but this doesn't seem to work.

from polymaps.

RandomEtc avatar RandomEtc commented on July 28, 2024

Yeah the desired end result is to round the screen coordinates (the full concatenated transform) of the tiles down to pixel values, and then round up the scale of the tiles (again, full concatenated transform) to the nearest pixel. I'm not completely familiar with how the stack of transforms gets generated but you can see some tile level positioning happening further down at https://github.com/jasondavies/polymaps/blob/master/src/Layer.js#L210 as well.

from polymaps.

palewire avatar palewire commented on July 28, 2024

I've seen this with a couple different tilesets, especially in Firefox on Ubuntu. Bummer.

from polymaps.

jasondavies avatar jasondavies commented on July 28, 2024

I got the overlapping hack to work, but I had to tweak po.image:

--- a/src/Image.js
+++ b/src/Image.js
@@ -5,8 +5,8 @@ po.image = function() {
   function load(tile) {
     var element = tile.element = po.svg("image"), size = image.map().tileSize();
     element.setAttribute("preserveAspectRatio", "none");
-    element.setAttribute("width", size.x);
-    element.setAttribute("height", size.y);
+    element.setAttribute("width", size.x+1);
+    element.setAttribute("height", size.y+1);

     if (typeof url == "function") {
       element.setAttribute("opacity", 0);

Perhaps we should expose the image tile size via .tileSize() in a similar way to po.map? The only reason I can think of is to implement the overlapping hack, but it might be useful for something else.

from polymaps.

jasondavies avatar jasondavies commented on July 28, 2024

Still curious about whether it's even possible to implement this for fractional scale() transforms. As I understand it, even if we round the image positions to the nearest pixel, there's still the problem of the fractional scale() transform, which presumably turns the rounded positions into non-integer values, leading to the subpixel bug again.

Perhaps the scale() transform should also be rounded, this time to the nearest 1/256th?

from polymaps.

jasondavies avatar jasondavies commented on July 28, 2024

See #65 for my fix.

from polymaps.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.