在 G. Maps v2 中使用动画 Gif 作为地面叠加层
Using an Animated Gif as Ground Overlays in G. Maps v2
我目前正在使用 Google 地图,并希望在我的应用程序中使用动画 Gif 作为叠加层。
这真的很令人沮丧,因为在 iOS 版本的应用程序上看起来很容易,所以我真的很想实现一些很酷的东西。
我想看到的结果是这个视频的第 23 秒:https://www.youtube.com/watch?v=JI323jA67x0#t=23s
Ground Overlays 似乎是最好的做法,但不接受动画 gif:
LatLng NEWARK = new LatLng(40.714086, -74.228697);
GroundOverlayOptions newarkMap = new GroundOverlayOptions()
.image(BitmapDescriptorFactory.fromResource(R.drawable.newark_nj_1922))
.position(NEWARK, 8600f, 6500f);
// Add an overlay to the map, retaining a handle to the GroundOverlay object.
GroundOverlay imageOverlay = map.addGroundOverlay(newarkMap);
https://developers.google.com/maps/documentation/android-api/groundoverlay#add_an_overlay
作为解决方案,我们将 GIF 分解为多张图片,并循环所有图片列表。
我们使用与上面相同的代码,一切正常。
按照下面的建议使用 ImageView + Glide 根本没有帮助,因为图像不会随地图移动。
您可以使用开源库在单个图像视图中显示 Gif 图片,只需添加其依赖项即可 https://github.com/bumptech/glide
这个示例代码很容易使用
ImageView imageView = (ImageView) findViewById(R.id.imageView);
GlideDrawableImageViewTarget imageViewTarget = new GlideDrawableImageViewTarget(imageView);
Glide.with(this).load(R.raw.sample_gif).into(imageViewTarget);
@waza_be目前ground overlay不支持动画gif。希望他们很快就会拥有它。版本 1 可以使用 ImageView 并将其添加到地图中。但在版本 2 中,他们不再向地图添加视图。
我目前正在使用 Google 地图,并希望在我的应用程序中使用动画 Gif 作为叠加层。 这真的很令人沮丧,因为在 iOS 版本的应用程序上看起来很容易,所以我真的很想实现一些很酷的东西。
我想看到的结果是这个视频的第 23 秒:https://www.youtube.com/watch?v=JI323jA67x0#t=23s
Ground Overlays 似乎是最好的做法,但不接受动画 gif:
LatLng NEWARK = new LatLng(40.714086, -74.228697);
GroundOverlayOptions newarkMap = new GroundOverlayOptions()
.image(BitmapDescriptorFactory.fromResource(R.drawable.newark_nj_1922))
.position(NEWARK, 8600f, 6500f);
// Add an overlay to the map, retaining a handle to the GroundOverlay object.
GroundOverlay imageOverlay = map.addGroundOverlay(newarkMap);
https://developers.google.com/maps/documentation/android-api/groundoverlay#add_an_overlay
作为解决方案,我们将 GIF 分解为多张图片,并循环所有图片列表。
我们使用与上面相同的代码,一切正常。
按照下面的建议使用 ImageView + Glide 根本没有帮助,因为图像不会随地图移动。
您可以使用开源库在单个图像视图中显示 Gif 图片,只需添加其依赖项即可 https://github.com/bumptech/glide
这个示例代码很容易使用
ImageView imageView = (ImageView) findViewById(R.id.imageView);
GlideDrawableImageViewTarget imageViewTarget = new GlideDrawableImageViewTarget(imageView);
Glide.with(this).load(R.raw.sample_gif).into(imageViewTarget);
@waza_be目前ground overlay不支持动画gif。希望他们很快就会拥有它。版本 1 可以使用 ImageView 并将其添加到地图中。但在版本 2 中,他们不再向地图添加视图。