mirror of https://gitee.com/antv-l7/antv-l7
fix(tilelayer): point pickup
This commit is contained in:
parent
b6d2109a68
commit
cef72bc497
|
@ -60,7 +60,7 @@ scene.on('loaded', () => {
|
|||
// cylinder
|
||||
.shape('hexagon')
|
||||
.size(2)
|
||||
.active(false)
|
||||
.active({fill:'red'})
|
||||
.color('total', ['#d53e4f','#f46d43','#fdae61','#fee08b','#ffffbf','#e6f598','#abdda4','#66c2a5','#3288bd'].reverse())
|
||||
//.color('#0D408C')
|
||||
.style({
|
||||
|
@ -68,9 +68,9 @@ scene.on('loaded', () => {
|
|||
})
|
||||
.render(
|
||||
);
|
||||
//layer.on('mousemove',(feature)=>{
|
||||
// console.log(feature);
|
||||
// })
|
||||
layer.on('mousemove',(feature)=>{
|
||||
console.log(feature);
|
||||
})
|
||||
console.log(layer);
|
||||
});
|
||||
//OBJECTID',(id)=>{
|
||||
|
|
|
@ -50,6 +50,7 @@ class Picking {
|
|||
}
|
||||
_update(point) {
|
||||
const texture = this._pickingTexture;
|
||||
// this._pickingTexture
|
||||
this._renderer.render(this._pickingScene, this._camera, this._pickingTexture);
|
||||
this.pixelBuffer = new Uint8Array(4);
|
||||
this._renderer.readRenderTargetPixels(texture, point.x, this._height - point.y, 1, 1, this.pixelBuffer);
|
||||
|
|
|
@ -168,7 +168,6 @@ export default class Layer extends Base {
|
|||
} else {
|
||||
scaleDefs[field] = cfg;
|
||||
}
|
||||
console.log(options);
|
||||
return this;
|
||||
}
|
||||
shape(field, values) {
|
||||
|
@ -627,8 +626,8 @@ export default class Layer extends Base {
|
|||
}
|
||||
this._activeIds = featureId;
|
||||
// TODO 瓦片图层获取选中数据信息
|
||||
const { feature, style } = this.getSelectFeature(featureId);
|
||||
const lnglat = this.scene.containerToLngLat(point2d);
|
||||
const { feature, style } = this.getSelectFeature(featureId, lnglat);
|
||||
// const style = this.layerData[featureId - 1];
|
||||
const target = {
|
||||
featureId,
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
import Tile from './tile';
|
||||
import ImageBuffer from '../../geom/buffer/image';
|
||||
import DrawImage from '../render/image/drawImage';
|
||||
import * as THREE from '../../core/three';
|
||||
export default class ImageTile extends Tile {
|
||||
requestTileAsync() {
|
||||
// Making this asynchronous really speeds up the LOD framerate
|
||||
|
|
|
@ -3,7 +3,6 @@ import source from '../../core/source';
|
|||
import * as THREE from '../../core/three';
|
||||
import Global from '../../global';
|
||||
const { pointShape } = Global;
|
||||
import { updateObjecteUniform } from '../../util/object3d-util';
|
||||
import TileCache from './tileCache';
|
||||
import pickingFragmentShader from '../../core/engine/picking/picking_frag.glsl';
|
||||
import { throttle, deepMix } from '@antv/util';
|
||||
|
@ -208,17 +207,15 @@ export default class TileLayer extends Layer {
|
|||
this._pickTiles.add(pickingMesh);
|
||||
|
||||
}
|
||||
getSelectFeature(id) {
|
||||
let feat = null;
|
||||
this._tileKeys.forEach(key => {
|
||||
const tile = this._tileCache.getTile(key);
|
||||
const feature = tile ? tile.getSelectFeature(id) : null;
|
||||
if (feature !== null) {
|
||||
feat = feature;
|
||||
return;
|
||||
}
|
||||
});
|
||||
return { feature: feat };
|
||||
// 根据距离优先级查找
|
||||
getSelectFeature(id, lnglat) {
|
||||
const zoom = Math.round(this.scene.getZoom()) - 1;
|
||||
const tilePoint = this._crs.lngLatToPoint(toLngLat(lnglat.lng, lnglat.lat), zoom);
|
||||
const tileXY = tilePoint.divideBy(256).round();
|
||||
const key = [ tileXY.x, tileXY.y, zoom ].join('_');
|
||||
const tile = this._tileCache.getTile(key);
|
||||
const feature = tile ? tile.getSelectFeature(id) : null;
|
||||
return { feature };
|
||||
}
|
||||
_pruneTiles() {
|
||||
let tile;
|
||||
|
|
|
@ -11,20 +11,20 @@ export default function geoJSON(data, cfg) {
|
|||
turfMeta.flattenEach(data, (currentFeature, featureIndex) => { // 多个polygon 拆成一个
|
||||
const coord = getCoords(currentFeature);
|
||||
let id = featureIndex + 1;
|
||||
// if (cfg.idField) {
|
||||
// const value = currentFeature.properties[cfg.idField];
|
||||
// // id = value;
|
||||
// id = BKDRHash(value) % 1000019;
|
||||
// if (featureKeys[id] && featureIndex !== featureKeys[id]) {
|
||||
// // TODO 哈希冲突解决方法
|
||||
// console.log('哈希冲突', value);
|
||||
// }
|
||||
// featureKeys[id] = featureIndex;
|
||||
// }
|
||||
if (cfg.idField && currentFeature.properties[cfg.idField]) {
|
||||
const value = currentFeature.properties[cfg.idField];
|
||||
// id = value;
|
||||
id = BKDRHash(value) % 1000019;
|
||||
// if (featureKeys[id] && featureIndex !== featureKeys[id]) {
|
||||
// // TODO 哈希冲突解决方法
|
||||
// console.log('哈希冲突', value);
|
||||
// }
|
||||
}
|
||||
featureKeys[id] = featureIndex;
|
||||
const dataItem = {
|
||||
...currentFeature.properties,
|
||||
coordinates: coord,
|
||||
_id: currentFeature.properties[cfg.idField]
|
||||
_id: id
|
||||
};
|
||||
resultData.push(dataItem);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue