在谷歌地图android api v2上覆盖图像

Joo*_*nda 2 android google-maps google-maps-api-2

我正在尝试使用 GroundOverlay 向我的地图添加图像。我正在使用来自的示例

https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/model/GroundOverlay

这是这样给出的

GoogleMap map = ...; // get a map.
BitmapDescriptor image = ...; // get an image.
LatLngBounds bounds = ...; // get a bounds
// Adds a ground overlay with 50% transparency.
GroundOverlay groundOverlay = map.addGroundOverlay(new GroundOverlayOptions()
 .image(image)
 .positionFromBounds(bounds)
 .transparency(0.5));
Run Code Online (Sandbox Code Playgroud)

但是我不知道如何将图像作为位图描述符。我也不知道如何输入 latlngBounds。任何帮助将不胜感激,我可以在网上找到的唯一教程是针对 API v.1 的,似乎不再有效。

Mac*_*ski 5

BitmapDescriptorFactory可以BitmapDescriptor从各种对象为您创建s,例如

BitmapDescriptor image = BitmapDescriptorFactory.fromResource(R.drawable.myimage);
Run Code Online (Sandbox Code Playgroud)

positionFromBounds如果你不想,你不需要使用。有其他方法可以从LatLng以米为单位的中心和宽度进行创建:GroundOverlayOptions.position