mapbox / DEPRECATED-mapbox-gl

Issue-only repository for discussion of Mapbox GL (DEPRECATED)
https://www.mapbox.com/mapbox-gl/
21 stars 5 forks source link

Add the ability to progressively reveal / hide a line #7

Closed peterqliu closed 8 years ago

peterqliu commented 8 years ago

Animating a line draw is a common need in routing and transportation. I've previously simulated this in GL by chopping a line into a bunch of tiny segments and feeding them in one at a time (via setData), but it would be nice to do this in a less hacky fashion.

In SVG, this is done by turning the line into an extremely long dash, applying a dash-offset property to "push" the dash off the line, and then at runtime, animating the offset to 0. Maybe we can do something similar, or a simpler approach.

cc/ @lyzidiamond

tmcw commented 8 years ago

This should be folded into https://github.com/mapbox/mapbox-gl-js/issues/1180 - mapbox-gl-js needs animation primitives and faster setData calls. We shouldn't copy the SVG line-dash hack, which is a hack.

lucaswoj commented 8 years ago

It sounds like there are two separate issues in here:

  1. setData performance (more of a gl-js or gl-native specific issue, hopefully being addressed in mapbox/mapbox-gl-js#1979). This is out of scope for this repo.
  2. displaying only part of a line, defined by start position and end position. This is an interesting discussion, complicated by the way geometries are sliced on tile boundaries.
tmcw commented 8 years ago

I don't think (2) should be considered. This is one of many potential animations: what about animating a polygon, or a line but from the other side, or from both ends? setData is the universal solution for animation and should be the sole focus.

lucaswoj commented 8 years ago

The underlying issue here is "we need a faster setData". That's a platform-specific challenge which we're tackling (namely in mapbox/mapbox-gl-js#1979)

jfirebaugh commented 8 years ago

More generally there's the question of whether setData is even a suitable primitive for animations.