Android 如何制作带有静态标记的移动地图应用程序,并在编辑文本中获得横向和纵向?

Android 如何制作带有静态标记的移动地图应用程序,并在编辑文本中获得横向和纵向?,android,google-maps,maps,marker,Android,Google Maps,Maps,Marker,我想做的是制作一个谷歌地图应用程序,我可以在其中移动地图,标记位置保持居中(完成),就像Uber一样。 然后在按下按钮(buttonGPS)后,获取lat(tvValueLatitude)和long(tvValueLatitude)坐标,以在两个文本视图中显示(完成)。 我需要帮助隐藏蓝点,同时将按钮保留在右上角,还需要获得移动地图时放置灰色标记的坐标。 接下来是xml文件 <?xml version="1.0" encoding="utf-8"?> <RelativeLayo

我想做的是制作一个谷歌地图应用程序,我可以在其中移动地图,标记位置保持居中(完成),就像Uber一样。 然后在按下按钮(buttonGPS)后,获取lat(tvValueLatitude)和long(tvValueLatitude)坐标,以在两个文本视图中显示(完成)。 我需要帮助隐藏蓝点,同时将按钮保留在右上角,还需要获得移动地图时放置灰色标记的坐标。 接下来是xml文件

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MapsActivity"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">


    <RelativeLayout
        android:id="@+id/rlmap"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/rlData">
        <LinearLayout
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <fragment xmlns:android="http://schemas.android.com/apk/res/android"

                android:name="com.google.android.gms.maps.SupportMapFragment"
                android:id="@+id/map_fragment"
                android:layout_width="match_parent"
                android:layout_height="match_parent" />

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:src="@drawable/pin"
                />


        </LinearLayout>
    </RelativeLayout>

    <RelativeLayout
        android:id="@+id/rlData"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingBottom="0dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentStart="true">




        <LinearLayout
            android:id="@+id/llGPS"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"

            android:layout_marginTop="@dimen/activity_horizontal_margin"
            android:divider="?android:dividerHorizontal"
            android:orientation="horizontal"
            android:showDividers="middle">

            <Button
                android:id="@+id/buttonGPS"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/activity_vertical_margin"
                android:layout_weight="1"
                android:gravity="center"
                android:text="Get GPS" />

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/activity_horizontal_margin"
                android:layout_weight="1"
                android:divider="?android:dividerVertical"
                android:orientation="vertical"
                android:showDividers="middle">

                <TextView

                    android:id="@+id/tvLatitude"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:text="@string/Latitude"
                    android:textAppearance="?android:attr/textAppearanceMedium"
                    android:textColor="@color/Black"

                    />

                <TextView

                    android:id="@+id/tvValueLatitude"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/activity_vertical_margin"
                    android:gravity="center"
                    android:hint="@string/valueLatitude"
                    android:textAppearance="?android:attr/textAppearanceMedium"
                    android:textColor="@color/Black"
                    android:textColorHint="@color/Gray" />


            </LinearLayout>

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/activity_horizontal_margin"
                android:layout_weight="1"
                android:divider="?android:dividerVertical"
                android:orientation="vertical"
                android:showDividers="middle">

                <TextView

                    android:id="@+id/tvLongitude"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:text="@string/Longitude"
                    android:textAppearance="?android:attr/textAppearanceMedium"
                    android:textColor="@color/Black"

                    />

                <TextView

                    android:id="@+id/tvValueLongitude"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/activity_vertical_margin"
                    android:gravity="center"
                    android:hint="@string/valueLongitude"
                    android:textAppearance="?android:attr/textAppearanceMedium"
                    android:textColor="@color/Black"
                    android:textColorHint="@color/Gray" />


            </LinearLayout>

        </LinearLayout>
    </RelativeLayout>

到目前为止,我只有地图。任何关于编码或指向一个好的教程的帮助都会很好,谢谢

如果我理解你的问题,这就是你需要的:

全球风险值:
私有标记

将开始标记放在屏幕中央:

    public void onMapReady(GoogleMap googleMap) {
            mMap = googleMap;
            mMap.setOnCameraMoveListener(this);
            LatLng center = mMap.getCameraPosition().target;
            marker = mMap.addMarker(new MarkerOptions().position(mMap.getCameraPosition().target));
    }
改变它的位置:

@Override
public void onCameraMove() {
    LatLng center = mMap.getCameraPosition().target;
    marker.setPosition(center);
}

然后单击以获取当前LatLng-
LatLng markerPosition=marker.getPosition()

SupportMapFragment
放在支持Z轴排序的容器中(例如,
ConstraintLayout
)。将标记放在同一个容器中,位于地图的中心(注意:如果标记的“点”位于图像的中心,这将更容易)。现在,当用户平移地图时,您所需要做的就是获取地图中心的坐标,您可以从
GoogleMap
上的
getCameraPosition()
获取坐标。查看答案。可能存在重复的
@Override
public void onCameraMove() {
    LatLng center = mMap.getCameraPosition().target;
    marker.setPosition(center);
}