叠加对谷歌的图像映射的Android API V2 [英] Overlay an image on google maps android api v2
问题描述
我想使用的GroundOverlay将图像添加到我的地图。我用这个例子从工作
I am trying to use GroundOverlay to add an image to my map. I'm working with the example from
<一个href=\"https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/model/GroundOverlay\" rel=\"nofollow\">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));
不过,我不知道如何让图像作为bitmapdescriptor。我也不知道怎么输入的LatLngBounds。任何帮助将是AP preciated,唯一的教程,我可以在网上找到是API第1节和似乎不再工作。
However I don't know how to get the image as a bitmapdescriptor. I also don't know how to input the latlngBounds. Any help would be appreciated, the only tutorials I can find online are for API v.1 and no longer seem to work.
推荐答案
<一个href=\"https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/model/BitmapDescriptorFactory\"相对=nofollow> BitmapDescriptorFactory 可以从不同的对象来创建 BitmapDescriptor
给你的,例如
BitmapDescriptorFactory can create BitmapDescriptor
s for you from various objects, e.g.
BitmapDescriptor image = BitmapDescriptorFactory.fromResource(R.drawable.myimage);
您不需要使用 positionFromBounds
如果你不想。有替代方法可以从中央在米宽经纬度
并创建:<一个href=\"https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/model/GroundOverlayOptions#position%28com.google.android.gms.maps.model.LatLng,%20float,%20float%29\"相对=nofollow> GroundOverlayOptions.position 。
You don't need to use positionFromBounds
if you don't want to. There are alternative ways to create from central LatLng
and width in meters: GroundOverlayOptions.position.
这篇关于叠加对谷歌的图像映射的Android API V2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!