Skip to content

Commit 21b73fe

Browse files
committed
【API】【leaflet】
1.高性能图层GraphicLayer新增要素设置和清除接口 2.高性能图层要素类Graphic支持设置要素属性 3.fix部分接口大小写不规范问题
1 parent 0ed030c commit 21b73fe

11 files changed

Lines changed: 159 additions & 23 deletions

‎CHANGELOG.md‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,26 @@
4848

4949
- `SuperMap.ThemeStyle` 参数 `strokeDashstyle` 类型 `dashot` 更改为 `dashdot`
5050

51+
- 高性能图层 `L.supermap.GraphicLayer` 新增接口:
52+
53+
- `setGraphics`: 设置点要素
54+
55+
- `addGraphics`: 追加点要素
56+
57+
- `removeGraphics`: 移除所有要素
58+
59+
60+
- 高性能图层要素类 `L.supermap.Graphic` 更改接口和参数:
61+
62+
- options参数 `latlng` 更改为 `latLng`
63+
64+
- options新增参数 `attributes`,支持设置要素属性
65+
66+
- 增加 `setAttributes`和`getAttributes`接口
67+
68+
- `setLatlng` 接口更改为 `setLatLng`
69+
70+
5171
### for OpenLayers
5272

5373
- `ol.supermap.WebMap` 新增支持加载 "MapEditor" , "DataInsights" , "ISERVER" 格式 json 数据

‎dist/iclient9-leaflet.css‎

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-leaflet.js‎

Lines changed: 67 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32770,18 +32770,19 @@ var Graphic = exports.Graphic = _leaflet2["default"].Class.extend({
3277032770
initialize: function initialize(options) {
3277132771
options = options || {};
3277232772

32773-
var latlng = options.latlng || options._latlng;
32774-
this._latlng = _leaflet2["default"].latLng(latlng.lat, latlng.lng);
32773+
var latLng = options.latLng || options._latLng;
32774+
this._latLng = _leaflet2["default"].latLng(latLng.lat, latLng.lng);
3277532775
this._style = options.style || options._canvas;
32776+
this._attributes = options.attributes;
3277632777
},
3277732778

3277832779
/**
32779-
* @function L.supermap.graphic.prototype.setLatlng
32780+
* @function L.supermap.graphic.prototype.setLatLng
3278032781
* @description 设置经纬度
32781-
* @param latlng - {L.latlng} 经纬度参数
32782+
* @param latLng - {L.latLng} 经纬度参数
3278232783
*/
32783-
setLatlng: function setLatlng(latlng) {
32784-
this._latlng = latlng;
32784+
setLatLng: function setLatLng(latLng) {
32785+
this._latLng = latLng;
3278532786
},
3278632787

3278732788
/**
@@ -32794,23 +32795,44 @@ var Graphic = exports.Graphic = _leaflet2["default"].Class.extend({
3279432795
this._style = canvas;
3279532796
},
3279632797

32798+
/**
32799+
* @function L.supermap.graphic.prototype.setAttributes
32800+
* @description 设置要素属性
32801+
* @param attributes - {Object} 属性对象
32802+
*/
32803+
setAttributes: function setAttributes(attributes) {
32804+
this._attributes = attributes;
32805+
},
32806+
3279732807
/**
3279832808
* @function L.supermap.graphic.prototype.getLatLng
3279932809
* @description 获取经纬度
32810+
* @return {L.latLng} 经纬度
3280032811
*/
32812+
3280132813
getLatLng: function getLatLng() {
32802-
return this._latlng;
32814+
return this._latLng;
3280332815
},
3280432816

3280532817
/**
3280632818
* @deprecated
3280732819
* @function L.supermap.graphic.prototype.getCanvas
3280832820
* @description 获取画布,已弃用该设置,请使用getStyle接口
32821+
* @return {HTMLCanvasElement} 画布
3280932822
*/
3281032823
getCanvas: function getCanvas() {
3281132824
return this._style;
3281232825
},
3281332826

32827+
/**
32828+
* @function L.supermap.graphic.prototype.getAttributes
32829+
* @description 获取要素属性
32830+
* @return {Object} 要素属性
32831+
*/
32832+
getAttributes: function getAttributes() {
32833+
return this._attributes;
32834+
},
32835+
3281432836
/**
3281532837
* @function L.supermap.graphic.prototype.setStyle
3281632838
* @description 设置样式
@@ -32823,6 +32845,7 @@ var Graphic = exports.Graphic = _leaflet2["default"].Class.extend({
3282332845
/**
3282432846
* @function L.supermap.graphic.prototype.getStyle
3282532847
* @description 获取样式
32848+
* @return {L.supermap.CircleStyle|L.supermap.ImageStyle|L.supermap.CloverStyle} 样式
3282632849
*/
3282732850
getStyle: function getStyle() {
3282832851
return this._style;
@@ -65444,6 +65467,42 @@ var GraphicLayer = exports.GraphicLayer = _leaflet2["default"].Path.extend({
6544465467
_leaflet2["default"].Path.prototype.onAdd.call(this);
6544565468
},
6544665469

65470+
/**
65471+
* @function L.supermap.graphicLayer.prototype.setGraphics
65472+
* @description 设置绘制的点要素数据,会覆盖之前的所有要素
65473+
* @param {Array<L.supermap.Graphic>} graphics - 点要素对象数组
65474+
*/
65475+
setGraphics: function setGraphics(graphics) {
65476+
this.graphics = [];
65477+
var sGraphics = !_leaflet2["default"].Util.isArray(graphics) ? [graphics] : graphics.concat([]);
65478+
this.graphics = [].concat(sGraphics);
65479+
this._update();
65480+
},
65481+
65482+
65483+
/**
65484+
* @function L.supermap.graphicLayer.prototype.addGraphics
65485+
* @description 追加点要素,不会覆盖之前的要素
65486+
* @param {Array<L.supermap.Graphic>} graphics - 点要素对象数组
65487+
*/
65488+
addGraphics: function addGraphics(graphics) {
65489+
this.graphics = this.graphics || [];
65490+
var sGraphics = !_leaflet2["default"].Util.isArray(graphics) ? [graphics] : graphics.concat([]);
65491+
this.graphics = this.graphics.concat(sGraphics);
65492+
this._update();
65493+
},
65494+
65495+
65496+
/**
65497+
* @function L.supermap.graphicLayer.prototype.removeGraphics
65498+
* @description 移除所有要素
65499+
*/
65500+
removeGraphics: function removeGraphics() {
65501+
this.graphics = [];
65502+
this._update();
65503+
},
65504+
65505+
6544765506
_update: function _update() {
6544865507
if (this._map) {
6544965508
this._updatePath();
@@ -71076,7 +71135,7 @@ module.exports = function (proj4) {
7107671135
/* 377 */
7107771136
/***/ (function(module) {
7107871137

71079-
module.exports = {"_args":[["proj4@2.3.15","E:\\git\\iClient9"]],"_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":"http://registry.npm.taobao.org/proj4/download/proj4-2.3.15.tgz","_spec":"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"},"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"};
71138+
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":"F:\\dev\\iClient","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"};
7108071139

7108171140
/***/ }),
7108271141
/* 378 */

‎dist/iclient9-leaflet.min.css‎

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-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/include-leaflet.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
inputScript("http://cdn.bootcss.com/elasticsearch/13.0.1/elasticsearch.min.js");
6262
}
6363
if (!inArray(excludes, 'iclient9-leaflet')) {
64-
inputScript("../../dist/iclient9-leaflet.js");
64+
inputScript("../../dist/iclient9-leaflet.min.js");
6565
}
6666
if (inArray(includes, 'iclient9-leaflet-css')) {
6767
inputCSS("../../dist/iclient9-leaflet.min.css");

‎examples/leaflet/12_graphicLayer.html‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@
4747
continue;
4848
}
4949
graphics[i] = L.supermap.graphic({
50-
latlng: L.latLng(coordinates[1], coordinates[0]),
51-
50+
latLng: L.latLng(coordinates[1], coordinates[0]),
5251
style: circleStyles[Math.floor(Math.random() * colorCount)].getStyle()
5352
});
5453
}
@@ -63,6 +62,7 @@
6362
}).addTo(map);
6463
})
6564
}
65+
6666
//生成随机颜色
6767
function getRandomColors(count) {
6868
return randomColor({

‎examples/leaflet/12_graphicLayerClover.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
for (var i = 0; i < count; ++i) {
5555
var coordinates = [2 * e * Math.random() - e, 2 * e * Math.random() - e];
5656
graphics[i] = L.supermap.graphic({
57-
latlng: L.latLng(coordinates[0], coordinates[1]),
57+
latLng: L.latLng(coordinates[0], coordinates[1]),
5858
style: clovers[Math.floor(Math.random() * randCount)].getStyle()
5959
});
6060
var pointVector = graphics[i];

‎examples/leaflet/12_graphicLayerImage.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
continue;
4343
}
4444
graphics[i] = L.supermap.graphic({
45-
latlng: L.latLng(coordinates[1], coordinates[0]),
45+
latLng: L.latLng(coordinates[1], coordinates[0]),
4646
style: imageStyles[0].getStyle()
4747
});
4848
}

‎src/leaflet/overlay/GraphicLayer.js‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,39 @@ export var GraphicLayer = L.Path.extend({
4646
L.Path.prototype.onAdd.call(this);
4747
},
4848

49+
/**
50+
* @function L.supermap.graphicLayer.prototype.setGraphics
51+
* @description 设置绘制的点要素数据,会覆盖之前的所有要素
52+
* @param {Array<L.supermap.Graphic>} graphics - 点要素对象数组
53+
*/
54+
setGraphics(graphics) {
55+
this.graphics = [];
56+
let sGraphics = !L.Util.isArray(graphics) ? [graphics] : graphics.concat([]);
57+
this.graphics = [].concat(sGraphics);
58+
this._update();
59+
},
60+
61+
/**
62+
* @function L.supermap.graphicLayer.prototype.addGraphics
63+
* @description 追加点要素,不会覆盖之前的要素
64+
* @param {Array<L.supermap.Graphic>} graphics - 点要素对象数组
65+
*/
66+
addGraphics(graphics) {
67+
this.graphics = this.graphics || [];
68+
let sGraphics = !L.Util.isArray(graphics) ? [graphics] : graphics.concat([]);
69+
this.graphics = this.graphics.concat(sGraphics);
70+
this._update();
71+
},
72+
73+
/**
74+
* @function L.supermap.graphicLayer.prototype.removeGraphics
75+
* @description 移除所有要素
76+
*/
77+
removeGraphics() {
78+
this.graphics = [];
79+
this._update();
80+
},
81+
4982
_update: function () {
5083
if (this._map) {
5184
this._updatePath();

0 commit comments

Comments
 (0)