首页 / 浏览问题 / 移动GIS / 问题详情
给地图添加标记,addCallout
65EXP 2021年06月16日

给地图添加了标记  设置一个自定义布局,自定义布局就是一个简单的imageview  但是该标记有一个比较大的背景 造成该布局下的那个图标不能显示到正确的底部那个位置 有没有方法只设置一张png图

String makerName = MY_POINT_OWNER_MAKER + x + y;
        listOwnerPointMaker.add(makerName);
        //设置标注
        LayoutInflater inflater = mActivity.getLayoutInflater();
        View view = inflater.inflate(R.layout.layout_map_marker_callout, null);
        ImageView imgMaker = view.findViewById(R.id.img_view_maker);
        imgMaker.setImageResource(R.mipmap.ic_owner_info_map_maker);

        CallOut callout = new CallOut(mActivity);
        callout.setContentView(view);  // 设置显示内容
        callout.setCustomize(true);  // 是否自定义背景图片
        callout.setLocation(x, y);// 设置显示位置
        //callout.setStyle(CalloutAlignment.BOTTOM);
        mMapView.addCallout(callout, makerName);
        callout.dispose();
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="30dp"
    android:layout_height="50dp"
    android:background="@color/color_normal_title">
    <ImageView
        android:id="@+id/img_view_maker"
        android:layout_width="30dp"
        android:layout_height="50dp"
        android:src="@mipmap/ic_my_location_marker"
        />
</RelativeLayout>

1个回答

您好,可以检查一下您原始的图片是不是有背景呢?你把图片添加到drawable里面,然后去布局文件里面调用即可。具体代码可以网上搜索Android imageView;如果有背景可以使用第三方软件将背景去掉。可以参考一下我们的示范demo:GeometryInfo
9,137EXP 2021年06月16日
...