forked from zeroch/OpenStreetMap-Qt-Plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMapItem.cpp
55 lines (47 loc) · 1.31 KB
/
MapItem.cpp
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
#include "MapItem.h"
MapItem::MapItem(QQuickItem *parent=0) : MapItem(parent)
{
map()->setSize(width(), height());
map()->setShowFrameRate(true);
map()->setProjection(Mercator);
map()->setMapThemeId("earth/openstreetmap/openstreetmap.dgml");
map()->setShowAtmosphere(false);
map()->setShowCompass(false);
map()->setShowClouds(false);
map()->setShowCrosshairs(false);
map()->setShowGrid(false);
map()->setShowOverviewMap(false);
map()->setShowOtherPlaces(false);
map()->setShowScaleBar(false);
map()->setShowBackground(false);
}
MapItem::~MapItem()
{
}
void MapItem::componentComplete()
{
QQuickItem *pinch = findChild<QQuickItem*>("pinchArea");
if (pinch)
{
pinch->setFiltersChildMouseEvents(childMouseEventFilter());
}
}
void MapItem::makePinch(QPointF center, Qt::GestureState currentState, qreal scale =1)
{
scale = sqrt(sqrt(scale));
scale = qBound(0.5, scale, 2.0);
pinch(center, scale, currentState);
}
void MapItem::pinchStart(QPointF center)
{
makePinch(center, Qt::GestureStarted);
}
void MapItem::pinchEnd(QPointF center, bool stop)
{
// cancle the pinch or the pinch finished
makePinch(center, stop ? Qt::GestureFinished : Qt::GestureCanceled);
}
void MapItem::pinchUpdate(QPointF center, qreal scaleFactor)
{
makePinch(center, Qt::GestureUpdated, scaleFactor);
}