0

Its pretty simple to transform a Point feature from one to another like this :

enter image description here

But I am facing a usecase that needs to animate polygon feature from one state to another, sometimes the polygons (old and new) can have different number of vertices like shown below below where I want to smoothly animate the left polygon to right?

enter image description here

Are there any pre-built APIs or efficient way of doing these things?

erluxman
  • 18,155
  • 20
  • 92
  • 126
  • There's no built-in APIs for transformations you have in mind, but you can create custom `ValueAnimator` with a custom `TypeEvaluator` and with each animation fraction create a new polygon and update the map. – Łukasz Paczos Feb 01 '19 at 13:53
  • Thanks @ŁukaszPaczos I am following that path, now I am facing issue to how to introduce the intermediate points when the number of sides is changing – erluxman Feb 01 '19 at 14:18
  • @erluxman, did you ever figure this out? I'm trying to accomplish the same polygon animation transition – langsmith Aug 22 '19 at 16:55

1 Answers1

0

sometimes the polygons (old and new) can have different number of vertices

As a solution for this particular problem, you can simply add intermediate nodes on the polygon that has less vertices. The image below shows how to get from polygon A (a rectangle) to polygon B (a "plus" shape). It is a screenshot taken from this video, which I suggest you checkout out.

Now, the difficult part is how to determine where to add those nodes ?
Do you have more info on these polygons ? Is there a relationship between them ?

enter image description here

Ariles
  • 333
  • 1
  • 14
  • there are merely an array of coordinates (in screen or map does not matter) – erluxman Feb 01 '19 at 14:16
  • @erluxman What about changing a little bit the animation, e.g: First, collapse the first polygon by bringing all of its nodes together to its center of gravity. From there, you can add the missing nodes and then move them to their respective final destinations. What do you think ? – Ariles Feb 01 '19 at 14:26
  • I do not think that will be much viable option, but what I am thinking of now is replacing the missing points with duplicate of closest point.. – erluxman Feb 01 '19 at 14:51