Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了android – 如何在将Pin放到它上面后从Google Map获取位置大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试使用 ImageView从GoogleMap获取位置.
我可以拖动这个Pin图像和我放下它的位置,我应该得到它的位置.

我正在使用带有googleMap的framelayout作为它的第一个子节点,而ImageView(即Pin)作为它的第二个子元素.

就像我们在谷歌地图应用程序中一样.

.

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

我的布局文件

<FrameLayout xmlns:android="http://scheR_467_11845@as.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>

解决方法

我猜你是通过在OnTouchListener中收到的MotionEvent对象来获取屏幕的rawX和rawY点.

使用这两个坐标,您可以在投影的帮助下在地图上找到该位置:

Projection projection = googleMap.getProjection();
Log.e("TAG",projection.fromScreenLOCATIOn(new Point(x,y)).toString());

大佬总结

以上是大佬教程为你收集整理的android – 如何在将Pin放到它上面后从Google Map获取位置全部内容,希望文章能够帮你解决android – 如何在将Pin放到它上面后从Google Map获取位置所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。