如何绘制在使用MyLocationOverlay上MapView的当前GPS位置? [英] How to draw at the current GPS location on MapView using MyLocationOverlay?
问题描述
我想画一个自定义的GPS定位图标。我使用 图形页面
,并创建了一个类 MyLocationArrow
扩展<一href="http://$c$c.google.com/intl/sv-SE/android/add-ons/google-apis/reference/com/google/android/maps/MyLocationOverlay.html"相对=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
来屏幕上的像素坐标,相对于左上角的图形页面的
提供该投影
。
Converts the given GeoPoint
to onscreen pixel coordinates, relative to the top-left of the MapView
that provided this Projection
.
这篇关于如何绘制在使用MyLocationOverlay上MapView的当前GPS位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!