如何使用 MyLocationOverlay 在 MapView 上绘制当前 GPS 位置?如何使用、位置、MapView、MyLocationOverlay

由网友(_____痴戀っ)分享简介:我正在尝试绘制一个自定义 gps 位置图标.我正在使用 MapView 并创建了一个扩展 MyLocationOverlay.I'm trying to draw a custom gps-location icon. I'm using MapView and have created a class MyLoca...

我正在尝试绘制一个自定义 gps 位置图标.我正在使用 MapView 并创建了一个扩展 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 转换为屏幕像素坐标,相对于提供此 ProjectionMapView 的左上角.

Converts the given GeoPoint to onscreen pixel coordinates, relative to the top-left of the MapView that provided this Projection.

.

阅读全文

相关推荐

最新文章