问题描述
我对nebula.gl很陌生,我一直在尝试使用DrawpolygonMode捕捉功能来放置要放置在可编辑层(而非其他层)上的功能。
设置modeConfig表示不需要additionalSnapTargets
,并且仍然应该发生捕捉。这段代码目前没有发生这种情况:
// index.tsx
import React,{ useState,useEffect } from 'react';
import DeckGL from 'deck.gl';
import { EditableGeoJsonLayer,DrawpolygonMode } from 'nebula.gl';
import { StaticMap } from 'react-map-gl';
// ...
// const viewState = ...
// const MAPBox_TOKEN = ...
const selectedFeatureIndexes = [] as any;
const editableLayer = new EditableGeoJsonLayer({
id: 'geojson',data: geojson,pickable:true,//@ts-ignore
modeConfig:{
enableSnapping:true
},//@ts-ignore
mode: DrawpolygonMode,pickingRadius:100,selectedFeatureIndexes,//@ts-ignore
onEdit: (e) => {setGeojson(e.updatedData)}
});
export function Map(props:any){
const [geojson,setGeojson] = useState({
type: 'FeatureCollection' as any,features: [] as any} as any)
return(
<DeckGL
width='100%'
height='100%'
layers={[editableLayer]}
viewState={viewState}
controller={true}>
<StaticMap
width='100%'
height='100%'
mapBoxApiAccesstoken={MAPBox_TOKEN} />
</DeckGL>
);
}
绘制多边形时我是否缺少回调或该功能不可用? advanced example显示了如何进行翻译,但是我不确定是否适用于DrawpolygonMode
模式。另外,mode : new SnappableMode(new DrawpolygonMode())
不会产生我想要的效果。
此外,我还必须放置几个//@ts-ignore
,因为EditableGeoJsonLayer
不能识别某些参数(其中mode
中)。
提前谢谢
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)