-
Notifications
You must be signed in to change notification settings - Fork 3
/
map.h
79 lines (73 loc) · 3.31 KB
/
map.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/************************************************************************************
* QSlippyMap - Tile based slippery map *
* Copyright (C) 2017 Michael Carpenter ([email protected]) *
* *
* This file is a part of QSlippyMap *
* *
* QSlippyMap is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
* License as published by the Free Software Foundation, version *
* 2.1 of the License. *
* *
* QSlippyMap is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this program; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
************************************************************************************/
#ifndef MAP_H
#define MAP_H
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include "tile.h"
#include "tilecache.h"
class Map : public QGraphicsView
{
Q_OBJECT
public:
explicit Map(QWidget *parent = 0);
void addWaypoint(double lat,double lon,double accel);
void setCurrentPosition(double lat, double lon);
void centerOn(double lat,double lon);
void setCenter(double lat, double lon,int zoom);
int getZoom() { return m_zoomLevel; }
void setZoom(int zoom);
void SetGoogle();
void SetMapBox();
private:
QList<QPair<double,double> >m_waypoints;
TileCache *m_tileCache;
int m_zoomLevel;
QGraphicsScene *m_scene;
QMap<QNetworkReply*,QPair<QPair<int,int>,int > > m_tileIdList;
void mouseMoveEvent(QMouseEvent *evt);
void mousePressEvent(QMouseEvent *evt);
void mouseReleaseEvent(QMouseEvent *evt);
void wheelEvent(QWheelEvent *evt);
QPointF mapToSceneCoords(QPointF latlon);
QPointF sceneToMapCoords(QPointF scenecoords);
QGraphicsEllipseItem *m_cursorCircle;
QPointF m_lastLinePoint;
QGraphicsEllipseItem *m_currentPosition;
bool m_mouseIsDown;
QPointF m_lastMousePos;
QPointF m_currentLatLon;
QString m_cacheLocation;
QPoint m_currentTileCoords;
signals:
void mouseMoved(double lat, double lon);
void mouseReleased(double lat, double lon);
void tileUpdates(int waiting);
void localTileUpdate(int count);
void networkTileUpdate(int count);
private slots:
void tileRecv(int x,int y, int z, QImage tile);
public slots:
};
#endif // MAP_H