The text layer renders text labels on the map using texture mapping. This Layer is extended based on Icon Layer and wrapped using Composite Layer.
import DeckGL from 'deck.gl';
import TextLayer from './text-layer';
const App = ({data, viewport}) => {
/**
* Data format:
* [
* {text: '#San Francisco', coordinates: [-122.425586, 37.775049]},
* ...
* ]
*/
const layers = [
new TextLayer({
id: 'text-layer',
data
})
];
return <DeckGL {...viewport} layers={[layer]} />;
};
- Default:
x => x.text
Method called to retrieve the content of each text label.
- Default:
x => x.position || x.coordinates
Method called to retrieve the location of each text label.
- Default:
x => x.size || 32
Method called to retrieve the size of each text label. Default value is 32 in pixel.
- Default:
x => x.color || [0, 0, 0, 255]
Method called to retrieve the color of each text label. Default value is black.
- Default:
x => x.angle || 0
Method called to retrieve the angle to rotate (CCW) of each text label. Default value is 0.
- Default: 1
Text size multiplier.
- Default:
false
Whether the layer should be rendered in high-precision 64-bit mode.
- Default:
'Monaco, monospace'
Specifies a prioritized list of one or more font family names and/or generic family names. Follow the specs for CSS font-family.
Specifies a list of characters to include in the font. By default, only characters in the Ascii code range 32-128 are included. Use this prop if you need to display special characters.
- Default:
x => x.textAnchor || 'middle'
Method called to specify the text anchor. Available options include 'start'
, 'middle'
and 'end'
.
- Default:
x => x.alignmentBaseline || 'center'
Method called to specify the alignment baseline. Available options include 'top'
, 'center'
and 'bottom'
.
- Default:
x.pixelOffset || [0, 0]
Method called to specify screen space offset relative to the coordinates
in pixel unit. This function is rarely used in common cases.