您的位置:首页 > 其它

高德地图点击marker,infoWindow不显示问题

2017-03-15 10:29 881 查看
1)按照官网指示,要implement Amap.AMap.InfoWindowAdapter,override func:

@Override

public View getInfoWindow(Marker marker) {

System.out.println("getInfoWindow");
View infoWindow = null;
if (infoWindow == null) {
infoWindow = LayoutInflater.from(this).inflate(
R.layout.es_parent_popu, null);
}


// TextView title =(TextView)infoWindow.findViewById(R.id.title);

// title.setText(“lqteam”);

// TextView snippet =(TextView)infoWindow.findViewById(R.id.snippet);

// String str =”lqteam snippet”;

// snippet.setText(str);

render(marker,infoWindow);

return infoWindow;

}

@Override

public View getInfoContents(Marker marker) {

return null;

}

}

2)设置监听

aMap.setOnMarkerClickListener(this);

//实现 InfoWindow 样式和内容,必须要先执行如下方法:

aMap.setInfoWindowAdapter(this);//AMap类中

3)在marker的点击事件里, marker.showInfoWindow():

@Override

public boolean onMarkerClick(Marker marker) {

//调用 Marker 类的 showInfoWindow() 和 hideInfoWindow() 方法可以控制显示和隐藏。

System.out.println(“onMarkerClick”);

marker.showInfoWindow();

System.out.println(“onMarkerClick marker.showInfoWindow()”);

return true;

}

4)注意::添加maker的时候必须设置marker的title,不然是不会弹出infowindow的。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  infoWindow