Android dev:show A window on Baidu Map

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.