deck.gl icon indicating copy to clipboard operation
deck.gl copied to clipboard

Icon Layer Not Rendering

Open mtholdefer opened this issue 9 years ago • 6 comments

I am trying to create an Icon Layer with a png icon, however the layer is not rendering. I have done some debugging and found that the IconLayer render function is only accessing the first point in the dataset, and even that point is not getting rendered. There are also no error messages thrown so I have no idea where to look for the problem.

I have attached my data file, app.js and deckgl-overlay.js files.

const layers = [ 
      new IconLayer({
        id: 'icon-layer',
        getPosition: d => {d.position; console.log(d)}, //this log is only triggered once.  should be triggered for every point in dataset
        getColor: d => [255, 0, 128],
        getAngle: d => d.heading,
        getIcon: d => d.icon,
        iconAtlas: this.props.iconAtlas,
        iconMapping: ICON_MAPPING,
        sizeScale: 1,
        opacity: 1,
        pickable: true,
        radiusMinPixels: 2,
        radiusMaxPixels: 30,
        visible: true,
        ...this.props
      })
]

files.zip

mtholdefer avatar Oct 11 '17 13:10 mtholdefer

While this is presumably not your main issue, as far as I can tell, there is no return value from this statement

getPosition: d => {d.position; console.log(d)}

The resulting undefined position should trigger either an exception or a NaN attribute warning/error.

The fact that you are not seeing anything in the browser console is strange. Maybe try different browser, just to double check?

ibgreen avatar Oct 11 '17 15:10 ibgreen

As Ib pointed out the real bug is getPosition returning undefined, you either need a explict return statement or replace {...} with single statement. Also note LayerManager._initializeNewLayer caches exceptions prints error logs. Make sure you don't have any filters on log messages. I confirmed on Chrome, it does throw errors.

1chandu avatar Oct 11 '17 19:10 1chandu

@ibgreen you're right about the return statement, after adding it, all of the points were accessed. However, the layer is still not being rendered. Could it be the png I am using? I notice in all the documentation/examples it is referred to as an AtlasImage. I am just using a .png icon with nothing special about it, is that the issue?

airplane-flight

mtholdefer avatar Oct 12 '17 11:10 mtholdefer

@mtholdefer, your .png looks fine. Atlas is normally referred to a single image that contains textures for multiple images and are referred using specific x,y offsets. But you have one image and your offsets looks good too.

One thing I noticed you don't have getSize, it should still be fine as it uses defaults value, but good thing to try specifying oe, also increase the sizeScale if the objects are too small, and compare with example code in examples/icon.

1chandu avatar Oct 12 '17 16:10 1chandu

The getSize missing was what was keeping it from rendering. Thanks!

mtholdefer avatar Oct 19 '17 13:10 mtholdefer

I believe this is not the first time someone has had this issue. Maybe we should add a minPixelSize type prop to prevent icons from becoming invisible with default settings?

ibgreen avatar Oct 19 '17 15:10 ibgreen