Skip to content

Commit 7e146fc

Browse files
committed
Merge branch 'dev' of github.com:MapGIS/WebClient-JavaScript into dev
2 parents ba78c44 + e9187ff commit 7e146fc

File tree

17 files changed

+364
-400
lines changed

17 files changed

+364
-400
lines changed

src/cesiumjs/overlay/PopupLayer.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,18 +92,15 @@ export default class PopupLayer {
9292
let parents = document.getElementsByClassName('cesium-widget');
9393
parent = parents.length > 0 ? parents[0] : map.container;
9494
this.parent = parent;
95-
console.log('popup parent', parent);
9695

9796
// this.initDevicePixelRatio();
9897
this.showClose = options.showClose === undefined ? true : options.showClose;
9998
this.popup = this._createPopup();
100-
console.log('popup 3');
10199

102100
this.moveStart = this.eventMoveStart.bind(this);
103101
this.moveEnd = this.eventMoveEnd.bind(this);
104102
this.movement = this.movement.bind(this);
105103
this.update = this.update.bind(this);
106-
console.log('popup 4');
107104

108105
this.bindEvent();
109106

Lines changed: 62 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import mapboxgl from "@mapgis/mapbox-gl";
2-
import { Zondy } from "../../service/common/Base";
3-
import { copyAttributesWithClip } from "../../service/common/Util";
4-
import { GeoFeatureThemeLayer } from "./GeoFeatureThemeLayer";
5-
import { ThemeVector } from "../../common/overlay/ThemeVector";
6-
import { ShapeFactory } from "../../common/overlay/feature/ShapeFactory";
1+
import mapboxgl from '@mapgis/mapbox-gl';
2+
import { Zondy } from '../../service/common/Base';
3+
import { copyAttributesWithClip } from '../../service/common/Util';
4+
import { GeoFeatureThemeLayer } from './GeoFeatureThemeLayer';
5+
import { ThemeVector } from '../../common/overlay/ThemeVector';
6+
import { ShapeFactory } from '../../common/overlay/feature/ShapeFactory';
77

88
/**
99
* @class Zondy.Map.randomThemeLayer
@@ -22,74 +22,70 @@ import { ShapeFactory } from "../../common/overlay/feature/ShapeFactory";
2222
* @extends {Zondy.Map.GeoFeatureThemeLayer}
2323
*/
2424
class RandomThemeLayer extends GeoFeatureThemeLayer {
25-
constructor(name, options) {
26-
super(name, options);
27-
this.style = options.style;
28-
this.isHoverAble = options.isHoverAble;
29-
this.highlightStyle = options.highlightStyle;
30-
this.themeField = options.themeField;
31-
this.styleGroups = options.styleGroups;
32-
}
25+
constructor(name, options) {
26+
super(name, options);
27+
this.style = options.style;
28+
this.isHoverAble = options.isHoverAble;
29+
this.highlightStyle = options.highlightStyle;
30+
this.themeField = options.themeField;
31+
this.styleGroups = options.styleGroups;
32+
}
3333

34-
/**
35-
* @function Zondy.Map.randomThemeLayer.prototype.getColor
36-
* @description 获取随机颜色。
37-
*/
38-
getColor() {
39-
var colorValue = "0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f";
40-
var colorArray = colorValue.split(",");
41-
var color = "#"; //定义一个存放十六进制颜色值的字符串变量,先将#存放进去
42-
for (var i = 0; i < 6; i++) {
43-
color += colorArray[Math.floor(Math.random() * 16)];
34+
/**
35+
* @function Zondy.Map.randomThemeLayer.prototype.getColor
36+
* @description 获取随机颜色。
37+
*/
38+
getColor() {
39+
var colorValue = '0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f';
40+
var colorArray = colorValue.split(',');
41+
var color = '#'; //定义一个存放十六进制颜色值的字符串变量,先将#存放进去
42+
for (var i = 0; i < 6; i++) {
43+
color += colorArray[Math.floor(Math.random() * 16)];
44+
}
45+
return color;
4446
}
45-
return color;
46-
}
4747

48-
/**
49-
* @function Zondy.Map.randomThemeLayer.prototype.createThematicFeature
50-
* @description 创建专题图要素。
51-
* @param {Object} feature - 要创建的专题图形要素。
52-
*/
53-
createThematicFeature(feature) {
54-
//赋 style
55-
var style = this.getStyleByData(feature);
56-
//创建专题要素时的可选参数
57-
var options = {};
58-
options.nodesClipPixel = this.nodesClipPixel;
59-
options.isHoverAble = this.isHoverAble;
60-
options.isMultiHover = this.isMultiHover;
61-
options.isClickAble = this.isClickAble;
62-
options.highlightStyle = ShapeFactory.transformStyle(this.highlightStyle);
48+
/**
49+
* @function Zondy.Map.randomThemeLayer.prototype.createThematicFeature
50+
* @description 创建专题图要素。
51+
* @param {Object} feature - 要创建的专题图形要素。
52+
*/
53+
createThematicFeature(feature) {
54+
//赋 style
55+
var style = this.getStyleByData(feature);
56+
//创建专题要素时的可选参数
57+
var options = {};
58+
options.nodesClipPixel = this.nodesClipPixel;
59+
options.isHoverAble = this.isHoverAble;
60+
options.isMultiHover = this.isMultiHover;
61+
options.isClickAble = this.isClickAble;
62+
options.highlightStyle = ShapeFactory.transformStyle(this.highlightStyle);
6363

64-
//将数据转为专题要素(Vector)
65-
var thematicFeature = new ThemeVector(
66-
feature,
67-
this,
68-
ShapeFactory.transformStyle(style),
69-
options
70-
);
64+
//将数据转为专题要素(Vector)
65+
var thematicFeature = new ThemeVector(feature, this, ShapeFactory.transformStyle(style), options);
7166

72-
//直接添加图形到渲染器
73-
for (var m = 0; m < thematicFeature.shapes.length; m++) {
74-
this.renderer.addShape(thematicFeature.shapes[m]);
67+
//直接添加图形到渲染器
68+
for (var m = 0; m < thematicFeature.shapes.length; m++) {
69+
this.renderer.addShape(thematicFeature.shapes[m]);
70+
}
71+
return thematicFeature;
7572
}
76-
return thematicFeature;
77-
}
7873

79-
/**
80-
* @private
81-
* @function Zondy.Map.randomThemeLayer.prototype.getStyleByData
82-
* @description 获取 style。
83-
*/
84-
getStyleByData() {
85-
var me = this;
86-
var style = copyAttributesWithClip({}, me.style);
87-
style.fillColor = me.getColor();
88-
return style;
89-
}
74+
/**
75+
* @private
76+
* @function Zondy.Map.randomThemeLayer.prototype.getStyleByData
77+
* @description 获取 style。
78+
*/
79+
getStyleByData() {
80+
var me = this;
81+
var style = copyAttributesWithClip({}, me.style);
82+
style.fillColor = me.getColor();
83+
return style;
84+
}
9085
}
9186

92-
export var randomThemeLayer = function(name, options) {
93-
return new RandomThemeLayer(name, options);
87+
export { RandomThemeLayer };
88+
export var randomThemeLayer = function (name, options) {
89+
return new RandomThemeLayer(name, options);
9490
};
9591
Zondy.Map.randomThemeLayer = randomThemeLayer;

src/mapboxgl/theme/RangeTheme3DLayer.js

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Zondy } from '../../service/common/Base';
2-
import {Theme3DLayer} from './Theme3DLayer';
3-
import {extend} from '../../service/common/Util';
2+
import { Theme3DLayer } from './Theme3DLayer';
3+
import { extend } from '../../service/common/Util';
44

55
/**
66
* @class RangeTheme3DLayer
@@ -27,7 +27,6 @@ import {extend} from '../../service/common/Util';
2727
* });
2828
*/
2929
class RangeTheme3DLayer extends Theme3DLayer {
30-
3130
constructor(id, layerOptions) {
3231
super(id, layerOptions);
3332
/**
@@ -67,33 +66,33 @@ class RangeTheme3DLayer extends Theme3DLayer {
6766
var reg = /^[0-9]+.?[0-9]*$/;
6867
var options = {
6968
'fill-extrusion-color': {
70-
'stops': this.colorStops,
71-
'property': this.themeField || this.heightField,
72-
'type': 'interval',
73-
'base': reg.test(this.base) ? this.base : 1
69+
stops: this.colorStops,
70+
property: this.themeField || this.heightField,
71+
type: 'interval',
72+
base: reg.test(this.base) ? this.base : 1
7473
},
7574
'fill-extrusion-opacity': opacity
7675
};
7776
if (this.heightStops) {
7877
options['fill-extrusion-height'] = {
79-
'stops': this.heightStops,
80-
'property': this.heightField || 'height',
81-
'base': reg.test(this.base) ? this.base : 1
82-
}
78+
stops: this.heightStops,
79+
property: this.heightField || 'height',
80+
base: reg.test(this.base) ? this.base : 1
81+
};
8382
} else if (this.height) {
8483
options['fill-extrusion-height'] = this.height;
8584
} else {
8685
options['fill-extrusion-height'] = {
87-
'property': this.heightField || 'height',
88-
'type': 'identity'
89-
}
86+
property: this.heightField || 'height',
87+
type: 'identity'
88+
};
9089
}
9190

9291
if (this.baseHeightField) {
9392
options['fill-extrusion-base'] = {
94-
'property': this.baseHeightField,
95-
'type': 'identity'
96-
}
93+
property: this.baseHeightField,
94+
type: 'identity'
95+
};
9796
}
9897
return options;
9998
}
@@ -104,55 +103,54 @@ class RangeTheme3DLayer extends Theme3DLayer {
104103
* @returns {Object} mapbox gl样式对象
105104
*/
106105
getHighlightStyleOptions() {
107-
var color = (this.highlight && this.highlight.color != null) ? this.highlight.color : '#ADA91E';
106+
var color = this.highlight && this.highlight.color != null ? this.highlight.color : '#ADA91E';
108107
return {
109108
'fill-extrusion-color': color,
110109
'fill-extrusion-height': {
111-
"stops": this.heightStops,
112-
"property": this.heightField
110+
stops: this.heightStops,
111+
property: this.heightField
113112
},
114-
'fill-extrusion-opacity': this.highlight && this.highlight.opacity || 0.6
115-
}
113+
'fill-extrusion-opacity': (this.highlight && this.highlight.opacity) || 0.6
114+
};
116115
}
117116

118117
_createLegendElement() {
119-
var len = this.colorStops && this.colorStops.length || 0;
118+
var len = (this.colorStops && this.colorStops.length) || 0;
120119
//颜色分段对应标识
121-
var legendListElement = "<ul>";
120+
var legendListElement = '<ul>';
122121
var i;
123122
for (i = 0; i < len; i++) {
124123
var value = this.colorStops[i][0];
125124
var text = this._getWrapperText(value);
126125
if (i === len - 1) {
127-
text = "> " + text;
126+
text = '> ' + text;
128127
} else {
129128
var next = this._getWrapperText(this.colorStops[i + 1][0]);
130-
text = text + "-" + next;
129+
text = text + '-' + next;
131130
}
132131

133132
var color = this.colorStops[i][1];
134133

135-
legendListElement += "<li><span style='background-color:" + color + ";'></span><span>" + text + "</span></li>";
134+
legendListElement += "<li><span style='background-color:" + color + ";'></span><span>" + text + '</span></li>';
136135
}
137-
legendListElement += "</ul>";
136+
legendListElement += '</ul>';
138137
return legendListElement;
139138
}
140139

141140
_getWrapperText(number) {
142-
var value = number * ((this.legendRatio == null) ? 1 : parseFloat(this.legendRatio));
141+
var value = number * (this.legendRatio == null ? 1 : parseFloat(this.legendRatio));
143142

144143
//单个颜色值宽度为60px,最大只能完全显示1000000,否则就超出宽度,则显示以为k计数单位的值
145144
var num = parseFloat(value);
146145
if (num % 1000000 <= 1000000) {
147146
return num.toString();
148147
}
149-
return parseInt(num / 1000) + 'k'
148+
return parseInt(num / 1000) + 'k';
150149
}
151-
152-
};
153-
export {RangeTheme3DLayer};
150+
}
151+
export { RangeTheme3DLayer };
154152
export var rangeTheme3DLayer = function (id, layerOptions) {
155153
return new RangeTheme3DLayer(id, layerOptions);
156154
};
157155

158-
Zondy.Map.rangeTheme3DLayer = rangeTheme3DLayer;
156+
Zondy.Map.rangeTheme3DLayer = rangeTheme3DLayer;

0 commit comments

Comments
 (0)