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

Tiles do not fit the view when zoomed out #137

Closed ghost closed 10 years ago

ghost commented 10 years ago

I'm using the New York city's subway map to generate the tiles, the original image is 3200px x 3852px 2014-08-31 10_42_26-100 psd 100 layer 1 rgb_8

I used the script found here, and set the tiles like this:

mTileView = new TileView(getActivity());
mTileView.setSize(3200, 3852);
mTileView.addDetailLevel(1.0f, "tiles/1000/%col%_%row%.png", "samples/100.png");
mTileView.addDetailLevel(0.75f, "tiles/500/%col%_%row%.png", "samples/100.png");
mTileView.addDetailLevel(0.50f, "tiles/250/%col%_%row%.png", "samples/100.png");
mTileView.addDetailLevel(0.25f, "tiles/125/%col%_%row%.png", "samples/100.png");
mTileView.setTransitionsEnabled(true);
mTileView.setScaleLimits(0, 4);

but the end result looks bad if I don't zoom in.

2014-08-31 10_46_55-genymotion for personal use - google nexus 7 - 4 3 - api 18 - 800x1280 800x1280

2014-08-31 10_48_12-genymotion for personal use - google nexus 7 - 4 3 - api 18 - 800x1280 800x1280

What am I doing wrong?

ghost commented 10 years ago

tiles and samples are in png format

moagrius commented 10 years ago

There's nothing obviously wrong with the code you posted (although you probably don't need the setScaleLimits call). My first suggestion would be to not use samples, and just try 1 detail level at 1.0f scale If you can't figure it out post your tiles and full code somewhere and I'll take a look.

ghost commented 10 years ago

Turns out the detailScales were wrong, This fixed it:

mTileView.addDetailLevel(1.000f, "tiles/1000/%col%_%row%.png", "samples/100.png");
mTileView.addDetailLevel(0.500f, "tiles/500/%col%_%row%.png", "samples/100.png");
mTileView.addDetailLevel(0.250f, "tiles/250/%col%_%row%.png", "samples/100.png");
mTileView.addDetailLevel(0.125f, "tiles/125/%col%_%row%.png", "samples/100.png");
moagrius commented 10 years ago

glad you got it worked out