MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / queryRenderedFeatures

Method queryRenderedFeatures

src/mapboxgl/overlay/L7Layer.js:52–84  ·  view source on GitHub ↗
(geometry, options, cb)

Source from the content-addressed store, hash-verified

50 }
51
52 queryRenderedFeatures(geometry, options, cb) {
53 if (!this.l7layer || !this.l7layer.isVisible()) {
54 return cb([]);
55 }
56 let box = geometry;
57 if (geometry instanceof mapboxgl.Point || typeof geometry[0] === 'number') {
58 const point = mapboxgl.Point.convert(geometry);
59 // fix 两个点一样查出来的结果不对
60 box = [point, [point.x - 1, point.y - 1]];
61 }
62 box = box.map((item) => {
63 const point = mapboxgl.Point.convert(item);
64 return [point.x, point.y];
65 });
66 const [x1, y1, x2, y2] = box.flat();
67 const _this = this;
68 this.l7layer.boxSelect([Math.min(x1, x2), Math.min(y1, y2), Math.max(x1, x2), Math.max(y1, y2)], (features) => {
69 const nextFeatures = features || [];
70 const { layerCapture = true } = options || {};
71 if (layerCapture) {
72 cb(
73 nextFeatures.map((item) => {
74 return {
75 ...item,
76 layer: _this.getLayer()
77 };
78 })
79 );
80 return;
81 }
82 cb(nextFeatures);
83 });
84 }
85
86 _formateEvent(e) {
87 return {

Callers 1

_onMouseMoveMethod · 0.45

Calls 8

convertMethod · 0.80
mapMethod · 0.80
boxSelectMethod · 0.80
minMethod · 0.80
maxMethod · 0.80
cbFunction · 0.50
isVisibleMethod · 0.45
getLayerMethod · 0.45

Tested by

no test coverage detected