问题
I am trying to use GroundOverlay to add an image to my map. I'm working with the example from
https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/model/GroundOverlay
which is given like this
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));
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.
回答1:
BitmapDescriptorFactory can create BitmapDescriptor
s for you from various objects, e.g.
BitmapDescriptor image = BitmapDescriptorFactory.fromResource(R.drawable.myimage);
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.
来源:https://stackoverflow.com/questions/18062363/overlay-an-image-on-google-maps-android-api-v2