Comments (11)
The basic idea is to use really basic math to determine what tiles "interesect" the viewport and so should be rendered - that can be seen in DetailLevel.getIntersections. The idea is that the starting row is viewport.left / tileSize, and the ending row is viewport.right / tileSize - so intersections would be all rows between those two. Same for columns.
On any event that would change the viewport or map (drag, scale, pinch, etc), a handler is sent a delayed message (250 ms buffer, each one removing all previous messages) that requests a render pass. A render pass is handled by a modified AsyncTask (that uses a ThreadPool instead of a single thread) to decode the bitmap (based on the intersections), and position them in ImageViews. Some pretty heavy checks are then performed (for optimization) to determine any tiles that are rendered but are not intersected - these tiles are then destroyed. This is not a SurfaceView, does not use OpenGL, and is not trying to do all the work in onDraw. Since Markers kind of have to be views themselves, to support clicks, children, etc, and tiles might be animated in, I figured it'd be easiest to continue to use the existing Android View mechanism rather than trying to re-invent the wheel and decode the tiles straight to a canvas. Most of this can be seen in TileManager and TileRenderTask.
There's a lot more going on in the widget than I can realistically point out in a post like this, but the above should get you started. Feel free to post back with specific questions.
HTH.
from tileview.
thanks for explanation.
today i had 2 main problem:
firs: i tried to understand your code and find out how you render tiles.i arrived to a method renderIndividualTile( MapTile m ) that display tiles that is decoded in decodeIndividualTile( MapTile m ), am i right ?? if yes . it means that you put tiles together and display tiles in imageview ??
second : tried to build a MainActivity class that extends Activity and tried to render my tiles. i didn't use mapviewlib.jar and i tried to compile your packages(include :animation,geom,layouts,widgets, mapview.geom , mapview.hotspots , mapview.markers , mapview.paths , mapview.tiles , mapview.viewmanagers , mapview.zoom) but i couldn't do that. and many error happened during compilation, what was my problem ??
here is my code :
public class MainActivity extends Activity
{
public MapView mapview;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
mapview = new MapView(this);
setContentView(mapview);
mapview.addZoomLevel(256, 256, Environment.getExternalStorageDirectory()+"/GreatMap/0/%row%/%col%.jpg");
mapview.addZoomLevel(512, 512, Environment.getExternalStorageDirectory()+"/GreatMap/1/%row%/%col%.jpg");
mapview.addZoomLevel(1024, 1024, Environment.getExternalStorageDirectory()+"/GreatMap/2/%row%/%col%.jpg");
mapview.addZoomLevel(2048, 2048, Environment.getExternalStorageDirectory()+"/GreatMap/3/%row%/%col%.jpg");
mapview.addZoomLevel(4096, 4096, Environment.getExternalStorageDirectory()+"/GreatMap/4/%row%/%col%.jpg");
mapview.addZoomLevel(8192, 8192, Environment.getExternalStorageDirectory()+"/GreatMap/5/%row%/%col%.jpg");
mapview.addZoomLevel(16384, 16384, Environment.getExternalStorageDirectory()+"/GreatMap/6/%row%/%col%.jpg");
mapview.setShouldIntercept( true );
}
@Override
public void onPause(){
super.onPause();
mapview.clear();
}
// on resume, get a new render
@Override
public void onResume(){
super.onResume();
mapview.requestRender();
}
@Override
public void onDestroy(){
super.onDestroy();
mapview.destroy();
mapview = null;
}
}
from tileview.
for the first question: yes, tiles are displayed in ImageViews, using the methods you mentioned.
for the second question: looks like you're using MapView and MapViewDemo - you should be using TileView. There is a wiki for running a setup with java (instead of the jar) here.
from tileview.
hi.again: it's kind of weird for me, that u use imageView. i'm just 4 month android(java) programmer, but i always assumed that imageView just display one image at time,can you explan how you do that??
and also here you use child view. whats does it really mean?? i head and saw it many times but i don't know what is it's implementation ??
from tileview.
Each tile is an individual ImageView. Each one is housed in a VIewGroup (ScalingLayout), that are layered in another ViewGroup (TileManager), that's in another ViewGroup (the 'clip' member of ZoomPanLayout). These are are "child views" of one another. Any view is considered a child of the ViewGroup that it's in. The documentation on how Views work might be helpful - try this link.
from tileview.
hi again. in tileView.addDetailLevel method i want to use external storage directory (SDcard) to read tile from there.
but it seems impossible. i got it's permission in manifest.xml but it didn't work.
is there something special to do ??
tileView.addDetailLevel(1f,Environment.getExternalStorageDirectory()+ "/GreatMap/2/%row%/%col%.jpg",Environment.getExternalStorageDirectory()+ "/GreatMap/tile0.jpg");
tileView.addDetailLevel(0.75f,Environment.getExternalStorageDirectory()+ "/GreatMap/3/%row%/%col%.jpg",Environment.getExternalStorageDirectory()+ "/GreatMap/tile0.jpg");
tileView.addDetailLevel(0.5f, Environment.getExternalStorageDirectory()+ "/GreatMap/4/%row%/%col%.jpg",Environment.getExternalStorageDirectory()+ "/GreatMap/tile0.jpg");
tileView.addDetailLevel(0.25f,Environment.getExternalStorageDirectory()+ "/GreatMap/5/%row%/%col%.jpg",Environment.getExternalStorageDirectory()+ "/GreatMap/tile0.jpg");
manifest.xml :
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
another question. in View when i set my view in layout activity xml file i had option to set it's :
android:layout_alignParentLeft="true" or android:layout_alignParentRight="true"
how can i do this in tileView ???
thanks in advance
from tileview.
To read from the SD card you'll need to implement your own BitmapDecoder implementation. The interface has a single method: decode, that takes a String and a Context, and returns a Bitmap. However you get that bitmap is up to you (assets, SD card, HTTP, SVG, dynamic drawing, whatever). There are a couple existing implementations you can check out: BitmapDecoderAssets which is the default, and BitmapDecoderHttp that loads image from a remote server. Again, it's a very simple implementation - just return a Bitmap and you're good to go. Set it with TileView.setTileDecoder
, e.g.,
yourTileView.setTileDecoder(new BitmapDecoderSDCard()); // or whatever you name your custom implementation
For your second question, that isn't really a TileView question, but I'll try to answer anyway: it depends on the parent. Assuming you're using a RelativeLayout, you'd use addRule. This is off the top of my head and probably won't work, but it'd look something like this:
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
yourRelativeLayout.addView(yourTileView, lp);
from tileview.
closing for now - re-open (or open a new issue) if you still need help
from tileview.
@moagrius - I have this same requirement, where I have to get tiles from SD card. I could not understand "To read from the SD card you'll need to implement your own BitmapDecoder implementation".
Usually we add multiple detail levels but with this custom decoder I am not getting how to implement.
If you could explain a bit more, it is highly appreciated
Thanks
from tileview.
To get the bitmap from a filename, TileView uses a BitmapDecoder instance. This interface has one method - decode
that accepts a String filename and a Context instance, and must return a bitmap.
The default implementation is BitmapDecoderAssets, which you can see decodes an image file in the app's assets and returns the bitmap. Another impelementation is BitmapDecoderHttp, which decodes an image file from a remote web server.
You can create and use your own implementation to decode images from any source you want (including SD card), or generate them dynamically, draw from SVG, whatever.
To use an implementation, you just create the instance and assign it with the setTilerDecoder
method, or any similar method, e.g.,
BitmapDecoder decoder = new MyCustomBitmapDecoderImplementation();
tileView.setTileDecoder(decoder); // just used for tiles
// tileView.setDownsampleDecoder(decoder); // also uses the same decoder for samples
// tileView.setDecoder(decoder); // shortcut that does the same thing as calling both of the above methods
Regardless of the decoder, you'd add detail levels as normal.
Hope that makes sense - post back if you have more questions.
from tileview.
from tileview.
Related Issues (20)
- Remote tile demo freezes and crashes HOT 2
- Combine smooth scroll and scale HOT 2
- Tiles not properly laid out when Scale < 1 with remote tiles HOT 15
- Open source but no license? HOT 2
- Markers disappear when zooming HOT 4
- Cannot add tile images on the fly HOT 1
- StreamProvider asked to provide data for rows and columns out of bounds with to small images HOT 5
- Tiles outside the image are created HOT 8
- White text on white background in Advanved Tile Demo HOT 1
- Get touched position when touch on the tileview (version 4.0.7)
- longtouch
- App killed in background crashes when returning to foreground HOT 1
- `android.os.BadParcelableException` regarding `com.moagrius.widget.ScrollView$SavedState.<init>` HOT 1
- Use in viewholder for recycler view. HOT 2
- build() method starts to return void instead of TileView HOT 1
- Mike passed away HOT 5
- Does this lib support SVG format
- JCenter -> MavenCenter
- implementation 'com.qozix:tileview:2.7.7' doesn't seem to work HOT 1
- Impossible import com.qozix.tileview HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tileview.