Skip to content

Commit 76194c2

Browse files
author
caoxinke
committed
fix sonar;fix OpenLayers mapvLayer的动画不显示bug。
1 parent 48e3388 commit 76194c2

File tree

8 files changed

+187
-177
lines changed

8 files changed

+187
-177
lines changed

dist/iclient9-leaflet.js

Lines changed: 144 additions & 125 deletions
Large diffs are not rendered by default.

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-openlayers.js

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10822,15 +10822,6 @@ SuperMap.ElasticSearchService = SuperMap.Class({
1082210822
return this.client.updateByQuery(params, callback);
1082310823
},
1082410824

10825-
/**
10826-
* 通过查询API来更新文档。
10827-
* 参数设置参考 https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html#api-updatebyquery
10828-
* 更多信息参考 https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update-by-query.html
10829-
*/
10830-
updateByQuery: function (params, callback) {
10831-
return this.client.updateByQuery(params, callback);
10832-
},
10833-
1083410825
_update: function (data) {
1083510826
var me = this;
1083610827
if (!data) {
@@ -12185,30 +12176,34 @@ var MapvLayer = __webpack_require__(83);
1218512176
ol.source.Mapv = function (opt_options) {
1218612177
var options = opt_options ? opt_options : {};
1218712178
ol.source.ImageCanvas.call(this, {
12188-
attributions: options.attributions|| new ol.Attribution({
12189-
html: '© 2017 百度 MapV with <a href="http://iclient.supermapol.com/">SuperMap iClient</a>'}),
12179+
attributions: options.attributions || new ol.Attribution({
12180+
html: '© 2017 百度 MapV with <a href="http://iclient.supermapol.com/">SuperMap iClient</a>'
12181+
}),
1219012182
canvasFunction: this.canvasFunctionInternal_.bind(this),
1219112183
logo: options.logo,
1219212184
projection: options.projection,
1219312185
ratio: options.ratio,
1219412186
resolutions: options.resolutions,
1219512187
state: options.state
1219612188
});
12197-
this.layer = new MapvLayer(opt_options.map, opt_options.dataSet, opt_options.mapvOptions);
12189+
this.layer = new MapvLayer(opt_options.map, opt_options.dataSet, opt_options.mapvOptions, this);
12190+
this.layer.canvasLayer.draw();
1219812191
this.map = opt_options.map;
1219912192
};
1220012193
ol.inherits(ol.source.Mapv, ol.source.ImageCanvas);
1220112194

1220212195
ol.source.Mapv.prototype.canvasFunctionInternal_ = function (extent, resolution, pixelRatio, size, projection) {
1220312196
if (this.layer) {
12204-
var mapWidth = Math.round(ol.extent.getWidth(extent) / resolution);
12205-
var mapHeight = Math.round(ol.extent.getHeight(extent) / resolution);
12197+
if (!this.layer.isEnabledTime()) {
12198+
this.layer.canvasLayer.draw();
12199+
}
12200+
var mapWidth = size[0];
12201+
var mapHeight = size[1];
1220612202
var width = this.map.getSize()[0];
1220712203
var height = this.map.getSize()[1];
1220812204
var canvas = this.layer.canvasLayer.canvas;
12209-
this.layer.canvasLayer.draw();
1221012205
var context = ol.dom.createCanvasContext2D(mapWidth, mapHeight);
12211-
context.drawImage(canvas, 0, 0, mapWidth, mapHeight, (mapWidth - width) / 2, (mapHeight - height) / 2, mapWidth, mapHeight);
12206+
context.drawImage(canvas, 0, 0, width, height, (mapWidth - width) / 2, (mapHeight - height) / 2, width, height);
1221212207
if (this.resolution !== resolution || JSON.stringify(this.extent) !== JSON.stringify(extent)) {
1221312208
this.resolution = resolution;
1221412209
this.extent = extent;
@@ -14760,20 +14755,20 @@ var BaiduMapLayer = mapv.baiduMapLayer ? mapv.baiduMapLayer.__proto__ : Function
1476014755
var MapvLayer = function (_BaiduMapLayer) {
1476114756
_inherits(MapvLayer, _BaiduMapLayer);
1476214757

14763-
function MapvLayer(map, dataSet, options) {
14758+
function MapvLayer(map, dataSet, options, source) {
1476414759
_classCallCheck(this, MapvLayer);
1476514760

1476614761
var _this = _possibleConstructorReturn(this, (MapvLayer.__proto__ || Object.getPrototypeOf(MapvLayer)).call(this, map, dataSet, options));
1476714762

1476814763
_this.dataSet = dataSet;
1476914764
var self = _this;
1477014765
options = options || {};
14771-
14766+
_this.source = source;
1477214767
self.animator = null;
1477314768
self.map = map;
1477414769
self.init(options);
1477514770
self.argCheck(options);
14776-
var canvasLayer = _this.canvasLayer = new MapvCanvasLayer({
14771+
_this.canvasLayer = new MapvCanvasLayer({
1477714772
map: map,
1477814773
context: _this.context,
1477914774
paneName: options.paneName,
@@ -14784,10 +14779,6 @@ var MapvLayer = function (_BaiduMapLayer) {
1478414779
self._canvasUpdate();
1478514780
}
1478614781
});
14787-
canvasLayer.draw();
14788-
dataSet.on('change', function () {
14789-
canvasLayer.draw();
14790-
});
1479114782
_this.clickEvent = _this.clickEvent.bind(_this);
1479214783
_this.mousemoveEvent = _this.mousemoveEvent.bind(_this);
1479314784
_this.bindEvent();
@@ -14898,10 +14889,15 @@ var MapvLayer = function (_BaiduMapLayer) {
1489814889
}
1489914890
var data = self.dataSet.get(dataGetOptions);
1490014891

14892+
this.processData(data);
14893+
1490114894
self.options._size = self.options.size;
1490214895

1490314896
var pixel = map.getPixelFromCoordinate([0, 0]);
1490414897
this.drawContext(context, new mapv.DataSet(data), self.options, { x: pixel[0], y: pixel[1] });
14898+
if (self.isEnabledTime()) {
14899+
this.source.changed();
14900+
}
1490514901
self.options.updateCallback && self.options.updateCallback(time);
1490614902
}
1490714903
}, {

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.

examples/openlayers/mapvHoneycomb.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
var map = new ol.Map({
2020
target: 'map',
2121
view: new ol.View({
22-
center: [105.403119, 38.028658],
22+
center: ol.proj.transform([105.403119, 38.028658], 'EPSG:4326', 'EPSG:3857'),
2323
zoom: 4,
24-
projection: 'EPSG:4326'
24+
projection: 'EPSG:3857'
2525
})
2626
});
2727
map.addLayer(new ol.layer.Tile({
@@ -38,7 +38,7 @@
3838
data.push({
3939
geometry: {
4040
type: 'Point',
41-
coordinates: [cityCenter.lng - 2 + Math.random() * 4, cityCenter.lat - 2 + Math.random() * 4]
41+
coordinates: ol.proj.transform([cityCenter.lng - 2 + Math.random() * 4, cityCenter.lat - 2 + Math.random() * 4], 'EPSG:4326', 'EPSG:3857')
4242
},
4343
count: 30 * Math.random()
4444
});

src/common/thirdparty/elasticsearch/ElasticSearchService.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -432,15 +432,6 @@ SuperMap.ElasticSearchService = SuperMap.Class({
432432
return this.client.updateByQuery(params, callback);
433433
},
434434

435-
/**
436-
* 通过查询API来更新文档。
437-
* 参数设置参考 https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html#api-updatebyquery
438-
* 更多信息参考 https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update-by-query.html
439-
*/
440-
updateByQuery: function (params, callback) {
441-
return this.client.updateByQuery(params, callback);
442-
},
443-
444435
_update: function (data) {
445436
var me = this;
446437
if (!data) {

src/openlayers/overlay/mapv/MapvLayer.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ var BaiduMapLayer = mapv.baiduMapLayer ? mapv.baiduMapLayer.__proto__ : Function
1111

1212
class MapvLayer extends BaiduMapLayer {
1313

14-
constructor(map, dataSet, options) {
14+
constructor(map, dataSet, options, source) {
1515
super(map, dataSet, options);
1616
this.dataSet = dataSet;
1717
var self = this;
1818
options = options || {};
19-
19+
this.source = source;
2020
self.animator = null;
2121
self.map = map;
2222
self.init(options);
2323
self.argCheck(options);
24-
var canvasLayer = this.canvasLayer = new MapvCanvasLayer({
24+
this.canvasLayer = new MapvCanvasLayer({
2525
map: map,
2626
context: this.context,
2727
paneName: options.paneName,
@@ -32,10 +32,6 @@ class MapvLayer extends BaiduMapLayer {
3232
self._canvasUpdate();
3333
}
3434
});
35-
canvasLayer.draw();
36-
dataSet.on('change', function () {
37-
canvasLayer.draw();
38-
});
3935
this.clickEvent = this.clickEvent.bind(this);
4036
this.mousemoveEvent = this.mousemoveEvent.bind(this);
4137
this.bindEvent();
@@ -122,7 +118,7 @@ class MapvLayer extends BaiduMapLayer {
122118
context.clear(context.COLOR_BUFFER_BIT);
123119
}
124120
var dataGetOptions = {
125-
transferCoordinate: function transferCoordinate(coordinate) {
121+
transferCoordinate: function (coordinate) {
126122
return map.getPixelFromCoordinate(coordinate);
127123
}
128124
};
@@ -138,10 +134,14 @@ class MapvLayer extends BaiduMapLayer {
138134
}
139135
var data = self.dataSet.get(dataGetOptions);
140136

137+
this.processData(data);
138+
141139
self.options._size = self.options.size;
142140

143141
var pixel = map.getPixelFromCoordinate([0, 0]);
144142
this.drawContext(context, new mapv.DataSet(data), self.options, {x: pixel[0], y: pixel[1]});
143+
if (self.isEnabledTime()) {
144+
this.source.changed();}
145145
self.options.updateCallback && self.options.updateCallback(time);
146146
}
147147

src/openlayers/overlay/mapv/source/mapv.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,34 @@ var MapvLayer = require('./../MapvLayer');
55
ol.source.Mapv = function (opt_options) {
66
var options = opt_options ? opt_options : {};
77
ol.source.ImageCanvas.call(this, {
8-
attributions: options.attributions|| new ol.Attribution({
9-
html: '© 2017 百度 MapV with <a href="http://iclient.supermapol.com/">SuperMap iClient</a>'}),
8+
attributions: options.attributions || new ol.Attribution({
9+
html: '© 2017 百度 MapV with <a href="http://iclient.supermapol.com/">SuperMap iClient</a>'
10+
}),
1011
canvasFunction: this.canvasFunctionInternal_.bind(this),
1112
logo: options.logo,
1213
projection: options.projection,
1314
ratio: options.ratio,
1415
resolutions: options.resolutions,
1516
state: options.state
1617
});
17-
this.layer = new MapvLayer(opt_options.map, opt_options.dataSet, opt_options.mapvOptions);
18+
this.layer = new MapvLayer(opt_options.map, opt_options.dataSet, opt_options.mapvOptions, this);
19+
this.layer.canvasLayer.draw();
1820
this.map = opt_options.map;
1921
};
2022
ol.inherits(ol.source.Mapv, ol.source.ImageCanvas);
2123

2224
ol.source.Mapv.prototype.canvasFunctionInternal_ = function (extent, resolution, pixelRatio, size, projection) {
2325
if (this.layer) {
24-
var mapWidth = Math.round(ol.extent.getWidth(extent) / resolution);
25-
var mapHeight = Math.round(ol.extent.getHeight(extent) / resolution);
26+
if (!this.layer.isEnabledTime()) {
27+
this.layer.canvasLayer.draw();
28+
}
29+
var mapWidth = size[0];
30+
var mapHeight = size[1];
2631
var width = this.map.getSize()[0];
2732
var height = this.map.getSize()[1];
2833
var canvas = this.layer.canvasLayer.canvas;
29-
this.layer.canvasLayer.draw();
3034
var context = ol.dom.createCanvasContext2D(mapWidth, mapHeight);
31-
context.drawImage(canvas, 0, 0, mapWidth, mapHeight, (mapWidth - width) / 2, (mapHeight - height) / 2, mapWidth, mapHeight);
35+
context.drawImage(canvas, 0, 0, width, height, (mapWidth - width) / 2, (mapHeight - height) / 2, width, height);
3236
if (this.resolution !== resolution || JSON.stringify(this.extent) !== JSON.stringify(extent)) {
3337
this.resolution = resolution;
3438
this.extent = extent;

0 commit comments

Comments
 (0)