Android 百度地圖自定義地圖覆蓋物(Marker)
阿新 • • 發佈:2018-12-10
理論和高德地圖一模一樣,換個sdk而已,換湯不換藥,詳情可以參考上一篇高德地圖https://blog.csdn.net/Crystal_xing/article/details/84314359,下面只給出核心程式碼:
//自定義佈局 View view = LayoutInflater.from(getContext()).inflate(R.layout.marker, null); TextView tv = (TextView) view.findViewById(R.id.txt_name); LinearLayout lin_state = (LinearLayout) view.findViewById(R.id.lin_state); tv.setText("!!??"); //定義Maker座標點 LatLng point = new LatLng(x,y); //橫縱座標值 myPosition = point; //構建Marker圖示 BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromView(view) //構建MarkerOption,用於在地圖上新增Marker optionPosition = new MarkerOptions() .position(point) .icon(bitmapDescriptor); //在地圖上新增Marker,並顯示 baiduMap.addOverlay(optionPosition);