raptorswing / MapGraphics

A tile-based "slippy map" library written in/for C++/Qt. It's meant to enable C++/Qt developers to easily add nice, interactive maps to their applications. Supports zooming, rotating, interactive custom map objects, transparency, etc. It is a Qt map widget that can use tiles from MapQuest, Openstreetmap, or a custom source you define.
Other
163 stars 77 forks source link

How to rotate map #25

Closed ghost closed 2 years ago

ghost commented 2 years ago

How i can rotate map?

raptorswing commented 2 years ago

There's not a built-in method to do this, but I think it should be pretty easy to add.

MapGraphicsView has a QGraphicsView: https://github.com/raptorswing/MapGraphics/blob/5abf53449707985ef4754f9cc172fa99ea6c70fe/MapGraphics/MapGraphicsView.h#L97

QGraphicsView has methods for rotation or setting a transformation matrix.

If you add a method to MapGraphicsView that exposes that underlying functionality I think it will work.

Feel free to send a PR if you get something nice working :) I don't have a dev environment setup for this project at the moment so it's hard for me to work on it.

raptorswing commented 2 years ago

See 0cf9af2104f545b3ec279772ef582feae304c4d1

🥳

ghost commented 2 years ago

It's rotate map and text, but i want rotate map, but text is static image

raptorswing commented 2 years ago

Yes, the text is "baked into" the tiles. The tiles are just images pulled from OpenStreetMap and the orientation is set in stone when the tile is rendered.

To make the text always stay right-side-up the tiles would have to be rendered dynamically within the application. This would take a decent amount of work but is possible. One way would be to write a new tile source (implement the interface defined by MapTileSource) that renders tiles within the application. MapTileSource's interface would need to be modified to take rotation as an input for rendering.

Another option would be to render tiles with no text and add the text on top as map objects.

ghost commented 2 years ago

I have a program in my repository for this, I just wanted to know if it's possible better