🏠 back to Observable

nebula.gl not working with deck.gl

I am trying to use the nebula.gl library in Observable and was able to require it into the notebook (see issue requiring nebula.gl) but I am unable to find the DrawPolygonMode within nebula.gl - see notebook link below

I am trying to reproduce this nebula.gl and deck.gl example https://codesandbox.io/s/deckgl-and-nebulagl-editablegeojsonlayer-no-react-forked-l0n65?file=/app.js:0-86 in Observable

Any help would be appreciated :smiley:

I have no experience whatsoever with nebula or deck, but you might be looking for drawPolygon:
image

Chrome’s DevTools have a quite powerful search function that allows you to search in all loaded resources. You can access it through Command+Option+F (Mac) or Control+Shift+F (Windows/Linux).

Thanks @mootari for the help. But I can’t find that search section in the Chrome dev tools (MacOS) - is it under Sources? Also, would you know how I would access this variable from an Observable cell?

Make sure that the dev tools are focused when you use the above shortcut. Alternatively use Command+Shift+P to open the panel/drawer search and type “search”.

Have you tried specifying mode: "drawPolygon" in your layer options?

1 Like

Thanks I was able to find the search result you showed by first clicking on dev tools and then using the shortcut. This should help sort this out.

However, specifying mode: "drawPolygon" is still giving a drawPolygon is not defined.

maybe

   mode: 'drawPolygon',
1 Like

Thanks @severo and @mootari - sorry I missed the quotes around the variable and now there is not an error.

Now, I just have to try and implement the layer correctly in the deckgl visualization. Currently, when I add the layer to the deckgl visualization nothing is showing up and I’m having to comment out a section in the layer definition otherwise I get a circular definition

  onEdit: ({ updatedData, editType, featureIndexes, editContext }) => {
    var myFeatureCollection = updatedData;
    // deck.setProps({ layers: layers });
  }

Switching to mode: drawPolygon gave the following deprecation error in the console

layers@0.21.1:1 Deprecated use of passing `mode` as a string. Pass the mode's class constructor instead.

So, I looked at the codebox example and tried to emulate the imports

// codebox
import { EditableGeoJsonLayer } from "@nebula.gl/layers";
import { DrawPolygonMode } from "@nebula.gl/edit-modes";

on Observable

// Observable cells
nebula_layers = require('https://bundle.run/@nebula.gl/layers@0.21.1') 
EditableGeoJsonLayer = nebula_layers.EditableGeoJsonLayer

nebula_edit = require('https://bundle.run/@nebula.gl/edit-modes@0.21.1') 
DrawPolygonMode = nebula_edit.DrawPolygonMode 

It looks like the imports might be working correctly, but I’m getting the following error in the console about deck: error during initialization of invalid Error: Model needs a program

1 Like