开发者

JXMapViewer change orientation to Heading Up

开发者 https://www.devze.com 2022-12-27 17:21 出处:网络
I am trying to use JXMapViewer (from swingx-ws) with Open Street M开发者_如何学Caps. I was wondering if it would be possible to display the map tiles in the JXMapViewer based on heading up, rather tha

I am trying to use JXMapViewer (from swingx-ws) with Open Street M开发者_如何学Caps. 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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号