
CARTO for React (Beta)
Build compelling spatial apps using CARTO, React and deck.gl.
API
Set of functions that allow to work with CARTO APIs.
buildQueryFilters ⇒ string
Returns a SQL query applying a set of filters.
Returns: string
- SQL query
Param | Type | Description |
---|---|---|
data | string |
Dataset name or SQL query |
filters | Object |
Filters to be applied |
executeSQL ⇒ Object
Executes a SQL query against CARTO SQL API
Returns: Object
- Data returned from the SQL query execution
Param | Type | Description |
---|---|---|
credentials | Object |
CARTO user credentials |
credentials.username | string |
CARTO username |
credentials.apiKey | string |
CARTO API Key |
credentials.serverUrlTemplate | string |
CARTO server URL template |
query | string |
SQL query to be executed |
opts | Object |
Additional options for the HTTP request |
opts.format | string |
Output format (i.e. geojson) |
getUserDatasets ⇒ Object
Get the lists of datasets for the user by performing a request to CARTO datasets API
Returns: Object
- List of datasets
Param | Type | Description |
---|---|---|
credentials | Object |
CARTO user credentials |
credentials.username | string |
CARTO username |
credentials.apiKey | string |
CARTO API Key |
credentials.serverUrlTemplate | string |
CARTO server URL template |
opts | Object |
Additional options for the HTTP request |
opts.format | string |
Output format (i.e. geojson) |
buildFeatureFilter ⇒ number|boolean
Returns a number (0-1) or a boolean checking wether a feature should be rendered by widgets and displayed on the map
Returns: number|boolean
- Feature that passes the filter
Param | Type | Default | Description |
---|---|---|---|
filters | Object |
{} | Filters to be applied |
type | string |
‘boolean’ | Output type: number (0-1) or boolean |
useCartoLayerFilterProps ⇒ Object
Returns required default props for layers. It manages filtering and viewport changes.
Param | Type | Description | |
---|---|---|---|
props | Object |
Required default props for layers | |
props.onViewportLoad | function |
Function that is called when all tiles in the current viewport are loaded | |
props.getFilterValue | function |
Accessor to the filterable value of each data object | |
props.filterRange | [number, number] |
The [min, max] bounds of the filter values to display | |
props.extensions | [Object] |
Bonus features to add to the core deck.gl layers | |
props.updateTriggers | Object |
Tells deck.gl exactly which attributes need to change, and when | |
props.updateTriggers.getFilterValue | Object |
Updating getFilterValue accessor when new filters come |