- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我翻遍了文档,还是没能弄明白。有可能吗?
最佳答案
看起来正确的机制是扩展 MyLocationOverlay,然后覆盖 drawMyLocation() protected 方法。
下面用箭头表示“你”在哪里以及“你”指向的方向:
包 com.example;
导入 android.content.Context;
导入 android.graphics.Bitmap;
导入 android.graphics.BitmapFactory;
导入 android.graphics.Canvas;
导入 android.graphics.Matrix;
导入 android.graphics.Point;
导入 android.location.Location;
导入 com.google.android.maps.GeoPoint;
导入 com.google.android.maps.MapView;
导入 com.google.android.maps.MyLocationOverlay;
公共(public)类 MyCustomLocationOverlay 扩展 MyLocationOverlay {
私有(private)上下文 mContext;
私有(private) float 方向;
public MyCustomLocationOverlay(上下文上下文,MapView mapView){
super (上下文, map View );
mContext = 上下文;
}
@覆盖
protected void drawMyLocation(Canvas canvas, MapView mapView, Location lastFix, GeoPoint myLocation, long when) {
//将 GeoPoint 转换为屏幕像素
点screenPts = mapView.getProjection().toPixels(myLocation, null);
//创建标记的旋转副本
位图 arrowBitmap = BitmapFactory.decodeResource( mContext.getResources(), R.drawable.arrow_green);
矩阵matrix = new Matrix();
matrix.postRotate(mOrientation);
位图 rotatedBmp = Bitmap.createBitmap(
箭头位图,
0, 0,
arrowBitmap.getWidth(),
arrowBitmap.getHeight(),
矩阵,
真的
);
//将旋转标记添加到 Canvas
canvas.drawBitmap(
旋转Bmp,
screenPts.x - (rotaatedBmp.getWidth()/2),
screenPts.y - (rotaatedBmp.getHeight()/2),
无效的
);
}
public void setOrientation(float newOrientation) {
mOrientation = newOrientation;
}
}
关于java - 如何为 MyLocationOverlay 中的 "you are here"点使用自定义位图?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/753793/
我在 MapView 上遇到异常行为,顺便说一句,我正在使用 RoboGuice,我不确定它是否会影响问题。 问题是,如果我在我的 map 上启用了 MyLocationListener,那么它上面的
在 android 上,我们有 MyLocationOverlay 类。当设备所有者在某些国家/地区时,此类是否有任何问题?我没有任何理由相信它不会起作用,只是不确定谷歌服务条款 - 也许在某些国家/
如何更改谷歌地图中 MyLocationOverlay 的默认蓝色动画标记? 最佳答案 谢谢@CommonsWare,你引导我朝着正确的方向前进。花了相当多的时间来摆弄这个。 http://code.
是否可以覆盖 MyLocationOverlay() 的 onDraw 方法并用其他东西替换标准的闪烁蓝色图标。我可以通过哪些方式实现这一点? 最佳答案 这里很好地回答了您的问题: myLocatio
private void initMyLocation() { myLocOverlay = new MyLocationOverlay(this, myMap); m
我是安卓新手。我了解了 MyLocationOverlay。它可以获取用户位置并在该位置上绘制一个蓝点。我想获取用户位置并将其发送到服务器。是否可以使用 MyLocationOverlay 获取用户位
在我的应用程序中,我希望看到当您在谷歌地图中四处走动时跟随您的小蓝点。下面是代码,但是我没有在任何地方看到蓝点,即使我将应用程序导出到我的手机也是如此! public class UCLAProjec
我在使用 osmdroid 映射 API 的 android 映射应用程序中工作,直到现在我能够显示 map (使用 MapView 类),但我想知道如何在 map 上显示我的位置,之后我读到了它我知
我可以轻松地使用 myLocationOverlay 获取我的位置,并且我想设置为我的位置中心,我尝试了 map Controller : MapController mc = myMap.getCo
MyLocationOverlay 已弃用。有其他选择吗? MapView mapView; MyLocationOverlay myLocationoverlay; @Override protec
我的 GoogleMap API for Android 组件 MyLocationOverlay 有问题。每次设备位置发生变化(并且用户位置超出可见部分或 map )时,我都想关闭 MyLocati
刚刚浪费了 3 个小时试图弄清楚为什么在我的 map Activity 暂停时 GPS 图标仍然显示在通知栏中。我已将其缩小到与我正在使用的 MyLocationOverlay 对象有关(我还有一个
我有一个 MapView,上面有一些叠加层和 MyLocationOverlay 的子类,因为我希望用户当前位置显示在其他标记之上。 我正在为标记处理 onTap 事件,以显示一个面板,其中包含所点击
我正在开发一个显示带有用户位置的 map 的 Android 应用程序,到目前为止,我能够在线和离线显示 map 。现在我想知道如何使用 MylocationOverlay 在 osmdroid 中绘
我正在开发一个应用程序。我在其中与 friend 分享我的位置(非常像谷歌纬度)。我有一个作为守护进程运行的服务:它应该显示接收到的位置,并每 x 秒发布一次当前用户位置。 现在,作为 Android
关于 MapView 中的 MyLocationOverlay.enableMyLocation 方法的一个小问题。 在原始的 Goggle map 应用程序中,位置显示为指南针,但是,如果我在 Ma
我制作了一个应用程序,它使用 MyLocationOverlay 类显示用户的当前位置。然而,当用户改变他的位置时,标记不会重新居中。如何实现“跟我来”功能? 我正在考虑让 LocationManag
我正在使用 MapView 在 map 上显示用户的当前位置。要在用户移动时更新位置,我必须做出选择: 我可以使用 MyLocationOverlay 绘制当前位置并扩展它以允许跟踪移动中的用户位置并
MyLocationOverLay和调用LocationManager.requestLocationUpdates函数有什么区别 换句话说,如果我要在用户移动时在 map 上显示用户位置,MyLoc
我翻遍了文档,还是没能弄明白。有可能吗? Please see this 最佳答案 看起来正确的机制是扩展 MyLocationOverlay,然后覆盖 drawMyLocation() protec
我是一名优秀的程序员,十分优秀!