Giter VIP home page Giter VIP logo

Comments (4)

moagrius avatar moagrius commented on May 22, 2024

I've considered making all the private access stuff protected instead, and would still be open to doing that if it looked like it'd be helpful, but for now the member that has the viewport is private (DetailManager, which has the getViewport method). That said, it's pretty simple to get the viewport - the top and left are just getScrollX/Y and bottom and right just have getWidth/Height added... (you can see it calculated here)

There is no built-in method of going backwards (pixels to coordinates), but the math is pretty straightforward. To get the x you'd do something like:

double relativeX = x / <total width of tile view>;  // probably tileView.getBaseWidth
double rangeX = bottomRight.longitude - topLeft.longitude;  // whatever you set in defineBounds
double longitude = topLeft.longitude + rangeX * relativeX;

In the old widget (MapView) there were some methods for going back and forth between pixels and coordinates you might find helpful if the above isn't clear.

So you'd just use the getScrollX/Y methods and getWidth/Height to figure out the 4 values for the viewport, then take each of those and apply the relative factor to find the coordinate version.... Does that help?

from tileview.

corsc avatar corsc commented on May 22, 2024

Yeah I think so, I was messing around in getScroll() methods and getWidth() methods with little success. I will give it another shot and advice. If it looks useful (and working) when I am done, I can PR it back to you if you want?

from tileview.

moagrius avatar moagrius commented on May 22, 2024

Sure, sounds good - in general I'm always happy to consider any changes that are broadly useful and not API breaking.

from tileview.

moagrius avatar moagrius commented on May 22, 2024

closing the issue for now - always happy to take a look at PRs if it happens

from tileview.

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.