在 MapView 上的特定 GeoPoint 处绘制 ImageView (Android)

发布于 2024-09-25 23:53:18 字数 683 浏览 1 评论 0原文

尝试解决我在 Android MapView 上绘制图像的当前问题,然后为了使其动画化以表示移动的对象,我决定尝试在地图上的 GeoPoint 处绘制原始 ImageView,然后尝试从那里对其进行动画处理。

这是我放入地图活动(扩展 MapActivity)的 onCreate 方法中的代码:

GeoPoint point = new GeoPoint(19240000, -99120000);
ImageView iv = new ImageView(this);
iv.setImageResource(R.drawable.icon);
LayoutParams lp = new LayoutParams(iv.getWidth(), iv.getHeight(), point, LayoutParams.BOTTOM);

mapView.addView(iv, lp);

同样,我只是尝试绘制静态图标并从那里为其设置动画。我已经可以使用 ItemizedOverlay 来做到这一点,但据我所知,我无法像对视图进行动画处理那样对 AnimatedOverlay 的元素进行动画处理。因此,使用ImageView。

但图标不显示。有什么想法或建议吗?

Trying to solve my current problem of drawing an image on an Android MapView and then animate it to represent a moving object, I decided to try to just draw a raw ImageView at a GeoPoint on the map and then try and animate it from there.

This is the code I put in my map activity (extends MapActivity)'s onCreate method:

GeoPoint point = new GeoPoint(19240000, -99120000);
ImageView iv = new ImageView(this);
iv.setImageResource(R.drawable.icon);
LayoutParams lp = new LayoutParams(iv.getWidth(), iv.getHeight(), point, LayoutParams.BOTTOM);

mapView.addView(iv, lp);

Again, I'm just trying to draw the static icon and animate it from there. I can already do this with an ItemizedOverlay, but as far as I can tell, I can't animate the elements of an AnimatedOverlay the way that I can animate a view. Thus, using ImageView.

But the icon doesn't show up. Any thoughts or suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

空城仅有旧梦在 2024-10-02 23:53:18
MapView.LayoutParams screenLP = new MapView.LayoutParams(MapView.LayoutParams.WRAP_CONTENT, 
                MapView.LayoutParams.WRAP_CONTENT, point, width/2,
                0, MapView.LayoutParams.LEFT | MapView.LayoutParams.BOTTOM)

您是否尝试过使用 WRAP_CONTENT 标签?

MapView.LayoutParams screenLP = new MapView.LayoutParams(MapView.LayoutParams.WRAP_CONTENT, 
                MapView.LayoutParams.WRAP_CONTENT, point, width/2,
                0, MapView.LayoutParams.LEFT | MapView.LayoutParams.BOTTOM)

Have you tried with the WRAP_CONTENT tags?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文