The weekend students said they want to get an application based on the Baidu map, and then began to study the SDK. Where there is a need to apply, a set of buttons is displayed when you click on a marker on the map. As a result of the normal practice of unemployment infowindow, as follows.
//panel is a view, some buttons in it. Final New null); //getmap () return baidumap Activity.getmap (). Showinfowindow (IW);
It's not hard, but there's a problem when dealing with click events. According to the document, the Infowindow shown at this point is actually the bitmap picture of the view, which means there is no way to distinguish the buttons on the view, let alone handle the click event of the button. No wonder, there is only one clicklistener in the document for the entire Infowindow, and it does not contain view information.
This can only "curve salvation", Infowindow can not use, then directly in the Mapview shot a Popupwindow bar. (Tap the test code, the record is used)
FinalView panel = userpanel.make (activity); Point P = Activity.getmap (). getprojection (). Toscreenlocation (Marker.getposition ());FinalPopupwindow PW =NewPopupwindow (panel); Pw.setwidth (ViewGroup.LayoutParams.WRAP_CONTENT); Pw.setheight (ViewGroup.LayoutParams.WRAP_CONTENT); Pw.setfocusable (true); Pw.setoutsidetouchable (true);//getmapview () return Mapview, not baidumap any morePw.showatlocation (Activity.getmapview (), Gravity.left | gravity.bottom,p.x, P.Y);FinalButton btn = (button) Panel.findviewbyid (R.id.button2); Btn.setonclicklistener (NewView.onclicklistener () {@Override Public voidOnClick (view view) {Pw.dismiss (); } });
It's always useful to have a head.
The test found a problem, if the map occurs, the location of the window pop-up will be inaccurate, it is very strange, supposedly mapview change, its projection should be able to follow the changes in real time, this problem back to need to see.