Android Google Maps V2 - GroundOverlay 未显示在地图上
Android Google Maps V2 - GroundOverlay not showing on map
我创建了一个使用 google 地图 v2 的 android 应用程序。我正在尝试使用 GroundOverlay 将图像定位在我的地图上,但由于某种原因它无法正常工作。
根据我所做的研究和我在 Internet 上看到的其他示例,我已经以正确的方式将它写入我的应用程序,为什么我没有得到叠加层?
覆盖选项位于 OnMapLongClick() 方法中,以便在用户将手指放在地图上时放置覆盖。我还调用了一个 toastLong() 方法来显示祝酒词以检查 OnMapLongClick 方法是否正常工作。
叠加层的图像也肯定存在并且可以访问。
代码如下:
//-----map long click
@Override
public void onMapLongClick(LatLng point) {
toastMsg = "on map long click";
toastLong();
//add overlay
BitmapDescriptor image = BitmapDescriptorFactory.fromResource(R.drawable.lower_ui);
GroundOverlayOptions groundOverlay = new GroundOverlayOptions()
.image(image)
.position(point, 500f, 500f)
.transparency(1.0f);
mapView.addGroundOverlay(groundOverlay);
}
只是一个小错误:
如果您在此处查看透明度文档 https://developers.google.com/android/reference/com/google/android/gms/maps/model/GroundOverlayOptions.html#transparency(float)
你看:
transparency a float in the range [0..1] where 0 means that the ground
overlay is opaque and 1 means that the ground overlay is transparent
删除您的透明度 (1.0f) 调用或减小该值,您将看到叠加层!
我创建了一个使用 google 地图 v2 的 android 应用程序。我正在尝试使用 GroundOverlay 将图像定位在我的地图上,但由于某种原因它无法正常工作。
根据我所做的研究和我在 Internet 上看到的其他示例,我已经以正确的方式将它写入我的应用程序,为什么我没有得到叠加层?
覆盖选项位于 OnMapLongClick() 方法中,以便在用户将手指放在地图上时放置覆盖。我还调用了一个 toastLong() 方法来显示祝酒词以检查 OnMapLongClick 方法是否正常工作。
叠加层的图像也肯定存在并且可以访问。
代码如下:
//-----map long click
@Override
public void onMapLongClick(LatLng point) {
toastMsg = "on map long click";
toastLong();
//add overlay
BitmapDescriptor image = BitmapDescriptorFactory.fromResource(R.drawable.lower_ui);
GroundOverlayOptions groundOverlay = new GroundOverlayOptions()
.image(image)
.position(point, 500f, 500f)
.transparency(1.0f);
mapView.addGroundOverlay(groundOverlay);
}
只是一个小错误: 如果您在此处查看透明度文档 https://developers.google.com/android/reference/com/google/android/gms/maps/model/GroundOverlayOptions.html#transparency(float)
你看:
transparency a float in the range [0..1] where 0 means that the ground overlay is opaque and 1 means that the ground overlay is transparent
删除您的透明度 (1.0f) 调用或减小该值,您将看到叠加层!