Codota Logo
MBTilesLayer
Code IndexAdd Codota to your IDE (free)

How to use
MBTilesLayer
in
com.mapbox.mapboxsdk.tileprovider.tilesource

Best Java code snippets using com.mapbox.mapboxsdk.tileprovider.tilesource.MBTilesLayer (Showing top 6 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Charset c =
  • Codota IconString charsetName;Charset.forName(charsetName)
  • Codota IconCharset.defaultCharset()
  • Codota IconContentType contentType;contentType.getCharset()
  • Smart code suggestions by Codota
}
origin: posm/OpenMapKitAndroid

/**
 * Reads and opens a MBTiles file given by url and loads its tiles into this layer.
 */
private void initialize(String url, final Context context) {
  initialize(getFile(url, context));
}
origin: posm/OpenMapKitAndroid

/**
 * Initialize a new tile layer, represented by a Database file.
 *
 * @param db a database used as the MBTiles source
 */
public MBTilesLayer(final SQLiteDatabase db) {
  super(getFileName(db.getPath()), db.getPath());
  initialize(db);
}
origin: posm/OpenMapKitAndroid

private void selectMBTilesBasemap(String mbtilesPath) {
  File mbtilesFile = new File(mbtilesPath);
  if(!mbtilesFile.exists()) {
    AlertDialog.Builder builder = new AlertDialog.Builder(mapActivity);
    builder.setTitle("Offline Basemap Not Found");
    builder.setMessage("Please check out a deployment or add MBTiles files to " + ExternalStorage.getMBTilesDir());
    builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
      public void onClick(DialogInterface dialog, int id) {
        //placeholder
      }
    });
    AlertDialog dialog = builder.create();
    dialog.show();
    return;
  }
  //add mbtiles to map
  MBTilesLayer mbTilesLayer = new MBTilesLayer(mbtilesFile);
  mapView.setTileSource(mbTilesLayer);
  setSelectedBasemap(mbtilesPath);
  // if we set an MBTiles from a DeploymentDetails, the map may not start panned to the bounds
  if (needsBoundsChecking) {
    BoundingBox bbox = mbTilesLayer.getBoundingBox();
    mapView.zoomToBoundingBox(bbox);
    needsBoundsChecking = false;
  }
}
origin: posm/OpenMapKitAndroid

/**
 * Initialize a new tile layer, represented by a MBTiles file.
 *
 * @param file a MBTiles file
 */
public MBTilesLayer(final File file) {
  super(file.getName(), file.getAbsolutePath());
  initialize(file);
}
origin: posm/OpenMapKitAndroid

private File getFile(String url, final Context context) {
  if (context != null) {
    //we assume asset here
    AssetManager am = context.getAssets();
    InputStream inputStream;
    try {
      inputStream = am.open(url);
      final File mbTilesDir;
      if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
          || (!Environment.isExternalStorageRemovable())) {
        mbTilesDir = new File(context.getExternalFilesDir(null), url);
      } else {
        mbTilesDir = new File(context.getFilesDir(), url);
      }
      return createFileFromInputStream(inputStream, mbTilesDir.getPath());
    } catch (IOException e) {
      Log.e(TAG, "MBTiles file not found in assets: " + e.toString());
      return null;
    }
  }
  try {
    return new File(url);
  } catch (Exception e) {
    Log.e(TAG, "can't load MBTiles: " + e.toString());
    return null;
  }
}
origin: posm/OpenMapKitAndroid

/**
 * Initialize a new tile layer, represented by a MBTiles file.
 *
 * @param url     path to a MBTiles file
 * @param context the graphics drawing context
 */
public MBTilesLayer(final Context context, final String url) {
  super(url.substring(url.lastIndexOf('/') + 1, url.lastIndexOf('.')), url);
  initialize(url, context);
}
com.mapbox.mapboxsdk.tileprovider.tilesourceMBTilesLayer

Javadoc

A layer that pulls resources from an MBTiles file. Used for offline map tiles, like those generated by TileMill.

Most used methods

  • <init>
    Initialize a new tile layer, represented by a MBTiles file. This constructor does need a context but
  • createFileFromInputStream
    Creates a file from an input stream by reading it byte by byte. todo: same as MapViewFactory's creat
  • getBoundingBox
  • getFile
  • getFileName
    Get the filename of this layer based on the full path
  • initialize
    Reads and opens a MBTiles file given by url and loads its tiles into this layer.

Popular in Java

  • Creating JSON documents from java classes using gson
  • setContentView (Activity)
  • putExtra (Intent)
  • onCreateOptionsMenu (Activity)
  • Point (java.awt)
    A point representing a location in (x, y) coordinate space, specified in integer precision.
  • FileOutputStream (java.io)
    A file output stream is an output stream for writing data to aFile or to a FileDescriptor. Whether
  • FileWriter (java.io)
    Convenience class for writing character files. The constructors of this class assume that the defaul
  • BigInteger (java.math)
    Immutable arbitrary-precision integers. All operations behave as if BigIntegers were represented in
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now