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

How can I use a url as a tile #24

Closed westlinkin closed 10 years ago

westlinkin commented 10 years ago

My picture used in addDetailLevel(1f, "picture file path"), this picture file path is a url, like "http://i1.ytimg.com/vi/EukIx3XYTqI/mqdefault.jpg", how can I code this?

moagrius commented 10 years ago

You can create your own implementation of BitmapDecoder to decode tiles however you want, and set it with setTileDecoder

A BitmapDecoder is a pretty simple interface. It has a single public method that must be implemented - decode - that accepts a file name and a Context instance, and returns a Bitmap.

By default, the TileView will replace %col% and %row% in the pattern provided with the integer values of the column and row being rendered, but this can be overriden by a custom parser implementation, but if you don't have either of those strings in the pattern you pass to addDetailLevel, it won't matter.

Note that the tile view is looking for image tiles - so the example you posted would technically work, but it'd use that image for each tile - probably not what you want.

HTH, post back if you need more help.

westlinkin commented 10 years ago

Thanks, now I can load url as a tile.

Tristus1er commented 10 years ago

And for all, it would be nice of you to post your code, this way it could be integrated to the project for other users :-D

kwent commented 10 years ago

Agree with @Tristus1er :)

moagrius commented 10 years ago

FWIW, someone earlier posted an implementation of loading tiles via http - it's included at BitmapDecoderHttp, and can be used like

tileView.setTileDecoder(new BitmapDecoderHttp());

Of course, it could be implemented using a 3rd-party loader or something similar as well - as long as the BitmpaDecoder implementation returns a bitmap, you can get that bitmap any way you want.

kwent commented 10 years ago

Cool thank you for this.