How to draw at the current GPS location on MapView using MyLocationOverlay?(如何使用 MyLocationOverlay 在 MapView 上绘制当前 GPS 位置?)
问题描述
我正在尝试绘制一个自定义 gps 位置图标.我正在使用 MapView 并创建了一个扩展 MyLocationArrow
/google-apis/reference/com/google/android/maps/MyLocationOverlay.html" rel="nofollow">MyLocationOverlay
.
I'm trying to draw a custom gps-location icon. I'm using MapView
and have created a class MyLocationArrow
that extends MyLocationOverlay
.
我重写 drawMyLocation()
并在 100,100 处绘制一个点.但这是屏幕上的坐标.如何从当前 GPS 位置获取屏幕坐标?
I override drawMyLocation()
and draw a point at 100,100. But this is the coordinates on screen. How do I get the screen-coordinates from the current GPS-location?
推荐答案
可以用
android.graphics.Point toPixels(GeoPoint in,
android.graphics.Point out)
将给定的 GeoPoint
转换为屏幕像素坐标,相对于提供此 Projection
的 MapView
的左上角.
Converts the given GeoPoint
to onscreen pixel coordinates, relative to the top-left of the MapView
that provided this Projection
.
.
这篇关于如何使用 MyLocationOverlay 在 MapView 上绘制当前 GPS 位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何使用 MyLocationOverlay 在 MapView 上绘制当前 GPS 位置?


- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- android 4中的android RadioButton问题 2022-01-01