Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Animating Icon Layer #4199

Closed
sambaskin opened this issue Jan 24, 2020 · 10 comments
Closed

Animating Icon Layer #4199

sambaskin opened this issue Jan 24, 2020 · 10 comments
Labels

Comments

@sambaskin
Copy link

I'm trying to visualize car trip data, and I want to use a moving icon to represent each car.
I haven't been able to find any examples where icons move, so I figured that the best way forward would be to modify either the existing trip or icon layer.
I know that the trips layer works by just adjusting the shading on a normal path layer over time, so I think the best bet would be modifying the icon layer.
Is there a way to consistently change the getPosition attribute in the icon layer over time?

@Foosballfan
Copy link

Hi @sambaskin , just add this property transitions: { getPosition: { duration: 100 } } or for JSX transitions={{ getPosition: { duration: 100 } }}

@sambaskin
Copy link
Author

Thanks! I should add that in the icon layer javascript file, right? If so, where in the file should I add that property?

@Foosballfan
Copy link

Foosballfan commented Jan 30, 2020 via email

@sambaskin
Copy link
Author

sambaskin commented Jan 30, 2020

Here's my default props section in icon-layer.js after adding that property in. Does this seem right?
I think I'm confused about where I would actually add in the location data that is used to tell the icon where to move.

`const defaultProps = {

iconAtlas: null,
iconMapping: {type: 'object', value: {}, async: true},
sizeScale: {type: 'number', value: 1, min: 0},
fp64: false,
billboard: true,
sizeUnits: 'pixels',
sizeMinPixels: {type: 'number', min: 0, value: 0}, // min point radius in pixels
sizeMaxPixels: {type: 'number', min: 0, value: Number.MAX_SAFE_INTEGER}, // max point radius in pixels
transitions: { getPosition: { duration: 100 } },
getPosition: {type: 'accessor', value: x => x.position},
getIcon: {type: 'accessor', value: x => x.icon},
getColor: {type: 'accessor', value: DEFAULT_COLOR},
getSize: {type: 'accessor', value: 1},
getAngle: {type: 'accessor', value: 0}
};
`

Edit: Sorry, just realized you probably meant the icon properties in app.js. Was still thinking about this in terms of modifying an existing layer type. Still confused on how the data for the changing position comes into this though.
Here's the icon layer in app.js:
` new IconLayer({
id: 'icon-layer',
data: icon_data,
iconAtlas: 'images/sprite.png',
iconMapping:{ marker: {x: 0, y: 0, width: 128, height: 128, mask: false}},
getPosition: d => d.position,
transitions: { getPosition: { duration: 100 } },
getIcon: d => d.icon,
getSize: 1,
sizeScale: 20,
opacity: 1

  })`

@Foosballfan
Copy link

Hopefully they'll invest some time in documenting the transitions so we have a clearer picture of what works.
Right now I'm just scouring the net for any examples.

@sambaskin
Copy link
Author

Here's two things I've found:
The docs discussing layer transitions, and one example with radius in a scatter plot layer.
Maybe I could use enter => to access a function which returns the next value stored in a dataset?
Also, thank you for your help with this! I really appreciate it

@sambaskin
Copy link
Author

Here's something else
Maybe the icon layer isn't supported by transitions?

@danias
Copy link

danias commented Aug 30, 2020

@Foosballfan Foosballfan transitions: { getPosition: { duration: 100 } } works BUT as soon as an item is added or removed and the array sequence changes, since there is no identifier to match, markers start flying around.

There should probably be a getKey data accessor to avoid this behaviour getKey: d => d.id else how would it be possible to know what goes where? You can only assume that the size of the array remains the same and there are no replacements.

@Pessimistress
Copy link
Collaborator

Merging with #2570

@haelimk
Copy link

haelimk commented Apr 20, 2022

@danias
Hi. Can I ask you something? I cannot find any solution related to icons flying around. I tried to use getKey: d => d.id, but I don't know where to put the code in. I'm using deck.gl icon layer animation with transition, and my icons are animating properly, but sunddenly they start to flying around like you mentioned. Can I get any solution or answer please? Thank you so much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants