Skip to content

Commit f2858b6

Browse files
committed
【fix】fixed SuperMap#26 and test
1 parent b7eec08 commit f2858b6

File tree

8 files changed

+380
-218
lines changed

8 files changed

+380
-218
lines changed

dist/openlayers/iclient9-openlayers-es6.js

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67285,9 +67285,23 @@ external_ol_default.a.supermap.Util = core_Util_Util;
6728567285
* @private
6728667286
*/
6728767287
var MapExtend = function () {
67288+
const fun = function (layer, coordinate, resolution, callback, pixel, e) {
67289+
if (layer instanceof external_ol_default.a.layer.Group) {
67290+
layer.getLayers().forEach(function (subLayer) {
67291+
fun(subLayer, coordinate, resolution, callback, pixel, e)
67292+
});
67293+
} else {
67294+
//当前高效率点图层满足筛选条件/并且可视时,可被选中:
67295+
if (layer.getSource()._forEachFeatureAtCoordinate) {
67296+
layer.getSource()._forEachFeatureAtCoordinate(coordinate, resolution, (feature) => {
67297+
callback(feature, layer)
67298+
}, pixel, e);
67299+
}
67300+
}
67301+
}
6728867302
external_ol_default.a.Map.prototype.forEachFeatureAtPixelDefault = external_ol_default.a.Map.prototype.forEachFeatureAtPixel;
6728967303

67290-
external_ol_default.a.Map.prototype.forEachFeatureAtPixel= external_ol_default.a.Map.prototype.Tc = function (pixel, callback, opt_options, e) {
67304+
external_ol_default.a.Map.prototype.forEachFeatureAtPixel = external_ol_default.a.Map.prototype.Tc = function (pixel, callback, opt_options, e) {
6729167305

6729267306
//如果满足高效率图层选取要求优先返回高效率图层选中结果
6729367307
const layerFilter = (opt_options && opt_options.layerFilter) ? opt_options.layerFilter : () => {
@@ -67297,13 +67311,13 @@ var MapExtend = function () {
6729767311
const layers = this.getLayers().getArray();
6729867312
const resolution = this.getView().getResolution();
6729967313
const coordinate = this.getCoordinateFromPixel(pixel);
67314+
6730067315
for (let i = 0; i < layers.length; i++) {
67301-
//当前高效率点图层满足筛选条件/并且可视时,可被选中:
67302-
if (layers[i].getVisible() && layerFilter.call(null, layers[i]) && layers[i].getSource()._forEachFeatureAtCoordinate) {
67303-
layers[i].getSource()._forEachFeatureAtCoordinate(coordinate, resolution, (feature) => {
67304-
callback(feature, layers[i])
67305-
}, pixel, e);
67316+
const layer = layers[i];
67317+
if (layer.getVisible() && layerFilter.call(null, layer)) {
67318+
fun(layer, coordinate, resolution, callback, pixel, e)
6730667319
}
67320+
6730767321
}
6730867322
return this.forEachFeatureAtPixelDefault(pixel, callback, opt_options);
6730967323
}

dist/openlayers/iclient9-openlayers-es6.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/openlayers/iclient9-openlayers.js

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35233,6 +35233,20 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
3523335233
* @private
3523435234
*/
3523535235
var MapExtend = exports.MapExtend = function () {
35236+
var fun = function fun(layer, coordinate, resolution, callback, pixel, e) {
35237+
if (layer instanceof _openlayers2.default.layer.Group) {
35238+
layer.getLayers().forEach(function (subLayer) {
35239+
fun(subLayer, coordinate, resolution, callback, pixel, e);
35240+
});
35241+
} else {
35242+
//当前高效率点图层满足筛选条件/并且可视时,可被选中:
35243+
if (layer.getSource()._forEachFeatureAtCoordinate) {
35244+
layer.getSource()._forEachFeatureAtCoordinate(coordinate, resolution, function (feature) {
35245+
callback(feature, layer);
35246+
}, pixel, e);
35247+
}
35248+
}
35249+
};
3523635250
_openlayers2.default.Map.prototype.forEachFeatureAtPixelDefault = _openlayers2.default.Map.prototype.forEachFeatureAtPixel;
3523735251

3523835252
_openlayers2.default.Map.prototype.forEachFeatureAtPixel = _openlayers2.default.Map.prototype.Tc = function (pixel, callback, opt_options, e) {
@@ -35246,17 +35260,11 @@ var MapExtend = exports.MapExtend = function () {
3524635260
var resolution = this.getView().getResolution();
3524735261
var coordinate = this.getCoordinateFromPixel(pixel);
3524835262

35249-
var _loop = function _loop(i) {
35250-
//当前高效率点图层满足筛选条件/并且可视时,可被选中:
35251-
if (layers[i].getVisible() && layerFilter.call(null, layers[i]) && layers[i].getSource()._forEachFeatureAtCoordinate) {
35252-
layers[i].getSource()._forEachFeatureAtCoordinate(coordinate, resolution, function (feature) {
35253-
callback(feature, layers[i]);
35254-
}, pixel, e);
35255-
}
35256-
};
35257-
3525835263
for (var i = 0; i < layers.length; i++) {
35259-
_loop(i);
35264+
var layer = layers[i];
35265+
if (layer.getVisible() && layerFilter.call(null, layer)) {
35266+
fun(layer, coordinate, resolution, callback, pixel, e);
35267+
}
3526035268
}
3526135269
return this.forEachFeatureAtPixelDefault(pixel, callback, opt_options);
3526235270
};

dist/openlayers/iclient9-openlayers.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/openlayers/core/MapExtend.js

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,23 @@ import ol from 'openlayers';
99
* @private
1010
*/
1111
export var MapExtend = function () {
12+
const fun = function (layer, coordinate, resolution, callback, pixel, e) {
13+
if (layer instanceof ol.layer.Group) {
14+
layer.getLayers().forEach(function (subLayer) {
15+
fun(subLayer, coordinate, resolution, callback, pixel, e)
16+
});
17+
} else {
18+
//当前高效率点图层满足筛选条件/并且可视时,可被选中:
19+
if (layer.getSource()._forEachFeatureAtCoordinate) {
20+
layer.getSource()._forEachFeatureAtCoordinate(coordinate, resolution, (feature) => {
21+
callback(feature, layer)
22+
}, pixel, e);
23+
}
24+
}
25+
}
1226
ol.Map.prototype.forEachFeatureAtPixelDefault = ol.Map.prototype.forEachFeatureAtPixel;
1327

14-
ol.Map.prototype.forEachFeatureAtPixel= ol.Map.prototype.Tc = function (pixel, callback, opt_options, e) {
28+
ol.Map.prototype.forEachFeatureAtPixel = ol.Map.prototype.Tc = function (pixel, callback, opt_options, e) {
1529

1630
//如果满足高效率图层选取要求优先返回高效率图层选中结果
1731
const layerFilter = (opt_options && opt_options.layerFilter) ? opt_options.layerFilter : () => {
@@ -21,13 +35,13 @@ export var MapExtend = function () {
2135
const layers = this.getLayers().getArray();
2236
const resolution = this.getView().getResolution();
2337
const coordinate = this.getCoordinateFromPixel(pixel);
38+
2439
for (let i = 0; i < layers.length; i++) {
25-
//当前高效率点图层满足筛选条件/并且可视时,可被选中:
26-
if (layers[i].getVisible() && layerFilter.call(null, layers[i]) && layers[i].getSource()._forEachFeatureAtCoordinate) {
27-
layers[i].getSource()._forEachFeatureAtCoordinate(coordinate, resolution, (feature) => {
28-
callback(feature, layers[i])
29-
}, pixel, e);
40+
const layer = layers[i];
41+
if (layer.getVisible() && layerFilter.call(null, layer)) {
42+
fun(layer, coordinate, resolution, callback, pixel, e)
3043
}
44+
3145
}
3246
return this.forEachFeatureAtPixelDefault(pixel, callback, opt_options);
3347
}

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