腾讯地图展示多个InfoWindow问题

刚做了腾讯地图相关项目,但是看了文档之后,开放平台并没有给出显示多个InfoWindow的方法,问了腾讯开发人员,也没给出答案,目前看了许多网上资料之后自己把这个功能弄了出来。

下面上代码:

public class Bean {
    private String content;

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }
}

List<Bean> data = new ArrayList<>();
/**
 * 循环添加 标记位 Marker
 */
for (int i = 0; i < data.size(); i++) {

    Bean bean  =data.get(i);
    //标注坐标 
    LatLng latLng = new LatLng(latitude, longitude);
    final Marker marker = tencentMap.addMarker(new MarkerOptions());//初始化marker 
    marker.setPosition(latLng);//经纬度
    marker.setTag(i);

    //标记点icon ,这里使用fromView通过自定义布局显示内容
    marker.setIcon(BitmapDescriptorFactory.fromView(getCustomerView(Bean, size)));

    marker.setAnchor(0.5f, 1f);//设置标记锚点
}
/**
 * 通过自定义布局显示内容
 */
public View getCustomerView(Bean bean,int size) {
    View view = View.inflate(getContext(), R.layout.layout_marker, null);
    TextView tv1 = (TextView) view.findViewById(R.id.tv_1);
    ImageView ivLocation = (ImageView) view.findViewById(R.id.iv_location);

    tv1.setText(bean.getContent());
    ivLocation.setImageResource(R.drawable.main_map_location1);
    return view;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值