Android 百度地图自定义地图覆盖物(Marker)

  理论和高德地图一模一样,换个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);

 

你可能感兴趣的:(android)