CartoSQLLayer
is a layer to visualize data hosted in your CARTO account and to apply custom SQL.
import DeckGL from '@deck.gl/react';
import {CartoSQLLayer, setDefaultCredentials} from '@deck.gl/carto';
setDefaultCredentials({
username: 'public',
apiKey: 'default_public'
});
function App({viewState}) {
const layer = new CartoSQLLayer({
data: 'SELECT * FROM world_population_2015',
pointRadiusMinPixels: 2,
getLineColor: [0, 0, 0, 0.75],
getFillColor: [238, 77, 90],
lineWidthMinPixels: 1
})
return <DeckGL viewState={viewState} layers={[layer]} />;
}
To install the dependencies from NPM:
npm install deck.gl
# or
npm install @deck.gl/core @deck.gl/layers @deck.gl/carto
import {CartoSQLLayer} from '@deck.gl/carto';
new CartoSQLLayer({});
To use pre-bundled scripts:
<script src="https://unpkg.com/deck.gl@^8.2.0/dist.min.js"></script>
<script src="https://unpkg.com/@deck.gl/carto@^8.2.0/dist.min.js"></script>
<!-- or -->
<script src="https://unpkg.com/@deck.gl/core@^8.0.0/dist.min.js"></script>
<script src="https://unpkg.com/@deck.gl/layers@^8.2.0/dist.min.js"></script>
<script src="https://unpkg.com/@deck.gl/geo-layers@^8.2.0/dist.min.js"></script>
<script src="https://unpkg.com/@deck.gl/carto@^8.2.0/dist.min.js"></script>
new deck.carto.CartoSQLLayer({});
Inherits all properties from MVTLayer
.
Required. Either a sql query or a name of dataset
- Default:
cartodb_id
Optional. A string pointing to a unique attribute at the result of the query. A unique attribute is needed for highlighting a feature split across two or more tiles.
Optional. Object with the credentials to connect with CARTO.
- Default:
{
username: 'public',
apiKey: 'default_public',
serverUrlTemplate: 'https://{user}.carto.com'
}
Optional. MVT BufferSize in pixels
- Default:
1
Optional. MapConfig version
- Default:
1.3.1
Optional. Tile extent in tile coordinate space as defined by MVT specification.
- Default:
4096