不同的标记显示相同的内容信息窗口Android的谷歌地图V2 [英] Different markers show same infowindow content android google map v2

查看:496
本文介绍了不同的标记显示相同的内容信息窗口Android的谷歌地图V2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有不同的标记根据其不同的信息在自定义信息窗口显示。对于我使用不同类信息窗口的每个内容。

I have different Markers based on their different information to show in custom infowindow. For that I have use different class for each infowindow content.

我可以在我的地图上看到不同的标记。但我点击他们,只有最后建成标记的信息显示。基本信息窗口的内容是一样的。
此外,我注意到,当我点击,它不叫培训相关信息窗口,而不是它的调用最后创建信息窗口的 getInfoContents(标记为arg0)。不过,我收到正确的标记里面 getInfoContents(标记为arg0)到最后添加的标记。

I can see different Markers in my map. But I tap on them, only the lastly built marker's information is showing. Basically the infowindow content is same. Also I noted that when I tap, it does not call the relevent infowindow instead its calling lastly created infowindow's getInfoContents(Marker arg0). But I receive the correct marker inside to getInfoContents(Marker arg0) to the lastly added marker.

我们只能有一个在地图上的所有标记信息窗口执行?并根据标记鉴定我应该实现不同的内容?

We can have only one infowindow implementation for all the markers in the map? And based on the marker identification should I implement the different contents?

标记A型执行

 public class MapGoogleOverlayV2 {

    private ViewGroup infoWindow;

    public boolean onTap() {


    infoWindow  = (ViewGroup)((Activity)mContext).getLayoutInflater().inflate(R.layout.info_window_layout, null);


    /*Custom info window implementation is below */
    googleMap.setInfoWindowAdapter(new InfoWindowAdapter() {

        @Override
        public View getInfoWindow(Marker arg0) {

            return null;
        }

        @Override
        public View getInfoContents(Marker arg0) {

            // set title
            ((TextView)infoWindow.findViewById(R.id.title)).setText("Test text");

            // set freeText
            ((TextView)infoWindow.findViewById(R.id.text)).setText(Long.toString("1"));


              return infoWindow;

        }
    });
   }
}

标记中的B具有不同的信息另一类实施。
和我打电话中的onTap()

我通过调用自己的实现,并显示在地图上创建两个标记有不同的信息。

I create two markers with different information by calling their own implementation and display that in map.

唯一的问题是,他们都显示这是最后一个标记的信息相同的信息。

only problem is they both show same information which is last marker's information.

推荐答案

塞特斯(和 GoogleMap.setInfoWindowAdapter 似乎是一个二传手)替换一下在那里了。

Setters (and GoogleMap.setInfoWindowAdapter seems to be a setter) replace what was there before.

如果你调用中的onTap 在这两个班,只有最后 InfoWindowAdapter 生存。

If you call onTap in both classes, only the last InfoWindowAdapter survives.

相反,你需要设置只有一个 InfoWindowAdapter 并决定哪些标记你需要证明基于信息窗口 getInfoContents 参数(标记为arg0 )。

Instead you need to set only one InfoWindowAdapter and decide for which Marker you need to show info window based on getInfoContents parameter (Marker arg0).

这篇关于不同的标记显示相同的内容信息窗口Android的谷歌地图V2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆