【问题标题】:Android Google Maps V2 - GroundOverlay not showing on mapAndroid Google Maps V2 - GroundOverlay 未显示在地图上
【发布时间】:2015-10-13 12:08:15
【问题描述】:

我创建了一个使用 google maps v2 的 android 应用程序。我正在尝试使用 GroundOverlay 将图像放置在我的地图上,但由于某种原因它无法正常工作。
根据我所做的研究和我在互联网上看到的其他示例,我已经以正确的方式将其写入我的应用程序,为什么我没有覆盖?

叠加选项位于 OnMapLongClick() 方法中,以便在用户将手指放在地图上时放置叠加。我还调用了一个 toastLong() 方法,以显示一个 toast 来检查 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);
}

【问题讨论】:

    标签: java android google-maps google-maps-android-api-2 android-mapview


    【解决方案1】:

    只是一个小错误: 如果您在这里查看透明度文档https://developers.google.com/android/reference/com/google/android/gms/maps/model/GroundOverlayOptions.html#transparency(float)

    你看:

    透明度 [0..1] 范围内的浮点数,其中 0 表示地面 覆盖层是不透明的,1 表示地面覆盖层是透明的

    删除您的透明度(1.0f)调用或减少该值,您将看到覆盖!

    【讨论】:

    • 感谢您的帮助和回答!恐怕虽然我已经完全删除了透明度并且覆盖仍然没有显示:/
    • 好的,不用担心,我现在可以使用了!感谢您的帮助!
    • 如果您由于提供的代码或我的回答中的错误而使其工作,请将其放在这里,以便其他人受益。如果与您的特定代码有关,请忽略我:D
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-17
    相关资源
    最近更新 更多