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

Pixelorigin #424

Merged
merged 20 commits into from
Sep 14, 2019
Merged

Pixelorigin #424

merged 20 commits into from
Sep 14, 2019

Conversation

sashadev-sky
Copy link
Member

@sashadev-sky sashadev-sky commented Sep 3, 2019

Fixes #402 (<=== Add issue number here)

Make sure these boxes are checked before your pull request (PR) is ready to be reviewed and merged. Thanks!

  • PR is descriptively titled 📑 and links the original issue above 🔗
  • tests pass -- look for a green checkbox ✔️ a few minutes after opening your PR -- or run tests locally with grunt
  • code is in uniquely-named feature branch and has no merge conflicts 📁
  • screenshots/GIFs are attached 📎 in case of UI updates
  • @mention the original creator of the issue in a comment below for help or for a review

We're happy to help you get this ready -- don't be afraid to ask for help, and don't be discouraged if your tests fail at first!

If tests do fail, click on the red X to learn why by reading the logs.

Please be sure you've reviewed our contribution guidelines at https://publiclab.org/contributing-to-public-lab-software

Thanks!

=======
changes:

  • updated debug/pixelorigin.html to use one of our distortableImageOverlay's instead of a marker
  • bounds are now saved on the image corner and updated appropriately - one of the pending things wanted to implement to fix downstream MK logic (Implementgroup mapknitter#959)
    • note that setBounds calls _reset, so we no longer use that method ourselves.
  • updated dragging logic to use setCorners() as well, also mentioned as useful in Implementgroup mapknitter#959
  • bump to 0.7.8
  • update docs

pending:

=======

@sashadev-sky
Copy link
Member Author

@jywarren @rexagod here is an explanation of this one because its a little tricky -

the typical L.Draggable leaflet object is allowed to just leave the map:

typical

Since we overrode this method, instead we get a result like the one shown in #402:
63525312-c5741580-c4fd-11e9-9503-6e67e9621636

To fix this I update setCorners with a conditional that uses a formula based on the information from Leaflet docs that
image

which came out like this:

   for (var k in latlngObj) {
      if ((zoom === 0 && (map.project(latlngObj[k]).y < 2 || map.project(latlngObj[k]).y >= 255)) ||
          (zoom !== 0 && (map.project(latlngObj[k]).y / zoom < 2 || map.project(latlngObj[k]).y / Math.pow(2, zoom) >= 255))
      ) {
        // calling reset / update w/ the same corners bc it prevents a marker flicker for rotate
        this.setBounds(L.latLngBounds(this.getCorners()));
        this.fire('update');
        return;
      }
    }

2 is for the top, 255 is for the bottom. Made it less than 256 because 256 would trigger the distortions.

This results in:
now

@sashadev-sky
Copy link
Member Author

let me know your thoughts and ill make corresponding doc updates if you like it!

@sashadev-sky
Copy link
Member Author

@jywarren were u ok with this solution?

@sashadev-sky
Copy link
Member Author

@jywarren merging here first because its already ready.

@sashadev-sky sashadev-sky merged commit 09b63b6 into publiclab:main Sep 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Strange behavior on map edges
2 participants