Nebula.gl DrawPolygonMode not snapping

Viewed 340

I am quite new to nebula.gl, and I have been trying to use the DrawPolygonMode snapping to features I am dropping on the editable layer (not other layers).

The setting modeConfig says that additionalSnapTargets is not required, and the snap should occur anyway. This is not currently happening with this code:

// 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>
    );
}

is there any callback I am missing or is the function not available when drawing polygons? The advanced example shows how to do this with translation, but I am not sure to get if that's applicable to the DrawPolygonMode mode. Also, mode : new SnappableMode(new DrawPolygonMode()) does not produce the effect I am about.

Also, I have to put several //@ts-ignore as EditableGeoJsonLayer does not recognise some arguments (among which, mode).

Thank you in advance

0 Answers
Related