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

IconLayer problem

Open HeiYanjing opened this issue 8 years ago • 5 comments

In my project ,a event to make dots. so I want use IconLayer to achieve the effect. I refer to the example IconLayer. in the code ,I copy 'icon-cluster-layer.js' file in my project in layer

      new IconClusterLayer({
        data: RankListData,
        wrapLongitude: true,
        getPosition: d => d.location,
        iconAtlas: require('../../images/rank_icon.png'),
        iconMapping: require('../../data/rank-icon-mapping.json'),
        sizeScale: 30,
         id: 'icon-cluster'
        }),

but the result is not quiet right,: image the yellow point maybe is the icon ,in console. image and in the line 97 image how can I resolve this warn to show the right effect. thank you .

HeiYanjing avatar Oct 08 '18 09:10 HeiYanjing

@HeiYanjing

icon-cluster-layer.js is an example that uses standard core layer IconLayer. It basically projects icon position in screen space to group them into clusters. You may have to apply any changes to the icon-cluster-layer based on you data format and please compare all other required props.

The crash seem to be due to invalid data format, make sure data in your props is an array where each element contains coord array.

1chandu avatar Oct 08 '18 15:10 1chandu

@HeiYanjing

icon-cluster-layer.js is an example that uses standard core layer IconLayer. It basically projects icon position in screen space to group them into clusters. You may have to apply any changes to the icon-cluster-layer based on you data format and please compare all other required props.

The crash seem to be due to invalid data format, make sure data in your props is an array where each element contains coord array.

yes,I resolved it ,thank you

HeiYanjing avatar Oct 09 '18 11:10 HeiYanjing

This is always because that the input data doesn't include property of coordinates. In icon-cluster-layer.js, the location of one point is fixed to be get from this key. See https://github.com/uber/deck.gl/blob/6.3-release/examples/website/icon/icon-cluster-layer.js#L97

const screenCoords = transform.project(p.coordinates);

Other developers may face the same problem when they need to modify the codes of this demo, I think abstract it to a user customized input property will be better, such as:

const User_Customized_Key_Name = props.User_Customized_Key_Name || 'coordinates';
const screenCoords = transform.project(p[User_Customized_Key_Name]);

:-)

hijiangtao avatar Dec 20 '18 09:12 hijiangtao

@hijiangtao , please update to latest deck.gl version, and let us know if it is still relevant, if so please re open the bug, closed bugs are usually not monitored.

1chandu avatar Jul 11 '19 00:07 1chandu

@1chandu Well, I can customize getPosition function right now, but it doesn't work in [email protected] or older versions. Thanks.

hijiangtao avatar Jul 12 '19 01:07 hijiangtao