fix: text overlap

This commit is contained in:
thinkinggis 2020-01-23 00:31:48 +08:00
parent dc914476b1
commit 77020ce1cf
5 changed files with 8 additions and 5 deletions

View File

@ -104,6 +104,7 @@ export default class TextModel extends BaseModel {
}
public buildModels(): IModel[] {
this.extent = this.textExtent();
this.initGlyph();
this.updateTexture();
this.filterGlyphs();

View File

@ -137,6 +137,7 @@ export default class Source extends EventEmitter {
public getFeatureById(id: number): unknown {
const { type = 'geojson' } = this.parser;
if (type === 'geojson' && !this.cluster) {
// TODO 聚合图层返回聚合和后的数据
return id < this.rawData.features.length
? this.rawData.features[id]
: 'null';

View File

@ -20,7 +20,7 @@ interface IRawData {
}
export function pointToHexbin(data: IParserData, option: ITransform) {
const dataArray = data.dataArray;
const { size = 10 } = option;
const { size = 10, method = 'sum' } = option;
const pixlSize = ((size / (2 * Math.PI * R_EARTH)) * (256 << 20)) / 2;
const screenPoints: IRawData[] = dataArray.map((point: IParseDataItem) => {
const [x, y] = aProjectFlat(point.coordinates);
@ -38,12 +38,12 @@ export function pointToHexbin(data: IParserData, option: ITransform) {
const result: IParserData = {
dataArray: hexbinBins.map((hex: IHexBinItem<IRawData>, index: number) => {
if (option.field && option.method) {
if (option.field && method) {
const columns = getColumn(hex, option.field);
hex[option.method] = statMap[option.method](columns);
hex[method] = statMap[method](columns);
}
return {
[option.method]: hex[option.method],
[option.method]: hex[method],
count: hex.length,
coordinates: [hex.x, hex.y],
_id: index + 1,

View File

@ -14,7 +14,7 @@ export function join(geoData: IParserData, options: { [key: string]: any }) {
const { field, data } = options;
const dataObj: { [key: string]: any } = {};
data.forEach((element: { [key: string]: any }) => {
dataObj[element.field] = element;
dataObj[element[field]] = element;
});
geoData.dataArray = data.dataArray.map((item: IParseDataItem) => {
const joinName = item[field];

View File

@ -43,6 +43,7 @@ export default class TextLayerDemo extends React.Component {
.size(12)
.color('#fff')
.style({
textAllowOverlap: true,
// fontWeight: 200,
// textAnchor: 'center', // 文本相对锚点的位置 center|left|right|top|bottom|top-left
// textOffset: [0, 0], // 文本相对锚点的偏移量 [水平, 垂直]