Closed corsc closed 10 years ago
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?
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?
Sure, sounds good - in general I'm always happy to consider any changes that are broadly useful and not API breaking.
closing the issue for now - always happy to take a look at PRs if it happens
I feel like this is a dumb question but I am afraid I'm in need of assistance.
I was trying to write some tests on a Custom View Component that I wrote the extends from TileView and I have been unable figure out how to get the current TileView settings,
For example I was trying to get the center of view port in world co-ordinates.
Thanks.