ArcGISTiledMapServiceLayer initLayer

978
2
11-16-2012 05:25 AM
BrianOconer
New Contributor
Hello

I coded my own OfflineTiledLayer based on the ArcGISTiledMapServiceLayer. The method "getTile" is overrided. The Tiles be stored at the SD Card as PNG Image.

Like this:
...
byte[] image = super.getTile(level, col, row);
Bitmap bmp = BitmapFactory.decodeByteArray(image, 0, image.length);
dir.mkdirs();
File file = new File(dir, cachedTileFile);
FileOutputStream fOut = new FileOutputStream(file);
bmp.compress(Bitmap.CompressFormat.JPEG, 80, fOut);
fOut.flush();
fOut.close();
...


When the Mobile Internet is deactiveted on the device and i start the app will crash (on initLayer).
The problem should be on the initLayer Method. How can i overide the initLayer that the app also work offline and load the tiles?

-> E/ArcGIS(26273): Caused by: libcore.io.ErrnoException: connect failed: ENETUNREACH (Network is unreachable)
0 Kudos
2 Replies
LukeCatania
New Contributor III
Hello

I coded my own OfflineTiledLayer based on the ArcGISTiledMapServiceLayer. The method "getTile" is overrided. The Tiles be stored at the SD Card as PNG Image.

Like this:
...
byte[] image = super.getTile(level, col, row);
Bitmap bmp = BitmapFactory.decodeByteArray(image, 0, image.length);
dir.mkdirs();
File file = new File(dir, cachedTileFile);
FileOutputStream fOut = new FileOutputStream(file);
bmp.compress(Bitmap.CompressFormat.JPEG, 80, fOut);
fOut.flush();
fOut.close();
...


When the Mobile Internet is deactiveted on the device and i start the app will crash (on initLayer).
The problem should be on the initLayer Method. How can i overide the initLayer that the app also work offline and load the tiles?

-> E/ArcGIS(26273): Caused by: libcore.io.ErrnoException: connect failed: ENETUNREACH (Network is unreachable)


Why your own offline tiled layer when there is one that automatically reads the compact cached format.  Are you creating your own cache in format stored similar to an the ESRI exploded format?
0 Kudos
GISKompetenzzentrum
New Contributor II
Hi, we have the same problem with our app here in Zurich. We tried the same approach but after overwriting initLayer() we still need an internet connection to show the tiles. Without connection the app crashes (network not available error). Is there a solution to usean offline cache?

Thanks for your answer
0 Kudos