Overlay an image on google maps android api v2

最后都变了- 提交于 2019-12-10 11:21:48

问题


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 BitmapDescriptors 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!