Your search returned no results

Try another search term or view Stack Exchange, where we have active conversations with Developers about GIS.

    http://gis.stackexchange.com/
    Support channel in Stack Exchange

    Thousands of developers around the world have helped make CartoDB a success, and we have active conversations with them about GIS in Stack Exchange.

    Go to Stack Exchange

    SDK and CARTO Tools

    For select account plans, you can connect to the CARTO Engine APIs via Mobile SDK, to retrieve map visualizations and table data from your CARTO account. API access is not available for free users. Contact us for questions about your account plan and enabling this feature.

    Loading CARTO Map Data

    There are several methods of connecting map data from your CARTO account (via the Mobile SDK) to your mobile app; depending on the size of your data, the visual requirements, and other factors.

    • To use a map as raster map tiles, define the tile URL for RasterTileLayer

    • To apply interactivity (object click data), use UTFGrid. This uses both raster map tiles and json-based UTF tiles

      Tip: For CARTO Builder, you will need to enable and define tooltips with the POP-UP feature

    • Load vector tiles, the CARTO Engine supports Mapbox Vector Tile (MVT) format tiles, which the Mobile SDK can render on the client side. You will also need CartoCSS styles to view vector tiles. This is useful for applying advanced styling features, such as zooming and rotating maps based on data that can be packaged for offline line, using mbtiles

    • Load GeoJSON vector data. This is useful if you need need more advanced interactivity (object click actions) or dynamic client-side styling of the objects. For vector data, the CARTO Engine provides a SQL API and mobile app that can load entire tables and render maps. You can also use client-side simplification and clustering

    • If the data table is large (more than a few thousand objects), then loading entire tables can overload the mobile client. Alternatively, use on-demand, view-based loading of vector data. Similar to the SQL API and GeoJSON format used on the CARTO Engine side, the SDK applies custom vector data sources to load data. Only a selected, visible area, of the map will load. The mobile app can control zoom levels, server-side generalizations, and simplifications can be applied

    • For point-geometry time-series visualizations, use the Animated aggregation to define Torque maps. This provides animated rendering, and the Mobile SDK has a special layer TorqueTileLayer to define this. From an API standpoint, Torque uses the SQL API and CartoCSS styling, but Torque contains an additional time control method

    Offline maps

    CARTO Mobile SDK offers several ways to use map data offline, but the suggested method is via CARTO platform:

    1. Upload your data to CARTO, create a new map with CARTO Builder, and apply map custom styling with CartoCSS.
    2. Use the Mobile Tile Packager tool to create the offline map data package.
    3. Load the package file to the mobile device - you can have your app download it from your server, or add it as bundled asset to your app.
    4. Add the map to MapView, as a VectorTileLayer, from MBTilesTileDataSource and CartoCSS.

    This method enables you to get both optimized vector tiles and suitable CartoCSS styling for your map.

    For details, see the Readme file of the Mobile Tile Packager.

    Online maps

    If you have map data in a CARTO database, you can show it on mobile using any of the following methods:

    1) Integrate with the Maps API for Anonymous or Named maps

    CartoMapsService is a mobile service that can be used to automatically configure layers using anonymous map configurations, or by using parametrized named maps

    2) Integrate with the SQL API for accessing database

    CartoSQLService is a high-level interface for the CARTO SQL Service. The mobile service can be used to query data from CARTO databases using explicit SQL queries. Note that this is only available for Public datasets.

    Maps API

    CARTO Mobile SDK supports Maps API integration for Anonymous Maps and Named Maps. Anonymous maps allow you to instantiate a map given SQL and CartoCSS. Named Maps are essentially the same as Anonymous Maps except the MapConfig is stored on the server, and the map is given a unique name.

    Building an Anonymous map config (SQL and CartoCSS)

    Use CARTO Maps service class to configure layers. Note that this must be done in a separate thread on Android, as Maps API requires connecting to server, which is not allowed in the main thread.

    The following snippet sets up the config (SQL and CartoCSS) we are going to use in our query

    Now that the config is set up, you can apply the actual query. This snippet is for querying data from an anonymous vector table (change the default vector layer mode to false if you are using a raster table).

    If you have the name of a map, use that to query data, instead of providing the SQL or CartoCSS

    SQL API

    CARTO’s SQL API allows you to interact with your tables and data inside CARTO, as if you were running SQL statements against a normal database. You can use the SQL API to insert, update or delete data (i.e., insert a new column with a latitude and longitude data) or to select data from public tables in order to use it on your website or application (i.e., display the 10 closest records to a particular location).

    Using CARTO SQL Service class to make a query

    CARTO API Samples

    The CARTO sample app projects contain a number of working samples for all the mobile platforms:

    • CartoVisJsonActivity load complete map configurations (from online viz.json)

    • CartoSQLActivity vector data via SQL API

    • CartoTorqueActivity for Torque tiles

    • CartoUTFGridActivity for raster tiles and UTFGrid

    • CartoVectorTileActivity for vector tiles with CartoCSS styling

    • CartoRasterTileActivity for raster tiles with CartoCSS styling