Consuming CartoDB with Nutiteq SDK
This is our third post of CartoDB’s mobile blog series. If you’ve missed any of our previous posts you can view them here and here. In this edition, we’ll continue to build on the information from the earlier posts and present new and compelling details on how you can consume the same CartoDB platform and engine that you love with the Nutiteq SDK.
Once you have the basic app running, you might wonder: how exactly can you consume CartoDB via the SDK? If you have already tried the basic app with the SDK then you may have discovered that there are no CartoDB specific methods. This will change with the next SDK updates. However, you can already consume a lot of the CartoDB platform:
- Use raster map tiles, just define the tile URL for RasterTileLayer.
- To get interactivity (object click data) you can use the UTF Grid. This uses both raster map tiles and json-based UTF tiles. On the CartoDB side, you need to enable and define tootlips.
- You can also load data as vector tiles. The CartoDB platform has beta support to provide Mapbox Vector Tile (MVT) format tiles, which Nutiteq can render on the client side. To use them you also need CartoCSS styling. This provides many advantages, from zooming and rotation of maps to data that can be packaged as offline using mbtiles.
- Loading GeoJSON vector data provides a better look and feel. You can add interactivity (object click actions) and client-side styling of the objects. Also, you can render vector objects as billboard Markers, which “stand up” in 3D view manipulations. For vector data, CartoDB provides an SQL API and app that can load whole tables and render on maps. You can also use client-side simplification and clustering.
- If the data table is large, more than a few thousand objects, then loading whole tables can be too much for the mobile client. Instead, you can use smart, on-demand, view-based loading of vector data. Similar to the SQL API and GeoJSON format used from the CartoDB side, the SDK will use custom vector data sources to consume it. This loads an only a selected visible area of the map. The app can control zoom levels, server-side generalizations, or simplification can be applied.
- For point-based time-series visualizations, you will want to use Torque. This provides animated rendering, and the latest development version of the SDK has a special layer type for it. From the API point of view, it uses the SQL API and CartoCSS styling, but Torque has an additional time control method.
Before consuming CartoDB via the SDK, you need to know specific endpoints — tile URLs, CartoCSS, SQL API endpoints, etc. The best way to get these endpoints is to use the CartoDB Maps API request. This part is not yet done by the SDK, so currently your app needs to handle it itself. It is not very difficult: just JSON+HTTP requests are needed.
Last, but not least — we have just published the CartoDB integration code samples for Advanced Map samples for Android. See:
- CartoDBSQLActivity for vector data (SQL API)
- CartoDBTorqueActivity for Torque tiles
- CartoDBUTFGridActivity for raster tiles and UTFGrid
- CartoDBVectorTileActivity for vector tiles with CartoCSS styling
Just remember that for these you’ll need to use the latest development version (snapshot) of the SDK.
Figure below summarizes various ways how the SDK can consume CartoDB data:
Happy mobile mapping!