Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I modified somethings and it worked. Here is the code:</p> <p><strong>CustomMapTileProvider.java</strong></p> <pre><code>public class CustomMapTileProvider implements TileProvider { private static final int TILE_WIDTH = 256; private static final int TILE_HEIGHT = 256; private static final int BUFFER_SIZE = 16 * 1024; Override public Tile getTile(int x, int y, int zoom) { byte[] image = readTileImage(x, y, zoom); return image == null ? null : new Tile(TILE_WIDTH, TILE_HEIGHT, image); } private byte[] readTileImage(int x, int y, int zoom) { FileInputStream in = null; ByteArrayOutputStream buffer = null; try { in = new FileInputStream(getTileFile(x, y, zoom)); buffer = new ByteArrayOutputStream(); int nRead; byte[] data = new byte[BUFFER_SIZE]; while ((nRead = in .read(data, 0, BUFFER_SIZE)) != -1) { buffer.write(data, 0, nRead); } buffer.flush(); return buffer.toByteArray(); } catch (IOException e) { e.printStackTrace(); return null; } catch (OutOfMemoryError e) { e.printStackTrace(); return null; } finally { if ( in != null) try { in .close(); } catch (Exception ignored) {} if (buffer != null) try { buffer.close(); } catch (Exception ignored) {} } } private File getTileFile(int x, int y, int zoom) { File sdcard = Environment.getExternalStorageDirectory(); String tileFile = "/TILES_FOLDER/" + zoom + '/' + x + '/' + y + ".png"; File file = new File(sdcard, tileFile); return file; } } </code></pre> <p><strong>Add TileOverlay to your GoogleMap instance</strong></p> <pre><code>... map.setMapType(GoogleMap.MAP_TYPE_NONE); TileOverlayOptions tileOverlay = new TileOverlayOptions(); tileOverlay.tileProvider(new CustomMapTileProvider()); map.addTileOverlay(tileOverlay).setZIndex(0); ... </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload