public class

GeoJSONVectorTileDataSource

extends TileDataSource
java.lang.Object
   ↳ com.carto.datasources.TileDataSource
     ↳ com.carto.datasources.GeoJSONVectorTileDataSource

Class Overview

A tile data source that builds vector tiles from GeoJSON inputs.

Summary

Public Constructors
GeoJSONVectorTileDataSource(int minZoom, int maxZoom)
Constructs a GeoJSONVectorTileDataSource object.
Public Methods
int createLayer(String name)
Creates a new layer with specified name.
synchronized void delete()
void deleteLayer(int layerIndex)
Deletes an existing layer.
MapBounds getDataExtent()
Returns the extent of the tiles in this data source.
TileData loadTile(MapTile mapTile)
Loads the specified tile.
void setLayerFeatureCollection(int layerIndex, Projection projection, FeatureCollection featureCollection)
Sets the feature collection of the specified layer.
void setLayerGeoJSON(int layerIndex, Variant geoJSON)
Sets the features of the specified layer.
[Expand]
Inherited Methods
From class com.carto.datasources.TileDataSource
From class java.lang.Object

Public Constructors

public GeoJSONVectorTileDataSource (int minZoom, int maxZoom)

Constructs a GeoJSONVectorTileDataSource object.
Note: EPSG3857 projection is used.

Parameters
minZoom The minimum zoom level supported by this data source.
maxZoom The maximum zoom level supported by this data source.

Public Methods

public int createLayer (String name)

Creates a new layer with specified name.

Parameters
name The name for the layer.
Returns
  • The layer index of the created layer.
Throws
Exception If an error occured during creation of the layer.
IOException

public synchronized void delete ()

public void deleteLayer (int layerIndex)

Deletes an existing layer.

Parameters
layerIndex The index of layer to delete.

public MapBounds getDataExtent ()

Returns the extent of the tiles in this data source.
The bounds are in coordinate system of the projection of the data source.

Returns
  • The extent of the data source.

public TileData loadTile (MapTile mapTile)

Loads the specified tile.
Note: the tile coordinate system used here is vertically flipped relative to layer tile coordinate system.

Parameters
mapTile The tile to load.
Returns
  • The tile data. If the tile is not available, null may be returned.

public void setLayerFeatureCollection (int layerIndex, Projection projection, FeatureCollection featureCollection)

Sets the feature collection of the specified layer.

Parameters
layerIndex The index of the layer. A layer with empty name will be created if it does not exist yet.
projection Projection for the features in featureCollection. Can be null if the coordinates are based on WGS84.
featureCollection The feature collection for the specified layer.
Throws
Exception If an error occured during updating the layer.
IOException

public void setLayerGeoJSON (int layerIndex, Variant geoJSON)

Sets the features of the specified layer.

Parameters
layerIndex The index of the layer. A layer with empty name will be created if it does not exist yet.
geoJSON A geojson type variant that MUST contain single FeatureColletion element.
Throws
Exception If an error occured during updating the layer.
IOException