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

Feature Request: Infinite Scrolling #373

Open
jcarnide opened this issue Nov 14, 2016 · 12 comments
Open

Feature Request: Infinite Scrolling #373

jcarnide opened this issue Nov 14, 2016 · 12 comments

Comments

@jcarnide
Copy link

First and foremost I just want to say that this library is awesome!

With that being said, I was wondering if infinite scrolling would be a feature you'd consider adding at some point down the road.

If not, how difficult would it be in your opinion to alter the library to get infinite scrolling to work?

After having a brief look at the ZoomPanLayout class, it looks like there's a decent amount of logic built around preventing users from scrolling out of bounds, notably getConstrainedScrollX/Y() and I've only seen forks go as far as adding an elastic band scrolling effect.

It'd understandably be easier to implement if we were working at an OpenGL level, controlling the coordinate system and rendering loop, but I'm just curious if this is a plausible feature for this library.

Thanks in advance!

@moagrius
Copy link
Owner

it would be a lot of work, but not very complicated, if that make sense.

are you trying to represent an infinite plane (like the surface of a sphere, like the earth), or do you want to "loop" around the same set of tiles?

version 3 will be plugin-based, so something like this might qualify. it's probably not something i'd do without a lot more requests, but since it will be plugin based, the intent is that users can hook in to blocks of functionality and modify feature sets. best case for first draft of v3 is several months, maybe closer to a year.

hope that answers your question

@jcarnide
Copy link
Author

jcarnide commented Nov 14, 2016

It would be the former--something where users could infinitely scroll horizontally through a map, similar to how the Google Maps API allows you to do.

Do you have any recommendations/starting points if I were to look into doing the above by myself?

Interesting, so the plugin-based rendition of this library would make it a lot easier to implement something like this?

Thank you for the prompt response.

@moagrius
Copy link
Owner

It would be the former--something where users could infinitely scroll horizontally through a map, similar to how the Google Maps API allows you to do.

Gotcha. Any reason why you wouldn't use Google Maps for that? TileView is usually to fill holes where Google Maps doesn't work (large images, fictional places, very close in work, indoors, etc).

Interesting, so the plugin-based rendition of this library would make it a lot easier to implement something like this?

That's the intention. I've found that most feature requests are really specific to one user's app and modifying the core doesn't seem appropriate. Also if people are just using the lib for non-map type stuff, the probably don't need Markers or Paths, so those would be plugins as well (although those would probably be included out-of-the-box), but yes, the idea would be to let people write the own plugins without having to fork or getting stuck on a version - the plugins would be intended to work even as the core was updated, fixed, improved, etc.

Thank you for the prompt response.

NP!

@jcarnide
Copy link
Author

Gotcha. Any reason why you wouldn't use Google Maps for that? TileView is usually to fill holes where Google Maps doesn't work (large images, fictional places, very close in work, indoors, etc).

It's a little clunky for my use case. I basically need a custom tile source, markers, path drawing and infinite scrolling.

That's the intention. I've found that most feature requests are really specific to one user's app and modifying the core doesn't seem appropriate. Also if people are just using the lib for non-map type stuff, the probably don't need Markers or Paths, so those would be plugins as well (although those would probably be included out-of-the-box), but yes, the idea would be to let people write the own plugins without having to fork or getting stuck on a version - the plugins would be intended to work even as the core was updated, fixed, improved, etc.

Sounds very promising, looking forward to it.

Sorry, I edited my previous message slightly to add in a question, but I don't think you saw it in time.
I was wondering if you had any recommendations/starting points if I were to look into doing the above by myself?

@moagrius
Copy link
Owner

Just off the top of my head: try to make a huge base size (not sure how big the sphere is, it might be too big for this example, but it's a jumping off point), maybe a million dots square. Most of the work will be in wrapping the edges so the "end" is on the left side of the "start" (on both axes).

Remember that the data argument of a DetailLevel can be anything (which is available in BitmapDecoder.getBitmap on the Tile instance through tile.getData(). This does NOT have to be just a string (as is used in the sample and default versio of BitmapDecoder)... You could pass in an instance of an object that has all kinds of information. That data object would handle most everything - generate a bitmap from the column/row normally.

At some point, if it's a sphere, it wraps back around - you'd have to do some calculations around the edges, and probably preform some kind of reset. As soon as they have scrolled past that line that separates the right edge (which wraps back to the left edge), you'll have to do some kind of "reset" that actually puts the scroll position back at 0 but happens in a seamless manner.

The more I think about it, the more work it seems like, but I don't think it'd be impossible.

To start off, I'd probably do a super tiny sphere with really large tiles, just to keep numbers manageable (like 1000x1000 tiles on a 5000x5000 sphere). If the basic logic in there works, then you should be able to adapt those concept really easily to a larger sphere.

HTH, GL

@ameron32
Copy link

@moagrius +1: I would love to play with infinite scrolling.

There is a website http://gmworldmap.com that generates random fictional continents based on some magic number in mathematics (Robert Jenkins’ 32 bit integer hash function... i think). I've adapted the logic to run in Android (via Java) from the original Javascript and created a boundaried version in a test Android app. Works great (if a bit CPU hungry), but you always hit the end of the boundary suddenly upon scrolling.

This would be an awesome usage for infinite scrolling (procedural maps/textures).

@moagrius
Copy link
Owner

@ameron32 are you interested in developing infinite scrolling, or just using it? fwiw i'm spending all my open source time in version 3, so the chance of me getting to infinite scrolling for v2 is nil. j/w...

@ameron32
Copy link

ameron32 commented Feb 23, 2018

@moagrius I'd love to try to implement it, either in v3 or v2.

Where do you see infinite fitting in? What code do you believe needs modification? You know your library the best.

At a glance, I suspect that ZoomPanLayout needs a boundaryless approach. Also, is TileCanvasViewGroup currently capable of a limitless set of data?

I'd love to give this a shot. Let me know you thoughts.

@moagrius
Copy link
Owner

yeah, i think you could just "wrap" it. tiles themselves are rendered by row/column, and zoompanlayout needs a size, but i think you could just repeat when coming to a border, including flings and drags. i'd suggest waiting for v3, since one of the main drivers for v3 is a plugin-style architecture where this would be a perfect candidate. honestly, v3 is going pretty slowly - until i get a nice chunk of down time, and presumably can hunker down and bang it out.

@ameron32
Copy link

I'm in no hurry. Maybe I can help with plugin development in v3.

@moagrius
Copy link
Owner

Sounds great.

@moagrius
Copy link
Owner

v3 (now v4) is up and has working plugins you can check out. The latest commit has a fairly-bug free experience, while the latest release is a little buggy. I'd suggest checking out the latest version of this repo, making your own branch (issue-373), then maybe getting started on the plugin, and I can answer questions or offer support as needed? Assume we get something workable, issue PR, it test it out and code review and once that's done we can merge into master and cut a new release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants