showInfoWindow函数在android Google地图中不起作用

问题描述 投票:0回答:1

我有一个带有一些标记的google地图,所有标记都有标题和摘录。我将标记存储在HashMap中。我想在单击按钮时使用showInfoWindow()函数显示标题和摘要。这是我的代码:

Marker m = getMarker(location); //this function return marker from HashMap with its location
if(m!=null)
    m.showInfoWindow();

m不为null,但showInfoWindow()不起作用

android google-maps android-studio android-maps-v2 android-maps
1个回答
0
投票

将您的代码更改为此

    Marker m = getMarker(location);
if(m!= null){
    m.showInfoWindow();
}

如果标记尚未在地图上呈现,则标记对象将为null,因此在使用标记对象之前,请确保检查标记对象是否为null。

© www.soinside.com 2019 - 2024. All rights reserved.