gpt4 book ai didi

android - 如何在将 Pin 放在 Google map 上后从 Google map 获取位置

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:24:03 32 4
gpt4 key购买 nike

我正在尝试使用 ImageView 从 GoogleMap 获取位置。我可以拖动这个 Pin 图片和我放置它的位置,我应该得到它的位置。

我将 framelayout 与 googleMap 一起使用,因为它是第一个子元素,ImageView(即 Pin)作为它的第二个子元素。

就像我们在 Google map 应用程序中一样。

enter image description here .

请建议我,如何实现这一点?

我的布局文件:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<fragment
android:id="@+id/fetchaddressMap"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
class="com.google.android.gms.maps.MapFragment" />

<ImageButton
android:id="@+id/markerRed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@android:color/transparent"
android:contentDescription="@string/content_description"
android:src="@drawable/marker_red"
android:visibility="visible" />
</FrameLayout>

最佳答案

我建议您使用 Google Maps Api 中已经内置的标记,您只需将标记设置为可拖动,并添加一个监听器,回调将为您提供所需的所有信息。更多信息请参阅 documentation .您也可以使用 Android Maps Utils library定义自定义标记。

关于android - 如何在将 Pin 放在 Google map 上后从 Google map 获取位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28499156/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com