You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
963 B
45 lines
963 B
#include "mapViewWidget.h"
|
|
|
|
sdlMapView::sdlMapView(int x, int y, int w, int h, bool decor, sdlCoreWidget* pParent) :sdlCoreWidget(x, y, w, h, decor, pParent) {
|
|
|
|
};
|
|
|
|
sdlMapView::~sdlMapView() {
|
|
|
|
};
|
|
|
|
void sdlMapView::setCenter(double lat, double lng) {
|
|
double x = (lng + 180.0f) / 360.0f;
|
|
double y = (1.0f - log(tan(lat * M_PI / 180.0f) + 1.0f / cos(lat * M_PI / 180.0f)) / M_PI) / 2.0f;
|
|
offsetx = x * (TILESIZE << zoom) - width / 2;
|
|
offsety = y * (TILESIZE << zoom) - height / 2;
|
|
};
|
|
|
|
void sdlMapView::moveBy(int dx, int dy) {
|
|
offsetx += dx;
|
|
offsety += dy;
|
|
};
|
|
|
|
void sdlMapView::zoomAt(int x, int y) {
|
|
if (zoom < 22) {
|
|
zoom++;
|
|
offsetx = offsetx * 2 + x;
|
|
offsety = offsety * 2 + y;
|
|
};
|
|
};
|
|
|
|
void sdlMapView::zoomIn() {
|
|
zoomAt(width / 2, height / 2);
|
|
};
|
|
|
|
void sdlMapView::zoomOut() {
|
|
if (zoom > 3) {
|
|
zoom--;
|
|
offsetx = (offsetx - width / 2) / 2;
|
|
offsety = (offsety - height / 2) / 2;
|
|
};
|
|
};
|
|
|
|
void sdlMapView::drawBefore(SDL_Renderer* pRenderer){
|
|
|
|
};
|