The Scatterplot Layer takes in paired latitude and longitude coordinated points and renders them as circles with a certain radius.
import DeckGL from '@deck.gl/react';
import {ScatterplotLayer} from '@deck.gl/layers';
function App({data, viewState}) {
/**
* Data format:
* [
* {name: 'Colma (COLM)', code:'CM', address: '365 D Street, Colma CA 94014', exits: 4214, coordinates: [-122.466233, 37.684638]},
* ...
* ]
*/
const layer = new ScatterplotLayer({
id: 'scatterplot-layer',
data,
pickable: true,
opacity: 0.8,
stroked: true,
filled: true,
radiusScale: 6,
radiusMinPixels: 1,
radiusMaxPixels: 100,
lineWidthMinPixels: 1,
getPosition: d => d.coordinates,
getRadius: d => Math.sqrt(d.exits),
getFillColor: d => [255, 140, 0],
getLineColor: d => [0, 0, 0]
});
return <DeckGL viewState={viewState}
layers={[layer]}
getTooltip={({object}) => object && `${object.name}\n${object.address}`} />;
}To install the dependencies from NPM:
npm install deck.gl
# or
npm install @deck.gl/core @deck.gl/layersimport {ScatterplotLayer} from '@deck.gl/layers';
new ScatterplotLayer({});To use pre-bundled scripts:
<script src="https://unpkg.com/deck.gl@^8.0.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.0.0/dist.min.js"></script>new deck.ScatterplotLayer({});Inherits from all Base Layer properties.
radiusUnits (String, optional) 'meters'The units of the radius, one of 'meters', 'common', and 'pixels'. See unit system.
radiusScale (Number, optional) 1A global radius multiplier for all points.
lineWidthUnits (String, optional) 'meters'The units of the line width, one of 'meters', 'common', and 'pixels'. See unit system.
lineWidthScale (Number, optional) 1A global line width multiplier for all points.
stroked (Boolean, optional)falseOnly draw outline of points. It falls back to outline if not provided.
filled (Boolean, optional)trueDraw the filled area of a point.
radiusMinPixels (Number, optional) 0The minimum radius in pixels. This prop can be used to prevent the circle from getting too small when zoomed out.
radiusMaxPixels (Number, optional) Number.MAX_SAFE_INTEGERThe maximum radius in pixels. This prop can be used to prevent the circle from getting too big when zoomed in.
lineWidthMinPixels (Number, optional) 0The minimum line width in pixels. This prop can be used to prevent the stroke from getting too thin when zoomed out.
lineWidthMaxPixels (Number, optional) Number.MAX_SAFE_INTEGERThe maximum line width in pixels. This prop can be used to prevent the path from getting too thick when zoomed in.
billboard (Boolean, optional)falseIf true, rendered circles always face the camera. If false circles face up (i.e. are parallel with the ground plane).
antialiasing (Boolean, optional)trueIf true, circles are rendered with smoothed edges. If false, circles are rendered with rough edges. Antialiasing can cause artifacts on edges of overlapping circles. Also, antialiasing isn't supported in FirstPersonView.
getPosition (Function, optional) object => object.positionMethod called to retrieve the position of each object.
getRadius (Function|Number, optional) 1The radius of each object, in units specified by radiusUnits (default meters).
getColor (Function|Array, optional) [0, 0, 0, 255]The rgba color is in the format of [r, g, b, [a]]. Each channel is a number between 0-255 and a is 255 if not supplied.
It will be overridden by getLineColor and getFillColor if these new accessors are specified.
getFillColor (Function|Array, optional) [0, 0, 0, 255]The rgba color is in the format of [r, g, b, [a]]. Each channel is a number between 0-255 and a is 255 if not supplied.
getColor.getLineColor (Function|Array, optional) [0, 0, 0, 255]The rgba color is in the format of [r, g, b, [a]]. Each channel is a number between 0-255 and a is 255 if not supplied.
getColor.getLineWidth (Function|Number, optional) 1The width of the outline of each object, in units specified by lineWidthUnits (default meters).
strokeWidth.