Skip to content

Commit d66e5dd

Browse files
committed
修改openlayers中theme图层map引用问题 & 增加部分UT review by zhurc
1 parent 17521e7 commit d66e5dd

File tree

16 files changed

+1546
-23
lines changed

16 files changed

+1546
-23
lines changed

dist/iclient9-leaflet.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24683,8 +24683,10 @@ var JSONFormat = function (_Format) {
2468324683
/**
2468424684
* @function SuperMap.Format.JSON.prototype.write
2468524685
* @description 序列化一个对象到一个符合JSON格式的字符串。
24686-
* @param value - {string} 需要被序列化的对象,数组,字符串,数字,布尔值。
24686+
* @param value - {object}|{string}|<Array>|{number}|{boolean} 需要被序列化的对象,数组,字符串,数字,布尔值。
24687+
* @param pretty -{boolean}
2468724688
* @return {string} 符合JSON格式的字符串。
24689+
*
2468824690
*/
2468924691

2469024692
}, {
@@ -62416,7 +62418,7 @@ eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a
6241662418
/* 382 */
6241762419
/***/ (function(module, exports) {
6241862420

62419-
module.exports = {"_args":[[{"raw":"proj4@2.3.15","scope":null,"escapedName":"proj4","name":"proj4","rawSpec":"2.3.15","spec":"2.3.15","type":"version"},"E:\\git\\iClient9"]],"_from":"proj4@2.3.15","_id":"proj4@2.3.15","_inCache":true,"_location":"/proj4","_nodeVersion":"6.1.0","_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/proj4-2.3.15.tgz_1471808262546_0.6752060337457806"},"_npmUser":{"name":"ahocevar","email":"andreas.hocevar@gmail.com"},"_npmVersion":"3.8.6","_phantomChildren":{},"_requested":{"raw":"proj4@2.3.15","scope":null,"escapedName":"proj4","name":"proj4","rawSpec":"2.3.15","spec":"2.3.15","type":"version"},"_requiredBy":["/"],"_resolved":"https://registry.npmjs.org/proj4/-/proj4-2.3.15.tgz","_shasum":"5ad06e8bca30be0ffa389a49e4565f51f06d089e","_shrinkwrap":null,"_spec":"proj4@2.3.15","_where":"E:\\git\\iClient9","author":"","bugs":{"url":"https://github.com/proj4js/proj4js/issues"},"contributors":[{"name":"Mike Adair","email":"madair@dmsolutions.ca"},{"name":"Richard Greenwood","email":"rich@greenwoodmap.com"},{"name":"Calvin Metcalf","email":"calvin.metcalf@gmail.com"},{"name":"Richard Marsden","url":"http://www.winwaed.com"},{"name":"T. Mittan"},{"name":"D. Steinwand"},{"name":"S. Nelson"}],"dependencies":{"mgrs":"~0.0.2"},"description":"Proj4js is a JavaScript library to transform point coordinates from one coordinate system to another, including datum transformations.","devDependencies":{"browserify":"~12.0.1","chai":"~1.8.1","curl":"git://github.com/cujojs/curl.git","grunt":"~0.4.2","grunt-browserify":"~4.0.1","grunt-cli":"~0.1.13","grunt-contrib-connect":"~0.6.0","grunt-contrib-jshint":"~0.8.0","grunt-contrib-uglify":"~0.11.1","grunt-mocha-phantomjs":"~0.4.0","istanbul":"~0.2.4","mocha":"~1.17.1","tin":"~0.4.0"},"directories":{"test":"test","doc":"docs"},"dist":{"shasum":"5ad06e8bca30be0ffa389a49e4565f51f06d089e","tarball":"https://registry.npmjs.org/proj4/-/proj4-2.3.15.tgz"},"gitHead":"9fa5249c1f4183d5ddee3c4793dfd7b9f29f1886","homepage":"https://github.com/proj4js/proj4js#readme","jam":{"main":"dist/proj4.js","include":["dist/proj4.js","README.md","AUTHORS","LICENSE.md"]},"license":"MIT","main":"lib/index.js","maintainers":[{"name":"cwmma","email":"calvin.metcalf@gmail.com"},{"name":"ahocevar","email":"andreas.hocevar@gmail.com"}],"name":"proj4","optionalDependencies":{},"readme":"ERROR: No README data found!","repository":{"type":"git","url":"git://github.com/proj4js/proj4js.git"},"scripts":{"test":"./node_modules/istanbul/lib/cli.js test ./node_modules/mocha/bin/_mocha test/test.js"},"version":"2.3.15"}
62421+
module.exports = {"_from":"proj4@2.3.15","_id":"proj4@2.3.15","_inBundle":false,"_integrity":"sha1-WtBui8owvg/6OJpJ5FZfUfBtCJ4=","_location":"/proj4","_phantomChildren":{},"_requested":{"type":"version","registry":true,"raw":"proj4@2.3.15","name":"proj4","escapedName":"proj4","rawSpec":"2.3.15","saveSpec":null,"fetchSpec":"2.3.15"},"_requiredBy":["/"],"_resolved":"https://registry.npmjs.org/proj4/-/proj4-2.3.15.tgz","_shasum":"5ad06e8bca30be0ffa389a49e4565f51f06d089e","_spec":"proj4@2.3.15","_where":"G:\\iClient9","author":"","bugs":{"url":"https://github.com/proj4js/proj4js/issues"},"bundleDependencies":false,"contributors":[{"name":"Mike Adair","email":"madair@dmsolutions.ca"},{"name":"Richard Greenwood","email":"rich@greenwoodmap.com"},{"name":"Calvin Metcalf","email":"calvin.metcalf@gmail.com"},{"name":"Richard Marsden","url":"http://www.winwaed.com"},{"name":"T. Mittan"},{"name":"D. Steinwand"},{"name":"S. Nelson"}],"dependencies":{"mgrs":"~0.0.2"},"deprecated":false,"description":"Proj4js is a JavaScript library to transform point coordinates from one coordinate system to another, including datum transformations.","devDependencies":{"browserify":"~12.0.1","chai":"~1.8.1","curl":"git://github.com/cujojs/curl.git","grunt":"~0.4.2","grunt-browserify":"~4.0.1","grunt-cli":"~0.1.13","grunt-contrib-connect":"~0.6.0","grunt-contrib-jshint":"~0.8.0","grunt-contrib-uglify":"~0.11.1","grunt-mocha-phantomjs":"~0.4.0","istanbul":"~0.2.4","mocha":"~1.17.1","tin":"~0.4.0"},"directories":{"test":"test","doc":"docs"},"homepage":"https://github.com/proj4js/proj4js#readme","jam":{"main":"dist/proj4.js","include":["dist/proj4.js","README.md","AUTHORS","LICENSE.md"]},"license":"MIT","main":"lib/index.js","name":"proj4","repository":{"type":"git","url":"git://github.com/proj4js/proj4js.git"},"scripts":{"test":"./node_modules/istanbul/lib/cli.js test ./node_modules/mocha/bin/_mocha test/test.js"},"version":"2.3.15"}
6242062422

6242162423
/***/ }),
6242262424
/* 383 */

dist/iclient9-leaflet.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/iclient9-mapboxgl.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21584,8 +21584,10 @@ var JSONFormat = function (_Format) {
2158421584
/**
2158521585
* @function SuperMap.Format.JSON.prototype.write
2158621586
* @description 序列化一个对象到一个符合JSON格式的字符串。
21587-
* @param value - {string} 需要被序列化的对象,数组,字符串,数字,布尔值。
21587+
* @param value - {object}|{string}|<Array>|{number}|{boolean} 需要被序列化的对象,数组,字符串,数字,布尔值。
21588+
* @param pretty -{boolean}
2158821589
* @return {string} 符合JSON格式的字符串。
21590+
*
2158921591
*/
2159021592

2159121593
}, {

dist/iclient9-openlayers.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11943,7 +11943,8 @@ var Theme = function (_ol$source$ImageCanva) {
1194311943
}, {
1194411944
key: 'getLocalXY',
1194511945
value: function getLocalXY(coordinate) {
11946-
var pixelP;
11946+
var pixelP,
11947+
map = this.map;
1194711948
if (coordinate instanceof _SuperMap2.default.Geometry.Point || coordinate instanceof _SuperMap2.default.Geometry.GeoText) {
1194811949
pixelP = map.getPixelFromCoordinate([coordinate.x, coordinate.y]);
1194911950
}
@@ -19948,8 +19949,10 @@ var JSONFormat = function (_Format) {
1994819949
/**
1994919950
* @function SuperMap.Format.JSON.prototype.write
1995019951
* @description 序列化一个对象到一个符合JSON格式的字符串。
19951-
* @param value - {string} 需要被序列化的对象,数组,字符串,数字,布尔值。
19952+
* @param value - {object}|{string}|<Array>|{number}|{boolean} 需要被序列化的对象,数组,字符串,数字,布尔值。
19953+
* @param pretty -{boolean}
1995219954
* @return {string} 符合JSON格式的字符串。
19955+
*
1995319956
*/
1995419957

1995519958
}, {

dist/iclient9-openlayers.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/common/format/JSON.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,10 @@ export default class JSONFormat extends Format {
7575
/**
7676
* @function SuperMap.Format.JSON.prototype.write
7777
* @description 序列化一个对象到一个符合JSON格式的字符串。
78-
* @param value - {string} 需要被序列化的对象,数组,字符串,数字,布尔值。
78+
* @param value - {object}|{string}|<Array>|{number}|{boolean} 需要被序列化的对象,数组,字符串,数字,布尔值。
79+
* @param pretty -{boolean}
7980
* @return {string} 符合JSON格式的字符串。
81+
*
8082
*/
8183
write(value, pretty) {
8284
this.pretty = !!pretty;

src/openlayers/overlay/theme/theme.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ export default class Theme extends ol.source.ImageCanvas {
419419
* @param coordinate - {Object} 坐标位置。
420420
*/
421421
getLocalXY(coordinate) {
422-
var pixelP;
422+
var pixelP, map = this.map;
423423
if (coordinate instanceof SuperMap.Geometry.Point || coordinate instanceof SuperMap.Geometry.GeoText) {
424424
pixelP = map.getPixelFromCoordinate([coordinate.x, coordinate.y]);
425425
}

test/common/format/JSONSpec.js

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
require('../../../src/common/format/JSON');
2+
3+
describe('JSONSTest', function () {
4+
var originalTimeout;
5+
beforeEach(function () {
6+
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
7+
jasmine.DEFAULT_TIMEOUT_INTERVAL = 50000;
8+
});
9+
afterEach(function () {
10+
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
11+
});
12+
13+
var attributes = {
14+
"CITY": "北京市",
15+
"SMID": 1,
16+
"ADDRESS": ["海淀区", "天安门", "东城区"]
17+
};
18+
19+
var POINTSARRAY = {"POINTSARRAY": [1, 2, 3, 4]};
20+
var BOOLEANOBJ = {"ISJSON": false};
21+
var DATE = {"DATE": new Date()};
22+
var pretty = true;
23+
24+
it("read", function () {
25+
var attribute = JSON.stringify(attributes);
26+
var jsonFormat = new SuperMap.Format.JSON();
27+
var jsonObject = jsonFormat.read(attribute);
28+
expect(typeof (jsonObject)).toBe('object');
29+
expect(typeof (jsonObject.SMID)).toBe('number');
30+
expect(typeof (jsonObject.CITY)).toBe('string');
31+
expect((jsonObject.ADDRESS) instanceof Array).toBeTruthy();
32+
});
33+
34+
it("write_object", function () {
35+
var jsonFormat = new SuperMap.Format.JSON();
36+
var jsonString = jsonFormat.write(attributes, pretty);
37+
expect(typeof (jsonString)).toBe('string');
38+
});
39+
40+
it("write_array", function () {
41+
var jsonFormat = new SuperMap.Format.JSON();
42+
jsonString = jsonFormat.write(POINTSARRAY, pretty);
43+
expect(typeof (jsonString)).toBe('string');
44+
});
45+
46+
it("write_boolean", function () {
47+
var jsonFormat = new SuperMap.Format.JSON();
48+
jsonString = jsonFormat.write(BOOLEANOBJ, pretty);
49+
expect(typeof (jsonString)).toBe('string');
50+
});
51+
52+
it("write_date", function () {
53+
var jsonFormat = new SuperMap.Format.JSON();
54+
jsonString = jsonFormat.write(DATE, pretty);
55+
expect(typeof (jsonString)).toBe('string');
56+
});
57+
58+
it("write_number", function () {
59+
var jsonFormat = new SuperMap.Format.JSON();
60+
jsonString = jsonFormat.write(POINTSARRAY, pretty);
61+
expect(typeof (jsonString)).toBe('string');
62+
});
63+
64+
});
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
require('../../../src/leaflet/overlay/RangeThemeLayer');
2+
3+
var baseUrl = GlobeParameter.jingjinMapURL + "/maps/京津地区地图";
4+
describe('leaflet_testRangeThemeLayer', function () {
5+
var originalTimeout;
6+
var testDiv, map;
7+
beforeAll(function () {
8+
testDiv = window.document.createElement("div");
9+
testDiv.setAttribute("id", "map");
10+
testDiv.style.styleFloat = "left";
11+
testDiv.style.marginLeft = "8px";
12+
testDiv.style.marginTop = "50px";
13+
testDiv.style.width = "500px";
14+
testDiv.style.height = "500px";
15+
window.document.body.appendChild(testDiv);
16+
map = L.map("map", {
17+
crs: L.CRS.EPSG4326,
18+
center: [40, 117],
19+
maxZoom: 18,
20+
zoom: 7
21+
});
22+
L.supermap.tiledMapLayer(baseUrl).addTo(map);
23+
});
24+
beforeEach(function () {
25+
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
26+
jasmine.DEFAULT_TIMEOUT_INTERVAL = 50000;
27+
});
28+
afterEach(function () {
29+
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
30+
});
31+
afterAll(function () {
32+
window.document.body.removeChild(testDiv);
33+
map.remove();
34+
});
35+
36+
37+
it('getStyleByData', function () {
38+
var rangeThemeLayer = L.supermap.rangeThemeLayer("ThemeLayer", {
39+
// 开启 hover 高亮效果
40+
isHoverAble: true,
41+
opacity: 0.8
42+
});
43+
44+
rangeThemeLayer.style = new SuperMap.ThemeStyle({
45+
shadowBlur: 16,
46+
shadowColor: "#000000",
47+
fillColor: "#FFFFFF"
48+
});
49+
50+
// hover 高亮样式
51+
rangeThemeLayer.highlightStyle = new SuperMap.ThemeStyle({
52+
stroke: true,
53+
strokeWidth: 4,
54+
strokeColor: 'blue',
55+
fillColor: "#00EEEE",
56+
fillOpacity: 0.8
57+
});
58+
59+
// 用于单值专题图的属性字段名称
60+
rangeThemeLayer.themeField = "POP_DENSITY99";
61+
// 风格数组,设定值对应的样式
62+
rangeThemeLayer.styleGroups = [{
63+
start: 0,
64+
end: 0.02,
65+
style: {
66+
color: '#FDE2CA'
67+
}
68+
}, {
69+
start: 0.02,
70+
end: 0.04,
71+
style: {
72+
color: '#FACE9C'
73+
}
74+
}];
75+
76+
var feature = {
77+
attributes: {
78+
'CITY': "北京市",
79+
'NAME': "怀柔区",
80+
'POP_DENSITY99': 0.012517714,
81+
'SMAREA': 2.296619182358133E9,
82+
'SMGEOMETRYSIZE': 1928,
83+
'SMID': 1,
84+
'SMPERIMETER': 276046.9622576497,
85+
'SMSDRIE': 116.900505,
86+
'SMSDRIN': 41.040543,
87+
'SMSDRIS': 40.22844,
88+
'SMSDRIW': 116.18578,
89+
'SMUSERID': 0
90+
},
91+
layer: null,
92+
lonlat: null,
93+
state: null,
94+
style: null,
95+
geometry: {
96+
'bounds': null,
97+
components: {
98+
components: {
99+
components: {
100+
'id': "SuperMap.Geometry.Point_383",
101+
'x': 116.4548427772861,
102+
'y': 40.742015064668564,
103+
'type': "NONE"
104+
},
105+
id: "SuperMap.Geometry.LinearRing_463",
106+
107+
length: 1
108+
},
109+
id: "SuperMap.Geometry.Polygon_464",
110+
length: 1
111+
},
112+
id: "SuperMap.Geometry.MultiPolygon_465"
113+
},
114+
id: "SuperMap.Feature.Vector_466",
115+
};
116+
feature.data = feature.attributes;
117+
var result = rangeThemeLayer.getStyleByData(feature);
118+
119+
expect(result).not.toBeNull();
120+
expect(result.fill).toBeTruthy();
121+
expect(result.fontSize).toBe(12);
122+
expect(result.color).toBe("#FDE2CA");
123+
});
124+
});

0 commit comments

Comments
 (0)