Skip to content

Commit 1ec6397

Browse files
committed
[feature] 新增符号类 Polygon、ImagePolygon
review by zhaoq
1 parent 87d9c14 commit 1ec6397

File tree

3 files changed

+150
-0
lines changed

3 files changed

+150
-0
lines changed

src/common/commontypes/symbol/DefaultValue.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,9 @@ export const POINT_DEFAULT_VALUE = {
1515
export const IMAGE_POINT_DEFAULT_VALUE = {
1616
rotate: COMMON_DEFAULT_VALUE.rotate,
1717
translate: COMMON_DEFAULT_VALUE.translate
18+
}
19+
20+
export const POLYGON_DEFAULT_VALUE = {
21+
color: COMMON_DEFAULT_VALUE.color,
22+
opacity: COMMON_DEFAULT_VALUE.opacity
1823
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/* Copyright© 2000 - 2022 SuperMap Software Co.Ltd. All rights reserved.
2+
* This program are made available under the terms of the Apache License, Version 2.0
3+
* which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/
4+
import { Polygon } from './Polygon';
5+
import {Util} from '../Util';
6+
7+
/**
8+
* @class ImagePolygonSymbol
9+
* @aliasclass Symbol.ImagePolygon
10+
* @classdesc 图片面符号类。
11+
* @category BaseTypes Symbol
12+
* @extends {Polygon}
13+
* @param {string} image - 符号图片。
14+
* @param {string} [type = 'ImagePolygon'] - 符号类型。
15+
* @example
16+
* const symbol = new ImagePolygonSymbol({
17+
* image: "xx.png"
18+
* });
19+
* @usage
20+
*/
21+
export class ImagePolygon extends Polygon {
22+
23+
constructor(option) {
24+
super(option);
25+
const { image, color } = option ?? {};
26+
27+
/**
28+
* @member {string} ImagePolygonSymbol.prototype.image
29+
* @description 符号图片, 必选参数。
30+
*/
31+
this.image = image;
32+
33+
/**
34+
* @member {string} PolygonSymbol.prototype.color
35+
* @description 符号颜色,如果为undefined,显示图片自身颜色。
36+
*/
37+
this.color = color;
38+
39+
/**
40+
* @member {string} ImagePolygonSymbol.prototype.type
41+
* @description 面符号的类型。
42+
*/
43+
this.type = "ImagePolygon";
44+
this.CLASS_NAME = "SuperMap.Symbol.ImagePolygon";
45+
}
46+
47+
/**
48+
* @function ImagePolygonSymbol.prototype.clone
49+
* @description 克隆符号。
50+
* @returns {ImagePolygonSymbol} 克隆后的符号。
51+
*/
52+
clone(obj) {
53+
if (obj == null) {
54+
obj = new ImagePolygon({
55+
image: this.image
56+
});
57+
}
58+
59+
// catch any randomly tagged-on properties
60+
Util.applyDefaults(obj, this);
61+
62+
return obj;
63+
}
64+
65+
/**
66+
* @function ImagePolygonSymbol.prototype.destroy
67+
* @description 释放符号资源。
68+
*/
69+
destroy() {
70+
this.image = null;
71+
super.destroy();
72+
}
73+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/* Copyright© 2000 - 2022 SuperMap Software Co.Ltd. All rights reserved.
2+
* This program are made available under the terms of the Apache License, Version 2.0
3+
* which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/
4+
import {Symbol} from '../Symbol';
5+
import {Util} from '../Util';
6+
import { POLYGON_DEFAULT_VALUE } from './DefaultValue';
7+
8+
/**
9+
* @class PolygonSymbol
10+
* @aliasclass Symbol.Polygon
11+
* @classdesc 面符号类。
12+
* @category BaseTypes Symbol
13+
* @extends {Symbol}
14+
* @param {string} [color = "#000"] - 符号颜色。
15+
* @param {number} [opacity = 1] - 符号透明度。
16+
* @param {string} [type = 'Polygon'] - 符号类型。
17+
* @example
18+
* const symbol = new PolygonSymbol();
19+
* @usage
20+
*/
21+
export class Polygon extends Symbol {
22+
23+
constructor(option) {
24+
super();
25+
const { color, opacity } = option ?? {};
26+
27+
/**
28+
* @member {string} PolygonSymbol.prototype.color
29+
* @description 面符号的颜色,默认值:"#000"。
30+
*/
31+
this.color = color ?? POLYGON_DEFAULT_VALUE.color;
32+
33+
/**
34+
* @member {number} PolygonSymbol.prototype.opacity
35+
* @description 面符号的透明度,默认值:1
36+
*/
37+
this.opacity = opacity ?? POLYGON_DEFAULT_VALUE.opacity;
38+
39+
/**
40+
* @member {string} PolygonSymbol.prototype.type
41+
* @description 面符号的类型。
42+
*/
43+
this.type = "Polygon";
44+
this.CLASS_NAME = "SuperMap.Symbol.Polygon";
45+
}
46+
47+
/**
48+
* @function PolygonSymbol.prototype.clone
49+
* @description 克隆面符号。
50+
* @returns {PolygonSymbol} 克隆后的面符号。
51+
*/
52+
clone(obj) {
53+
if (obj == null) {
54+
obj = new Polygon();
55+
}
56+
57+
// catch any randomly tagged-on properties
58+
Util.applyDefaults(obj, this);
59+
60+
return obj;
61+
}
62+
63+
/**
64+
* @function PolygonSymbol.prototype.destroy
65+
* @description 释放面符号的资源。
66+
*/
67+
destroy() {
68+
this.color = null;
69+
this.opacity = null;
70+
super.destroy();
71+
}
72+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy