首页 / 浏览问题 / 移动GIS / 问题详情
CallOut自定义布局随着地图放大 布局相距越来越远怎么解决
121EXP 2021年09月02日

布局就是一个图片是红点 上面是layout 点击红点控制layout隐藏显示

1个回答

您好,首先callout本身是地图上的某个点,会随着地图的移动而移动。点击callout显示你们的布局可以获取到点击的像素坐标,然后在像素坐标上方直接你们的layout。
9,137EXP 2021年09月02日
这个布局和红点在callout里面 不是独立的
我看你的截图layout都是显示在屏幕中央,你那边具体是怎么实现的呢

代码:

final CallOut calloutLocation = new CallOut(mapView.getContext());
calloutLocation.setStyle(CalloutAlignment.BOTTOM);
calloutLocation.setLocation(pt.getX(), pt.getY() + 0.1);
calloutLocation.setCustomize(true); // 设置自定义背景
LayoutInflater lfCallOut = getLayoutInflater();
View calloutLayout = lfCallOut.inflate(R.layout.callout_wljd, null);
TextView wuji_name = calloutLayout.findViewById(R.id.wuji_name);
View xq = calloutLayout.findViewById(R.id.xq);
View left = calloutLayout.findViewById(R.id.left);
left.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        webviewzhushi.loadUrl("https://www.baidu.com/");
        rl_webviewzhushi.setVisibility(View.VISIBLE);
    }
});
xq.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        showWLJDRightMsg(jsonListObject.get(finalI));
    }
});
wuji_name.setText(jsonListObject.get(finalI).getWlName());
calloutLocation.setStyle(CalloutAlignment.BOTTOM);
calloutLocation.setContentView(calloutLayout);

布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="300dp"
    android:layout_height="wrap_content"
    android:divider="@drawable/divider_horizontal_bg"
    android:gravity="center_horizontal"
    android:orientation="vertical">

    <com.map.mylibrary.utils.BubbleLayout
        android:id="@+id/view2"
        android:layout_width="300dp"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_gravity="center_horizontal"
        android:padding="6dp"
        android:visibility="gone"
        app:background_color="#fff"
        app:radius="4dp"
        app:shadow_color="#999999">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:layout_marginTop="5dp"
                android:text="详情"
                android:textColor="#666666" />

            <TextView
                android:id="@+id/ed_bj"
                android:layout_width="match_parent"
                android:layout_height="80dp"
                android:layout_gravity="center"
                android:layout_margin="10dp"
                android:background="@drawable/shape_xk"
                android:gravity="center"
                android:hint="填写描述信息"
                android:textColor="@color/black"
                android:textSize="14sp" />

            <LinearLayout
                android:id="@+id/view1"
                android:layout_width="300dp"
                android:layout_height="100dp"
                android:background="@color/white"
                android:orientation="horizontal"
                android:padding="10dp"
                android:visibility="gone">

                <!--        <com.example.cdlandrealestate.photoview.photo.MyGridView-->
                <!--            android:id="@+id/gridview"-->
                <!--            android:layout_width="match_parent"-->
                <!--            android:layout_height="wrap_content"-->
                <!--            android:horizontalSpacing="16px"-->
                <!--            android:listSelector="@android:color/white"-->
                <!--            android:numColumns="3"-->
                <!--            android:scrollbars="none"-->
                <!--            android:verticalSpacing="16px"-->
                <!--            android:visibility="visible" />-->
                <ImageView
                    android:id="@+id/iv1"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_gravity="center"
                    android:layout_weight="1" />

                <ImageView
                    android:id="@+id/iv2"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_gravity="center"
                    android:layout_weight="1" />

                <ImageView
                    android:id="@+id/iv3"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_gravity="center"
                    android:layout_weight="1" />
            </LinearLayout>

        </LinearLayout>
    </com.map.mylibrary.utils.BubbleLayout>


    <ImageView
        android:id="@+id/iv_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:src="@mipmap/wentixiangqing4" />


</LinearLayout>
建议您那边分成两个layout,点击callout弹出需要显示view,这样就会避免上述出现的问题
都是一个layout 为什么点的位置没变 但是点上面的layout位置跑远了?
点击callout弹出需要显示view 这个怎么实现呢 点击callout再谈出callout?
...