fix: picking

This commit is contained in:
thinkinggis 2020-03-20 12:13:28 +08:00
parent f938ff950c
commit e9892a2f7c
3 changed files with 6 additions and 6 deletions

View File

@ -110,7 +110,7 @@ export default class PickingService implements IPickingService {
const { enableHighlight, enableSelect } = layer.getLayerConfig(); const { enableHighlight, enableSelect } = layer.getLayerConfig();
const xInDevicePixel = x * window.devicePixelRatio; const xInDevicePixel = x * window.devicePixelRatio;
const yInDevicePixel = (height - (y + 1)) * window.devicePixelRatio; const yInDevicePixel = y * window.devicePixelRatio;
if ( if (
xInDevicePixel > width || xInDevicePixel > width ||
xInDevicePixel < 0 || xInDevicePixel < 0 ||
@ -123,7 +123,7 @@ export default class PickingService implements IPickingService {
pickedColors = readPixels({ pickedColors = readPixels({
x: Math.floor(xInDevicePixel / PICKSCALE), x: Math.floor(xInDevicePixel / PICKSCALE),
// 视口坐标系原点在左上,而 WebGL 在左下,需要翻转 Y 轴 // 视口坐标系原点在左上,而 WebGL 在左下,需要翻转 Y 轴
y: Math.floor(yInDevicePixel / PICKSCALE), y: Math.floor((height - (y + 1) * window.devicePixelRatio) / PICKSCALE),
width: 1, width: 1,
height: 1, height: 1,
data: new Uint8Array(1 * 1 * 4), data: new Uint8Array(1 * 1 * 4),

View File

@ -1,7 +1,7 @@
import { LineLayer, PointLayer, PolygonLayer, Popup, Scene } from '@antv/l7'; import { LineLayer, PointLayer, PolygonLayer, Popup, Scene } from '@antv/l7';
import { GaodeMap, Mapbox } from '@antv/l7-maps'; import { GaodeMap, Mapbox } from '@antv/l7-maps';
import { lnglatDistance } from '@antv/l7-utils'; import { lnglatDistance } from '@antv/l7-utils';
import turfCircle from '@turf/circle'; // import turfCircle from '@turf/circle';
import * as React from 'react'; import * as React from 'react';
const createGeoJSONCircle = ( const createGeoJSONCircle = (
center: [number, number], center: [number, number],
@ -9,13 +9,13 @@ const createGeoJSONCircle = (
points: number = 64, points: number = 64,
) => { ) => {
const options = { steps: 64 }; const options = { steps: 64 };
const circle = turfCircle(center, radiusInKm, options); // const circle = turfCircle(center, radiusInKm, options);
return { return {
type: 'geojson', type: 'geojson',
data: { data: {
type: 'FeatureCollection', type: 'FeatureCollection',
features: [circle], features: [],
}, },
}; };
}; };

View File

@ -1,4 +1,4 @@
import { LineLayer, MapboxScene, PolygonLayer } from '@antv/l7-react'; import { LineLayer, MapboxScene, PolygonLayer, Popup } from '@antv/l7-react';
import * as React from 'react'; import * as React from 'react';
export default React.memo(function Map() { export default React.memo(function Map() {