mBaiduMap.setOnMarkerClickListener(new BaiduMap.OnMarkerClickListener() { @Override public boolean onMarkerClick(final Marker marker) {
//率一种 View view = View.inflate(getApplicationContext(), R.layout.activity_map_info, null); TextView xiugai = view.findViewById(R.id.tite); ImageView pic1=view.findViewById(R.id.t_image); final InfoWindow mInfoWindow = new InfoWindow(view, marker.getPosition(), -47); mBaiduMap.showInfoWindow(mInfoWindow);
//玄虚二种
InfoWindow mInfoWindow; //获得marker中的数据 b= (FirepgBean) marker.getExtraInfo().get("info"); //得到上边传过来的实体类的信息 TextView location = new TextView(getApplicationContext()); location.setBackgroundResource(R.drawable.btn_bg_red); location.setPadding(30, 20, 30, 50); //去除设置实体类里边name的信息 //location.setText(b.getXfbm()); location.setText(b.getXfbm()+":"+b.getJwd()); //将marker所在的经纬度的信息转化成屏幕上的坐标 final LatLng ll = marker.getPosition(); Point p = mBaiduMap.getProjection().toScreenLocation(ll); p.y -= 47; LatLng llInfo = mBaiduMap.getProjection().fromScreenLocation(p); //infowindow点击事件 InfoWindow.OnInfoWindowClickListener listener = new InfoWindow.OnInfoWindowClickListener() { @Override public void onInfoWindowClick() { //隐藏infowindow mBaiduMap.hideInfoWindow();
}
}