moagrius / TileView

TileView is a subclass of android.view.ViewGroup that asynchronously displays, pans and zooms tile-based images. Plugins are available for features like markers, hotspots, and path drawing.
MIT License
1.46k stars 337 forks source link

determining right-most and bottom-most pan location #453

Closed drshavit closed 6 years ago

drshavit commented 6 years ago

Hi,

I'm creating a map in which when the user reaches one of the sides, a blinking arrow will appear which will send a request for the adjacent map in that direction.

In order to do that, I used onPanBegin and onPanEnd listeners. x and y arguments provided by onPanEnd appear to indicate the top-left corner of the original image size, since when I reach the top left corner of the map - regardless of scale - the values are (0,0). So determining up and left are easy.

My problem is with determining whether I have reached the right and/or bottom of the map. I figured it would be simple as if (map.getBaseWidth() - x == map.getScaledWidth(), but these values do not seem to match. I searched through the TileView object and could not find any means of determining it.

Thanks

moagrius commented 6 years ago

not sure, just log out values. maybe getScrollX() == getBaseWidth()?

drshavit commented 6 years ago

no, I tried that.. I have searched through the entire values and can't find it. What causes the view to 'stop' when it gets to the edges? One of the managers must keep a relative location no?

moagrius commented 6 years ago

it's in ZoomPanLayout, you can see the overriden onScroll here: https://github.com/moagrius/TileView/blob/master/tileview/src/main/java/com/qozix/tileview/widgets/ZoomPanLayout.java#L536, which is limited by getConstrainedScrollX: https://github.com/moagrius/TileView/blob/master/tileview/src/main/java/com/qozix/tileview/widgets/ZoomPanLayout.java#L579

drshavit commented 6 years ago

getConstrainedScrollX solved it! thank you