1

I'm trying to use an animated Layout for a Google Maps Marker. However, in Google Documentation they only speak about drawables (Bitmaps). The difficulty is only one part of the Layout is rotating. It means, that I can't convert the Layout into a Bitmap and animate the whole Bitmap.

I read the following topic Using an xml Layout for a Google Map Marker for Android that is really similar to my problem. Then I also read the following topic GIF type animation for marker in google map api ANDROID

According to these topics, my code should be something like that (not sure it works!) :

googleMap.addMarker(new MarkerOptions().position(position)
            .title("name")
            .icon(BitmapDescriptorFactory.fromBitmap(myfunction())));

private final int ONE_SECONDS = 1000;
public Bitmap myfunction(){
    // how to do there ?
}

However, I have some problems:

  • How to return a 'animated' Bitmap in the myfunction() ? I mean, how to return a different Bitmap each 100 ms ?
  • Is this solution a good way ? Because returning a different Bitmap each 100 ms may use a lot of memory for only one animation (and the animation could be not very fluid)...

Actually, maybe I should forget Google Maps ?


EDIT : I tried the solutions given by andrii-omelchenko however this way isn't good. It consumes so much resources for one animated marker !

I found an application doing what I want : ZENLY. Take a look there : https://youtu.be/0S-W8oSnzr0?t=18s How to do the same marker ?

Thanks in advance for your help.

Baudev
  • 141
  • 2
  • 13
  • 1
    Take a look at [this](https://stackoverflow.com/a/40347772/6950238) answer. – Andrii Omelchenko Oct 14 '17 at 11:43
  • Your solution is almost good. Thanks to you I can update the markerIcon periodically. Now, I need to transform my animated Layout into Bitmap**s** (an array of Bitmap maybe). How to do this ? Thanks again for your time – Baudev Oct 14 '17 at 12:14
  • Take a look at [this](https://stackoverflow.com/a/7200559/6950238) or [that](https://stackoverflow.com/a/3036736/6950238), but better IMHO use bitmap transformation. – Andrii Omelchenko Oct 14 '17 at 15:21
  • Thanks for your help. I tried what you gave to me, however it use too much resources just for one animated marker. I must found another way. – Baudev Oct 15 '17 at 10:56

1 Answers1

0

I have found a great solution : using TileOverlay : https://developers.google.com/android/reference/com/google/android/gms/maps/model/TileOverlay

So you have to add different forms such as circles and polygons and make their properties being dynamics.

It's consequently difficult just for obtaining this result !

Baudev
  • 141
  • 2
  • 13