刚做了腾讯地图相关项目,但是看了文档之后,开放平台并没有给出显示多个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; }