JXMapViewer 将方向更改为 Heading Up

发布于 2024-08-28 19:19:40 字数 199 浏览 2 评论 0原文

我正在尝试将 JXMapViewer (来自 swingx-ws)与 Open Street Maps 一起使用。我想知道是否可以在 JXMapViewer 中基于航向向上而不是向北显示地图图块。例如,普通的汽车 GPS 导航系统就可以做到这一点。

我查看了文档,似乎没有一个简单的方法可以做到这一点。除了 JXMapViewer 之外,还有其他东西可以实现此目的吗?

I am trying to use JXMapViewer (from swingx-ws) with Open Street Maps. I was wondering if it would be possible to display the map tiles in the JXMapViewer based on heading up, rather than on North up. For example, the normal car GPS navigation systems let you do that.

I've looked through the documentation and there doesn't seem to be a straightforward way to do this. Is there something else that accomplish this, besides JXMapViewer?

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

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

发布评论

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

评论(1

谎言月老 2024-09-04 19:19:40

没关系,我找到了解决方案。这是我的做法(如果有人感兴趣的话):

我将 JXMapViewer 子类化,并覆盖了 Paint 方法。
在paint方法中,JPanel的内容被转换为BufferedImage,然后根据角度旋转,然后绘制在面板的顶部。

所以 super.paint()-> BufferedImage->;对它应用仿射变换 ->绘制新图像。

当然,考虑到图像已旋转的事实,您还需要重写convertGeoPositionToPoint 和convertPointToGeoPosition 方法。

Nevermind, I found a solution. Here is how I did it(if anybody is interested) :

I subclassed JXMapViewer, and overrode the paint method.
In the paint method contents of the JPanel are converted to a BufferedImage which is then rotated according to an angle and then painted on top of the panel.

so super.paint()-> BufferedImage-> apply an affineTransformation to it-> draw the new Image.

Of course, you would also need to override the convertGeoPositionToPoint and convertPointToGeoPosition methods taking into account the fact that the image is rotated.

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