The following DataSources are available for the Mobile SDK, and are supported on all mobile platforms.
Note: Some DataSources are more generic and can be used for different data types and map layers (vector or raster). Others can only be applied for specific layer types. Please contact us if you have questions about which DataSources are available for your account plan.
Offline Maps from MBTiles
MBTilesTileDataSource is universal datasource for raster, or vector, tile data.
MBtiles as RasterTileLayer
For raster data, use MBTiles format files, and use the following code to generate them:
For packaged vector data, you will need CARTO specific vector files packages (NTVT - NutiTeq Vector Tile) and styling files must be in Mapnik XML format. Download the following, free sample package using OpenStreetMap data:
MBTiles contain the TileJSON formats that include basic map styling for Mapbox. MBTiles support is included in CARTO Mobile SDK. MBTiles uses the SQLite database format, which only requires one file to be downloaded and managed.
The following tools enable you to create MBTile packages:
MapTiler is a utility to create MBTiles from raster geo files (GeoTIFF, JPG, ECW, and so on)
TileMill is an open source generator of map packages for vector geo files, such as Shapefile or PosgGIS geo data
MOBAC is available to download from variety of free sources, such as Bing, OpenStreetMap, and so on. You can even load it from WMS with added configuration
MBUtil enables you to create mbtiles from/to TMS-style tile folders, created with different utilities, such as GDAL utility
Portable Basemap Server is a free utility for Windows and loads data from various commercial servers and custom sources. It is also available in ESRI formats. It works mainly as WMTS server, but can create MBTiles as an extra feature
The following vector map tools enable you to create MBTiles:
The Mobile SDK bundled Package Manager API downloads country-wide, or bounding box based, map packages with OpenStreetMap data. These files are not directly visible, as Package Manager downloads the files, you only use the API
Note: If you need to create vector map files from different sources, or with your own data (e.g. Shapefiles), please contact CARTO support. Our Mobile Developers will provide you with a free converter toolchain for custom conversions.
HTTPTileDataSource is a general datasource that can be used for vector or raster tiles. You can also use CARTO or Web (HTTP) tiles for vector layers. Additionally, you can use Web (HTTP) raster tiles for map layers.
CARTO Online Vector Tile Layer
The Mobile SDK contains built-in vector tiles, as provided by CARTO maps as a service, and is avilale for all account plans. This is useful for basic maps. For vector styling, you can use the same assets provided for offline tiles (OSMBright with 3D buildings osmbright.zip).
Some Mobile SDK plans enable you to use other vector tile map DataSources. These are similar to custom raster map data sources, but a vector decoder is needed for correct implementation.
Connect to MapBox vector tiles, which have a very similar (but not identical) data structure. You can use the same (OSMBright with 3D buildings osmbright.zip) asset for vector styling
Note: Before using these assets in your app, confirm with MapBox if this is allowed and make sure you use your MapBox license key in the URL. You may need to use your custom stylying and vector tile server URL.
The following tags are supported in the URL definition: zoom, x, y, xflipped, yflipped, quadkey.
Mobile SDK contains in-memory DataSources where applications can add vector objects as the map overlay layer.
LocalVectorDataSource is a dynamic DataSource that is initially empty, and allows you to add or remove objects. Objects are cached and by default, all added objects are rendered. For detailed code samples, see Basic Map Features for examples of adding Points, Markers, Texts, Lines and Polygons to map.
App-defined Ground Overlays
BitmapOverlayRasterTileDataSource defines a bitmap image and the geographical coordinates of the bitmap. For details, see Ground Overlays.
There are some DataSources which can use another DataSource as input, and apply internal processing and create a new DataSource as the result. This enables you to create a new DataSource based on a customized logic.
PersistentCacheTileDataSource caches HTTP tiles to a persistent sqlite database file. If the tile already exists in the database, the request to the original DataSource is ignored. This can be applied for both raster and vector tiles. The original DataSource’s expired headers are taken into account as part of the processing.
An in-memory cache DataSource. Although layers also cache tiles, the tiles are uncompressed and usually take 2-5x more memory after being loaded. CompressedCacheTileDataSource keeps all tiles in a compressed format for better use of existing memory.
A tile DataSource that combines two data sources (usually offline and online) and selects tiles based on the zoom level. All requests below a specified zoom level are directed to the first DataSource. All requests at, or above, a specified zoom level are directed to the second Datasource.
Other Built-in DataSources
The following datasources are also built into the Mobile SDK packages.
AssetTileDataSource - loads offline tiles data from a folder (/sdcard or Application sandbox, depending on platform). For example, you can use zoom/x/y.png or zoom_x_y.png file naming structures for offline data
NMLModelLODTreeOnlineDataSource - uses NMLDB online API for “3D city” layer. 3D tools are provided as commercial service. Contact us for more information.
NMLModelLODTreeSqliteDataSource - An offline version of NMLModelLODTreeOnlineDataSource, model that is stored in a sqlite database file. Simple individual 3D objects (NML models) can also be added to the usual LocalVectorDataSource
Shapefiles, GeoTIFF and other GIS DataSources
With the GIS extension we provide OGRVectorDataSource and GDALRasterTileDataSource which can open ESRI Shapefile, GeoTIFF, KML, GML, GPX, MapInfo and many other GIS vector and raster formats. The mobile codes just defines the file and layer to be used in your mobile app. CARTO provides a commercial package for these extensions. Contact us for a free evaluation demonstration.
You can define a custom datasource for your mobile application. See MyMergedRasterTileDataSource from the Sample Apps for an example of using a virtual DataSource. This example uses raster data from two raster datasources and merges the map using pixel aggregations. Note that the second datasource contains transparent, or semitransparent pixels. Otherwise, the pixels from the first datasource are hidden.
Custom DataSourced should extend one of following abstract base classes:
TileDataSource - for tiles (raster or vector)
VectorDataSource - for vector objects
CacheTileDataSource - for custom tile caching (it is a TileDataSource)
Raster Tile Sources
Raster tiles can produce a faster loading map by rendering the map based on pixels of small images. With certain account plans, you can use use external raster map tiles with the Mobile SDK. You can also create your own custom raster tile map source. This section describes the raster tile features available in the Mobile SDK.
In order to apply a raster tile source:
Use the HTTPTileDataSource API function as the tile source
Create RasterTileLayer to apply it
Tip: For general information about raster tiles and geospatial data, see the following Open Source Geospatial Foundation reference materials for Tile Map Service and Featured Tile Layers.
The DataSource constructor uses the following URL patterns. It requires a minimum zoom level above 0, and a maximum zoom level between 14 and 19