fix: layer style storkeColor->stroke

This commit is contained in:
thinkinggis 2019-12-26 00:16:33 +08:00
parent 8fc57ceeaf
commit 13ef541232
10 changed files with 19 additions and 23 deletions

View File

@ -73,7 +73,8 @@ module.exports = [
'isFunction', 'isFunction',
'cloneDeep', 'cloneDeep',
'isString', 'isString',
'isNumber' 'isNumber',
'merge'
] ]
} }
}), }),

View File

@ -14,7 +14,7 @@ export interface ICircleVertex {
color: number[]; color: number[];
radius: number; radius: number;
opacity: number; opacity: number;
strokeColor: number[]; stroke: number[];
strokeWidth: number; strokeWidth: number;
strokeOpacity: number; strokeOpacity: number;
} }
@ -68,7 +68,7 @@ export function packCircleVertex(
tileY, tileY,
shape, shape,
opacity, // packed buffer1 opacity, // packed buffer1
strokeColor, stroke,
strokeWidth, strokeWidth,
strokeOpacity, // packed buffer2 strokeOpacity, // packed buffer2
} = props; } = props;
@ -81,8 +81,8 @@ export function packCircleVertex(
packUint8ToFloat(color[2], color[3]), packUint8ToFloat(color[2], color[3]),
]; ];
const packedStrokeColor: [number, number] = [ const packedStrokeColor: [number, number] = [
packUint8ToFloat(strokeColor[0], strokeColor[1]), packUint8ToFloat(stroke[0], stroke[1]),
packUint8ToFloat(strokeColor[2], strokeColor[3]), packUint8ToFloat(stroke[2], stroke[3]),
]; ];
[ [

View File

@ -55,7 +55,7 @@ let layerIdCounter = 0;
export default class BaseLayer<ChildLayerStyleOptions = {}> extends EventEmitter export default class BaseLayer<ChildLayerStyleOptions = {}> extends EventEmitter
implements ILayer { implements ILayer {
public id: string = `${layerIdCounter++}`; public id: string = `${layerIdCounter++}`;
public name: string; public name: string = `${layerIdCounter++}`;
public type: string; public type: string;
public visible: boolean = true; public visible: boolean = true;
public zIndex: number = 0; public zIndex: number = 0;

View File

@ -1,4 +1,4 @@
export const enum lineStyleType { export enum lineStyleType {
'solid' = 0.0, 'solid' = 0.0,
'dash' = 1.0, 'dash' = 1.0,
} }
@ -9,8 +9,3 @@ export interface ILineLayerStyleOptions {
dashArray?: [number, number]; dashArray?: [number, number];
segmentNumber: number; segmentNumber: number;
} }
export const lineStyleObj: { [key: string]: number } = {
solid: 0.0,
dash: 1.0,
};

View File

@ -21,12 +21,12 @@ export default class ConfigSchemaValidationPlugin implements ILayerPlugin {
public apply(layer: ILayer) { public apply(layer: ILayer) {
layer.hooks.init.tap('ConfigSchemaValidationPlugin', () => { layer.hooks.init.tap('ConfigSchemaValidationPlugin', () => {
this.configService.registerLayerConfigSchemaValidator( this.configService.registerLayerConfigSchemaValidator(
layer.name, layer.name as string,
layer.getConfigSchemaForValidation(), layer.getConfigSchemaForValidation(),
); );
const { valid, errorText } = this.configService.validateLayerConfig( const { valid, errorText } = this.configService.validateLayerConfig(
layer.name, layer.name as string,
layer.getLayerConfig(), layer.getLayerConfig(),
); );

View File

@ -4,7 +4,7 @@ import PointModels, { PointType } from './models/index';
interface IPointLayerStyleOptions { interface IPointLayerStyleOptions {
opacity: number; opacity: number;
strokeWidth: number; strokeWidth: number;
strokeColor: string; stroke: string;
} }
export default class PointLayer extends BaseLayer<IPointLayerStyleOptions> { export default class PointLayer extends BaseLayer<IPointLayerStyleOptions> {
public type: string = 'PointLayer'; public type: string = 'PointLayer';

View File

@ -15,19 +15,19 @@ import pointFillVert from '../shaders/fill_vert.glsl';
interface IPointLayerStyleOptions { interface IPointLayerStyleOptions {
opacity: number; opacity: number;
strokeWidth: number; strokeWidth: number;
strokeColor: string; stroke: string;
} }
export default class FillModel extends BaseModel { export default class FillModel extends BaseModel {
public getUninforms(): IModelUniform { public getUninforms(): IModelUniform {
const { const {
opacity = 1, opacity = 1,
strokeColor = 'rgb(0,0,0,0)', stroke = 'rgb(0,0,0,0)',
strokeWidth = 1, strokeWidth = 1,
} = this.layer.getLayerConfig() as IPointLayerStyleOptions; } = this.layer.getLayerConfig() as IPointLayerStyleOptions;
return { return {
u_opacity: opacity, u_opacity: opacity,
u_stroke_width: strokeWidth, u_stroke_width: strokeWidth,
u_stroke_color: rgb2arr(strokeColor), u_stroke_color: rgb2arr(stroke),
}; };
} }

View File

@ -16,7 +16,7 @@ import normalVert from '../shaders/normal_vert.glsl';
interface IPointLayerStyleOptions { interface IPointLayerStyleOptions {
opacity: number; opacity: number;
strokeWidth: number; strokeWidth: number;
strokeColor: string; stroke: string;
} }
export function PointTriangulation(feature: IEncodeFeature) { export function PointTriangulation(feature: IEncodeFeature) {
const coordinates = feature.coordinates as number[]; const coordinates = feature.coordinates as number[];
@ -36,13 +36,13 @@ export default class NormalModel extends BaseModel {
public getUninforms(): IModelUniform { public getUninforms(): IModelUniform {
const { const {
opacity = 1, opacity = 1,
strokeColor = 'rgb(0,0,0,0)', stroke = 'rgb(0,0,0,0)',
strokeWidth = 1, strokeWidth = 1,
} = this.layer.getLayerConfig() as IPointLayerStyleOptions; } = this.layer.getLayerConfig() as IPointLayerStyleOptions;
return { return {
u_opacity: opacity, u_opacity: opacity,
u_stroke_width: strokeWidth, u_stroke_width: strokeWidth,
u_stroke_color: rgb2arr(strokeColor), u_stroke_color: rgb2arr(stroke),
}; };
} }
public buildModels(): IModel[] { public buildModels(): IModel[] {

View File

@ -34,7 +34,7 @@ void main() {
float antialiasblur = 1.0 / (a_Size + u_stroke_width); float antialiasblur = 1.0 / (a_Size + u_stroke_width);
// construct point coords // construct point coords
v_data = vec4(extrude, antialiasblur, ); v_data = vec4(extrude, antialiasblur,shape_type);
setPickingColor(a_PickingColor); setPickingColor(a_PickingColor);
} }

View File

@ -48,7 +48,7 @@ export default class DataUpdate extends React.Component {
.active(false) .active(false)
.color('#2F54EB') .color('#2F54EB')
.style({ .style({
strokeColor: '#fff', stroke: '#fff',
strokeWidth: 2, strokeWidth: 2,
opacity: 1, opacity: 1,
}); });