summaryrefslogtreecommitdiff
path: root/src/location
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-11-27 03:01:30 +0100
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-11-27 03:01:30 +0100
commit181f1d8eac0af6e508ed483cbffb28cd2066b961 (patch)
treece9ecf4878562ea35ddd6afd5efa040107d739af /src/location
parent355a82e3d3aeb470b1d3d257afd2cce24f05b110 (diff)
parentfb23882d5bc697b2dfdd22c27d34c52d889d1200 (diff)
downloadqtlocation-181f1d8eac0af6e508ed483cbffb28cd2066b961.tar.gz
Merge remote-tracking branch 'origin/5.12' into dev
Change-Id: I79898ba40dcce8054a105867ab2a88f1fba72c1f
Diffstat (limited to 'src/location')
-rw-r--r--src/location/declarativemaps/qdeclarativegeomapitemview.cpp85
-rw-r--r--src/location/declarativemaps/qdeclarativegeomapitemview_p.h12
-rw-r--r--src/location/declarativemaps/qdeclarativepolylinemapitem.cpp137
-rw-r--r--src/location/doc/src/qtlocation-qml.qdoc138
-rw-r--r--src/location/doc/src/qtlocation.qdoc8
-rw-r--r--src/location/labs/qdeclarativenavigator.cpp7
-rw-r--r--src/location/labs/qdeclarativenavigator_p_p.h2
-rw-r--r--src/location/maps/qgeoprojection.cpp3
-rw-r--r--src/location/maps/qgeoserviceprovider.cpp11
-rw-r--r--src/location/maps/qgeoserviceprovider.h3
-rw-r--r--src/location/maps/qnavigationmanagerengine.cpp1
-rw-r--r--src/location/maps/qnavigationmanagerengine_p.h1
12 files changed, 287 insertions, 121 deletions
diff --git a/src/location/declarativemaps/qdeclarativegeomapitemview.cpp b/src/location/declarativemaps/qdeclarativegeomapitemview.cpp
index 4461d2e0..41ab3453 100644
--- a/src/location/declarativemaps/qdeclarativegeomapitemview.cpp
+++ b/src/location/declarativemaps/qdeclarativegeomapitemview.cpp
@@ -135,8 +135,8 @@ void QDeclarativeGeoMapItemView::classBegin()
connect(m_delegateModel, &QQmlInstanceModel::modelUpdated, this, &QDeclarativeGeoMapItemView::modelUpdated);
connect(m_delegateModel, &QQmlInstanceModel::createdItem, this, &QDeclarativeGeoMapItemView::createdItem);
- connect(m_delegateModel, &QQmlInstanceModel::destroyingItem, this, &QDeclarativeGeoMapItemView::destroyingItem);
- connect(m_delegateModel, &QQmlInstanceModel::initItem, this, &QDeclarativeGeoMapItemView::initItem);
+// connect(m_delegateModel, &QQmlInstanceModel::destroyingItem, this, &QDeclarativeGeoMapItemView::destroyingItem);
+// connect(m_delegateModel, &QQmlInstanceModel::initItem, this, &QDeclarativeGeoMapItemView::initItem);
}
void QDeclarativeGeoMapItemView::destroyingItem(QObject */*object*/)
@@ -156,16 +156,21 @@ void QDeclarativeGeoMapItemView::createdItem(int index, QObject */*object*/)
// createdItem is emitted on asynchronous creation. In which case, object has to be invoked again.
// See QQmlDelegateModel::object for further info.
- if (m_incubationMode == QQmlIncubator::Synchronous) {
- qWarning() << "createdItem invoked on Synchronous incubation";
+ // DelegateModel apparently triggers this method in any case, that is:
+ // 1. Synchronous incubation, delegate instantiated on the first object() call (during the object() call!)
+ // 2. Async incubation, delegate not instantiated on the first object() call
+ // 3. Async incubation, delegate present in the cache, and returned on the first object() call.
+ // createdItem also called during the object() call.
+ if (m_creatingObject) {
+ // Falling into case 1. or 3. Returning early to prevent double referencing the delegate instance.
return;
}
QQuickItem *item = qobject_cast<QQuickItem *>(m_delegateModel->object(index, m_incubationMode));
if (item)
- addDelegateToMap(item, index);
+ addDelegateToMap(item, index, true);
else
- qWarning() << "createdItem for " << index << " produced a null item";
+ qWarning() << "QQmlDelegateModel:: object called in createdItem for " << index << " produced a null item";
}
void QDeclarativeGeoMapItemView::modelUpdated(const QQmlChangeSet &changeSet, bool reset)
@@ -189,9 +194,12 @@ void QDeclarativeGeoMapItemView::modelUpdated(const QQmlChangeSet &changeSet, bo
}
}
+ QBoolBlocker createBlocker(m_creatingObject, true);
for (const QQmlChangeSet::Change &c: changeSet.inserts()) {
- for (int idx = c.start(); idx < c.end(); idx++)
- addDelegateToMap(qobject_cast<QQuickItem *>(m_delegateModel->object(idx, m_incubationMode)), idx);
+ for (int idx = c.start(); idx < c.end(); idx++) {
+ QObject *delegateInstance = m_delegateModel->object(idx, m_incubationMode);
+ addDelegateToMap(qobject_cast<QQuickItem *>(delegateInstance), idx);
+ }
}
fitViewport();
@@ -316,8 +324,11 @@ void QDeclarativeGeoMapItemView::instantiateAllItems()
return;
// If here, m_delegateModel may contain data, but QQmlInstanceModel::object for each row hasn't been called yet.
- for (int i = 0; i < m_delegateModel->count(); i++)
- addDelegateToMap(qobject_cast<QQuickItem *>(m_delegateModel->object(i, m_incubationMode)), i);
+ QBoolBlocker createBlocker(m_creatingObject, true);
+ for (int i = 0; i < m_delegateModel->count(); i++) {
+ QObject *delegateInstance = m_delegateModel->object(i, m_incubationMode);
+ addDelegateToMap(qobject_cast<QQuickItem *>(delegateInstance), i);
+ }
fitViewport();
}
@@ -346,15 +357,12 @@ void QDeclarativeGeoMapItemView::removeDelegateFromMap(int index, bool transitio
{
if (index >= 0 && index < m_instantiatedItems.size()) {
QQuickItem *item = m_instantiatedItems.takeAt(index);
- if (!item) {
- if (m_incubatingItems.contains(index)) {
- // cancel request
- m_delegateModel->cancel(index);
- m_incubatingItems.remove(index);
- }
+ if (!item) { // not yet incubated
+ // Don't cancel incubation explicitly, as DelegateModel apparently takes care of incubating elements when the model
+ // remove those indices.
return;
}
- // item can be either a QDeclarativeGeoMapItemBase or a QDeclarativeGeoMapItemGroup
+ // item can be either a QDeclarativeGeoMapItemBase or a QDeclarativeGeoMapItemGroup (subclass)
if (m_exit && m_map && transition) {
transitionItemOut(item);
} else {
@@ -443,16 +451,14 @@ void QDeclarativeGeoMapItemView::exitTransitionFinished()
#endif
}
-void QDeclarativeGeoMapItemView::addItemToMap(QDeclarativeGeoMapItemBase *item, int index)
+void QDeclarativeGeoMapItemView::addItemToMap(QDeclarativeGeoMapItemBase *item, int index, bool createdItem)
{
- if (m_map && item) { // belonging to another map??
- if (item->quickMap() == m_map)
- return;
- }
+ if (m_map && item->quickMap() == m_map) // test for *item done in the caller
+ return;
if (m_map) {
- insertInstantiatedItem(index, item);
+ insertInstantiatedItem(index, item, createdItem);
item->setParentItem(this);
m_map->addMapItem(item);
if (m_enter) {
@@ -466,23 +472,21 @@ void QDeclarativeGeoMapItemView::addItemToMap(QDeclarativeGeoMapItemBase *item,
}
}
-void QDeclarativeGeoMapItemView::insertInstantiatedItem(int index, QQuickItem *o)
+void QDeclarativeGeoMapItemView::insertInstantiatedItem(int index, QQuickItem *o, bool createdItem)
{
- if (m_incubatingItems.contains(index)) {
- m_incubatingItems.remove(index);
+ if (createdItem)
m_instantiatedItems.replace(index, o);
- } else {
+ else
m_instantiatedItems.insert(index, o);
- }
}
-void QDeclarativeGeoMapItemView::addItemViewToMap(QDeclarativeGeoMapItemView *item, int index)
+void QDeclarativeGeoMapItemView::addItemViewToMap(QDeclarativeGeoMapItemView *item, int index, bool createdItem)
{
- if (!item || (m_map && item->quickMap() == m_map))
+ if (m_map && item->quickMap() == m_map) // test for *item done in the caller
return;
if (m_map) {
- insertInstantiatedItem(index, item);
+ insertInstantiatedItem(index, item, createdItem);
item->setParentItem(this);
m_map->addMapItemView(item);
if (m_enter) {
@@ -496,13 +500,13 @@ void QDeclarativeGeoMapItemView::addItemViewToMap(QDeclarativeGeoMapItemView *it
}
}
-void QDeclarativeGeoMapItemView::addItemGroupToMap(QDeclarativeGeoMapItemGroup *item, int index)
+void QDeclarativeGeoMapItemView::addItemGroupToMap(QDeclarativeGeoMapItemGroup *item, int index, bool createdItem)
{
- if (!item || (m_map && item->quickMap() == m_map))
+ if (m_map && item->quickMap() == m_map) // test for *item done in the caller
return;
if (m_map) {
- insertInstantiatedItem(index, item);
+ insertInstantiatedItem(index, item, createdItem);
item->setParentItem(this);
m_map->addMapItemGroup(item);
if (m_enter) {
@@ -516,28 +520,29 @@ void QDeclarativeGeoMapItemView::addItemGroupToMap(QDeclarativeGeoMapItemGroup *
}
}
-void QDeclarativeGeoMapItemView::addDelegateToMap(QQuickItem *object, int index)
+void QDeclarativeGeoMapItemView::addDelegateToMap(QQuickItem *object, int index, bool createdItem)
{
if (!object) {
- m_incubatingItems.insert(index);
- m_instantiatedItems.insert(index, nullptr);
+ if (!createdItem)
+ m_instantiatedItems.insert(index, nullptr); // insert placeholder
return;
}
QDeclarativeGeoMapItemBase *item = qobject_cast<QDeclarativeGeoMapItemBase *>(object);
if (item) { // else createdItem will be emitted.
- addItemToMap(item, index);
+ addItemToMap(item, index, createdItem);
return;
}
QDeclarativeGeoMapItemView *view = qobject_cast<QDeclarativeGeoMapItemView *>(object);
if (view) {
- addItemViewToMap(view, index);
+ addItemViewToMap(view, index, createdItem);
return;
}
QDeclarativeGeoMapItemGroup *group = qobject_cast<QDeclarativeGeoMapItemGroup *>(object);
if (group) {
- addItemGroupToMap(group, index);
+ addItemGroupToMap(group, index, createdItem);
return;
}
+ qWarning() << "addDelegateToMap called with a "<< object->metaObject()->className();
}
QT_END_NAMESPACE
diff --git a/src/location/declarativemaps/qdeclarativegeomapitemview_p.h b/src/location/declarativemaps/qdeclarativegeomapitemview_p.h
index 58ef2835..43ca685a 100644
--- a/src/location/declarativemaps/qdeclarativegeomapitemview_p.h
+++ b/src/location/declarativemaps/qdeclarativegeomapitemview_p.h
@@ -131,11 +131,11 @@ private:
void removeDelegateFromMap(QQuickItem *o);
void transitionItemOut(QQuickItem *o);
- void insertInstantiatedItem(int index, QQuickItem *o);
- void addItemToMap(QDeclarativeGeoMapItemBase *item, int index);
- void addItemViewToMap(QDeclarativeGeoMapItemView *item, int index);
- void addItemGroupToMap(QDeclarativeGeoMapItemGroup *item, int index);
- void addDelegateToMap(QQuickItem *object, int index);
+ void insertInstantiatedItem(int index, QQuickItem *o, bool createdItem);
+ void addItemToMap(QDeclarativeGeoMapItemBase *item, int index, bool createdItem);
+ void addItemViewToMap(QDeclarativeGeoMapItemView *item, int index, bool createdItem);
+ void addItemGroupToMap(QDeclarativeGeoMapItemGroup *item, int index, bool createdItem);
+ void addDelegateToMap(QQuickItem *object, int index, bool createdItem = false);
bool m_componentCompleted;
QQmlIncubator::IncubationMode m_incubationMode = QQmlIncubator::Asynchronous;
@@ -143,8 +143,8 @@ private:
QVariant m_itemModel;
QDeclarativeGeoMap *m_map;
QList<QQuickItem *> m_instantiatedItems;
- QSet<int> m_incubatingItems;
bool m_fitViewport;
+ bool m_creatingObject = false;
QQmlDelegateModel *m_delegateModel;
QQuickTransition *m_enter = nullptr;
QQuickTransition *m_exit = nullptr;
diff --git a/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp b/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp
index 70b4bc21..aeb7b718 100644
--- a/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp
+++ b/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp
@@ -400,7 +400,7 @@ QList<QList<QDoubleVector2D> > QGeoMapPolylineGeometry::clipPath(const QGeoMap &
// 2)
QList<QList<QDoubleVector2D> > clippedPaths;
- const QList<QDoubleVector2D> &visibleRegion = p.visibleGeometryExpanded();
+ const QList<QDoubleVector2D> &visibleRegion = p.projectableGeometry();
if (visibleRegion.size()) {
clippedPaths = clipLine(wrappedPath, visibleRegion);
@@ -507,6 +507,120 @@ void QGeoMapPolylineGeometry::updateSourcePoints(const QGeoMap &map,
pathToScreen(map, clippedPaths, leftBoundWrapped);
}
+// *** SCREEN CLIPPING *** //
+
+enum ClipPointType {
+ InsidePoint = 0x00,
+ LeftPoint = 0x01,
+ RightPoint = 0x02,
+ BottomPoint = 0x04,
+ TopPoint = 0x08
+};
+
+static inline int clipPointType(qreal x, qreal y, const QRectF &rect)
+{
+ int type = InsidePoint;
+ if (x < rect.left())
+ type |= LeftPoint;
+ else if (x > rect.right())
+ type |= RightPoint;
+ if (y < rect.top())
+ type |= TopPoint;
+ else if (y > rect.bottom())
+ type |= BottomPoint;
+ return type;
+}
+
+static void clipSegmentToRect(qreal x0, qreal y0, qreal x1, qreal y1,
+ const QRectF &clipRect,
+ QVector<qreal> &outPoints,
+ QVector<QPainterPath::ElementType> &outTypes)
+{
+ int type0 = clipPointType(x0, y0, clipRect);
+ int type1 = clipPointType(x1, y1, clipRect);
+ bool accept = false;
+
+ while (true) {
+ if (!(type0 | type1)) {
+ accept = true;
+ break;
+ } else if (type0 & type1) {
+ break;
+ } else {
+ qreal x = 0.0;
+ qreal y = 0.0;
+ int outsideType = type0 ? type0 : type1;
+
+ if (outsideType & BottomPoint) {
+ x = x0 + (x1 - x0) * (clipRect.bottom() - y0) / (y1 - y0);
+ y = clipRect.bottom() - 0.1;
+ } else if (outsideType & TopPoint) {
+ x = x0 + (x1 - x0) * (clipRect.top() - y0) / (y1 - y0);
+ y = clipRect.top() + 0.1;
+ } else if (outsideType & RightPoint) {
+ y = y0 + (y1 - y0) * (clipRect.right() - x0) / (x1 - x0);
+ x = clipRect.right() - 0.1;
+ } else if (outsideType & LeftPoint) {
+ y = y0 + (y1 - y0) * (clipRect.left() - x0) / (x1 - x0);
+ x = clipRect.left() + 0.1;
+ }
+
+ if (outsideType == type0) {
+ x0 = x;
+ y0 = y;
+ type0 = clipPointType(x0, y0, clipRect);
+ } else {
+ x1 = x;
+ y1 = y;
+ type1 = clipPointType(x1, y1, clipRect);
+ }
+ }
+ }
+
+ if (accept) {
+ if (outPoints.size() >= 2) {
+ qreal lastX, lastY;
+ lastY = outPoints.at(outPoints.size() - 1);
+ lastX = outPoints.at(outPoints.size() - 2);
+
+ if (!qFuzzyCompare(lastY, y0) || !qFuzzyCompare(lastX, x0)) {
+ outTypes << QPainterPath::MoveToElement;
+ outPoints << x0 << y0;
+ }
+ } else {
+ outTypes << QPainterPath::MoveToElement;
+ outPoints << x0 << y0;
+ }
+
+ outTypes << QPainterPath::LineToElement;
+ outPoints << x1 << y1;
+ }
+}
+
+static void clipPathToRect(const QVector<qreal> &points,
+ const QVector<QPainterPath::ElementType> &types,
+ const QRectF &clipRect,
+ QVector<qreal> &outPoints,
+ QVector<QPainterPath::ElementType> &outTypes)
+{
+ outPoints.clear();
+ outPoints.reserve(points.size());
+ outTypes.clear();
+ outTypes.reserve(types.size());
+
+ qreal lastX = 0;
+ qreal lastY = 0; // or else used uninitialized
+ for (int i = 0; i < types.size(); ++i) {
+ if (i > 0 && types[i] != QPainterPath::MoveToElement) {
+ qreal x = points[i * 2], y = points[i * 2 + 1];
+ clipSegmentToRect(lastX, lastY, x, y, clipRect, outPoints, outTypes);
+ }
+
+ lastX = points[i * 2];
+ lastY = points[i * 2 + 1];
+ }
+}
+
////////////////////////////////////////////////////////////////////////////
/*!
@@ -526,9 +640,24 @@ void QGeoMapPolylineGeometry::updateScreenPoints(const QGeoMap &map,
return;
}
- // The geometry has already been clipped against the visible region projection in wrapped mercator space.
- QVector<qreal> points = srcPoints_;
- QVector<QPainterPath::ElementType> types = srcPointTypes_;
+ // Create the viewport rect in the same coordinate system
+ // as the actual points
+ QRectF viewport(0, 0, map.viewportWidth(), map.viewportHeight());
+ viewport.adjust(-strokeWidth, -strokeWidth, strokeWidth, strokeWidth);
+ viewport.translate(-1 * origin);
+
+ QVector<qreal> points;
+ QVector<QPainterPath::ElementType> types;
+
+ if (clipToViewport_) {
+ // Although the geometry has already been clipped against the visible region in wrapped mercator space.
+ // This is currently still needed to prevent a number of artifacts deriving from QTriangulatingStroker processing
+ // very large lines (that is, polylines that span many pixels in screen space)
+ clipPathToRect(srcPoints_, srcPointTypes_, viewport, points, types);
+ } else {
+ points = srcPoints_;
+ types = srcPointTypes_;
+ }
QVectorPath vp(points.data(), types.size(), types.data());
QTriangulatingStroker ts;
diff --git a/src/location/doc/src/qtlocation-qml.qdoc b/src/location/doc/src/qtlocation-qml.qdoc
index 38f43ef1..90f19c5a 100644
--- a/src/location/doc/src/qtlocation-qml.qdoc
+++ b/src/location/doc/src/qtlocation-qml.qdoc
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
@@ -26,83 +26,103 @@
****************************************************************************/
/*!
- \qmlmodule QtLocation 5.11
+ \qmlmodule QtLocation \QtVer
\title Qt Location QML Types
\ingroup qmlmodules
- \brief Provides QML types for mapping and location information
+ \brief Provides QML types for mapping and location information.
-\section1 Overview
+ \section1 Overview
-Provided that a position has been obtained, this module can add a
-\l{QtLocation::Map}{Map} with Places of Interest (POI) and
-\l{QtLocation::Place}{Places}. The user can be made aware of nearby features
-and related information, displayed graphically. Features on the \l Map can be
-places of business, entertainment, and so on. They may include paths, roads,
-or forms of transport, enabling navigation optimization and assistance.
+ Provided that a position has been obtained, the Qt Location module
+ can add a \l{QtLocation::}{Map} with Places of Interest (POI) and
+ \l{QtLocation::Place}{Places}. The user can be made aware of nearby
+ features and related information, displayed on the map. These features
+ can be places of business, entertainment, and so on. They may include
+ paths, roads, or forms of transport, enabling navigation optimization
+ and assistance.
-To perform navigation we need \l {Route}s from start to destination. These routes
-are made up of segments, where each \l {QtLocation::RouteSegment}{RouteSegment}
-can be considered a navigation subtask: drive 100 meters, turn left. The beginning and
-end of each segment is a \e waypoint, that is, one part of our journey.
+ To perform navigation we need \l {Route}s from start to destination.
+ These routes are made up of segments, where each \l {QtLocation::}
+ {RouteSegment} can be considered a navigation subtask; for example,
+ "drive 100 meters", or "turn left". The beginning and end of each
+ segment is a \e waypoint, that is, one part of the journey.
-A typical use case for the API is a user looking for a particular type of
-place, say a restaurant. The user could enter a search string into the map
-application and respond to a list or display of results for restaurants
-"near" the device. The application could then be used to navigate to the
-restaurant using an optimized route that is aware of features in the
-environment that can help or hinder the journey. The navigation then
-proceeds with the user's progress monitored by means of the current
-\l Location. In the context of this API the map application would be aware
-of the location and size of various places and the location of the user.
-Plugins would supply the data required by the application to determine routes
-and navigation instructions. The \l Place types would hold information about the
-destination and surrounding objects including displayable representations.
-The \l Map type would enable this information to be displayed, panned,
-zoomed and so on. The \l Route would be determined by a plugin with each
-\l RouteSegment holding the navigation instructions guided by the updated
-current \l Location.
+ A typical use case for the API is a user looking for a particular type of
+ place, such as a restaurant; the user enters a search string into the map
+ application and is presented with a list of results for restaurants
+ "near" the device. The application can then be used to navigate to the
+ chosen destination using a route that is optimized according to features
+ in the environment that may help or hinder the journey. The navigation then
+ proceeds with the user's progress monitored by means of the current
+ location.
-\l {Plugin}s are a means of specifying which location-based service to use. For
-example, a plugin may allow connection to a provider's service that provides
-geocoding and routing information, which can be consumed by the application.
-There may be various GeoServices plugins for various tasks with some plugins
-providing more than one service. One QML \l Plugin must be created for each
-required GeoService plugin. Plugins are required for maps, routing and geocoding,
-and places, however the default plugin handles all four of these services. A plugin may
-require online access or may support on-board maps and data.
+ In short, the main QML types and their roles are as follows:
-\note Plugins may not provide features such as paging or relevance hints.
+ \list
-The following links provide more detailed information about maps and places:
+ \li The \l [QML] Place instances hold information about the
+ destination and surrounding objects, including displayable
+ representations.
-\table
- \row
- \li \l {Maps and Navigation (QML)}{Maps and Navigation}
- \li Displaying maps and finding routes.
- \row
- \li \l {QML PLaces API} {Places}
- \li Searching for and managing points of interest.
-\endtable
+ \li The \l [QML] Map enables the information contained in
+ \l [QML] {Place} objects to be displayed, panned, zoomed,
+ and so on.
-\section1 Common QML Types
+ \li The \l [QML] Route is be determined by a \e plugin, with each
+ \l [QML] RouteSegment holding the navigation instructions,
+ guided by the continuously updated current \l [QML] Location.
-\annotatedlist qml-QtLocation5-common
+ \endlist
-\section1 Maps QML Types
+ \section2 Plugins
-\annotatedlist qml-QtLocation5-maps
+ \l {Plugin}s supply the data required to calculate routes and navigation
+ instructions, and they are typically tied to a specific location-based
+ service. For example, a plugin may allow connecting to a service that
+ provides geocoding and routing information, which can be consumed by the
+ application.
-\section1 Navigation and Routing QML Types
+ There may be various GeoServices plugins for various tasks, with some
+ plugins providing more than one service. One QML \l Plugin instance must
+ be created for each GeoService plugin. Plugins are required for routing
+ and geocoding, maps, and places, however the default plugin handles all
+ four of these services. A plugin may require online access or it may
+ support on-board maps and data.
-\annotatedlist qml-QtLocation5-routing
+ \note Plugins may not provide features such as paging or relevance hints.
-\section1 Geocoding QML Types
+ \section2 Related Information
-\annotatedlist qml-QtLocation5-geocoding
+ The following links provide more information about maps and places:
-\section1 Places QML Types
+ \table
+ \row
+ \li \l {Maps and Navigation (QML)}{Maps and Navigation}
+ \li Displaying maps and finding routes
+ \row
+ \li \l {QML Places API} {Places}
+ \li Searching for and managing points of interest
+ \endtable
-\annotatedlist qml-QtLocation5-places
+ \section1 Common QML Types
-\section1 Alphabetical Listing of All QML Types
+ \annotatedlist qml-QtLocation5-common
+
+ \section1 Maps QML Types
+
+ \annotatedlist qml-QtLocation5-maps
+
+ \section1 Navigation and Routing QML Types
+
+ \annotatedlist qml-QtLocation5-routing
+
+ \section1 Geocoding QML Types
+
+ \annotatedlist qml-QtLocation5-geocoding
+
+ \section1 Places QML Types
+
+ \annotatedlist qml-QtLocation5-places
+
+ \section1 Alphabetical Listing of All QML Types
*/
diff --git a/src/location/doc/src/qtlocation.qdoc b/src/location/doc/src/qtlocation.qdoc
index 77c2cd99..059d03f2 100644
--- a/src/location/doc/src/qtlocation.qdoc
+++ b/src/location/doc/src/qtlocation.qdoc
@@ -87,10 +87,10 @@ The Qt Location API enables you to:
To load the Qt Location module, add the following statement to your .qml files
-\code
- import QtPositioning 5.11
- import QtLocation 5.11
-\endcode
+\qml \QtVer
+import QtPositioning \1
+import QtLocation \1
+\endqml
The QtLocation QML module depends on the QtPositioning QML module.
Therefore every QML application that imports the QtLocation QML module must always
diff --git a/src/location/labs/qdeclarativenavigator.cpp b/src/location/labs/qdeclarativenavigator.cpp
index 770f0dd3..a8cb788b 100644
--- a/src/location/labs/qdeclarativenavigator.cpp
+++ b/src/location/labs/qdeclarativenavigator.cpp
@@ -308,15 +308,15 @@ bool QDeclarativeNavigator::navigatorReady() const
bool QDeclarativeNavigator::trackPositionSource() const
{
- return d_ptr->m_trackPositionSource;
+ return d_ptr->m_params->m_trackPositionSource;
}
void QDeclarativeNavigator::setTrackPositionSource(bool trackPositionSource)
{
- if (trackPositionSource == d_ptr->m_trackPositionSource)
+ if (trackPositionSource == d_ptr->m_params->m_trackPositionSource)
return;
- d_ptr->m_trackPositionSource = trackPositionSource;
+ d_ptr->m_params->m_trackPositionSource = trackPositionSource;
emit trackPositionSourceChanged(trackPositionSource);
}
@@ -427,6 +427,7 @@ bool QDeclarativeNavigator::ensureEngine()
d_ptr->m_active = active;
emit activeChanged(active);
});
+ connect(this, &QDeclarativeNavigator::trackPositionSourceChanged, d_ptr->m_navigator.get(), &QAbstractNavigator::setTrackPosition);
emit navigatorReadyChanged(true);
return true;
}
diff --git a/src/location/labs/qdeclarativenavigator_p_p.h b/src/location/labs/qdeclarativenavigator_p_p.h
index 2ac6806b..7d043436 100644
--- a/src/location/labs/qdeclarativenavigator_p_p.h
+++ b/src/location/labs/qdeclarativenavigator_p_p.h
@@ -74,6 +74,7 @@ public:
QGeoRoute m_geoRoute;
QPointer<QDeclarativePositionSource> m_positionSource;
QList<QPointer<QGeoMapParameter>> m_parameters;
+ bool m_trackPositionSource = true;
};
class QDeclarativeNavigatorPrivate
@@ -92,7 +93,6 @@ public:
bool m_active = false;
bool m_completed = false;
bool m_ready = false;
- bool m_trackPositionSource = true;
};
QT_END_NAMESPACE
diff --git a/src/location/maps/qgeoprojection.cpp b/src/location/maps/qgeoprojection.cpp
index a456f80e..7961ec70 100644
--- a/src/location/maps/qgeoprojection.cpp
+++ b/src/location/maps/qgeoprojection.cpp
@@ -624,7 +624,8 @@ void QGeoProjectionWebMercator::setupCamera()
m_viewMercator = m_eyeMercator - m_centerMercator;
m_upMercator = QDoubleVector3D::normal(m_viewMercator, m_sideMercator);
- m_nearPlaneMercator = 1.0 / m_sideLength;
+ m_nearPlaneMercator = 0.000002; // this value works until ZL 18. Above that, a better progressive formula is needed, or
+ // else, this clips too much.
double aspectRatio = 1.0 * m_viewportWidth / m_viewportHeight;
diff --git a/src/location/maps/qgeoserviceprovider.cpp b/src/location/maps/qgeoserviceprovider.cpp
index 11b1c28d..c6b9d742 100644
--- a/src/location/maps/qgeoserviceprovider.cpp
+++ b/src/location/maps/qgeoserviceprovider.cpp
@@ -534,9 +534,13 @@ QPlaceManager *QGeoServiceProvider::placeManager() const
*/
QNavigationManager *QGeoServiceProvider::navigationManager() const
{
- return d_ptr->manager<QNavigationManager, QNavigationManagerEngine>(
+ QNavigationManager * mgr = d_ptr->manager<QNavigationManager, QNavigationManagerEngine>(
&(d_ptr->navigationError), &(d_ptr->navigationErrorString),
&(d_ptr->navigationManager));
+ if (!mgr) {
+ qDebug() << d_ptr->navigationError << d_ptr->navigationErrorString;
+ }
+ return mgr;
}
/*!
@@ -747,6 +751,11 @@ void QGeoServiceProviderPrivate::loadPlugin(const QVariantMap &parameters)
// load the actual plugin
QObject *instance = loader()->instance(idx);
+ if (!instance) {
+ error = QGeoServiceProvider::LoaderError;
+ errorString = QLatin1String("loader()->instance(idx) failed to return an instance");
+ return;
+ }
factoryV3 = qobject_cast<QGeoServiceProviderFactoryV3 *>(instance);
if (!factoryV3) {
factoryV2 = qobject_cast<QGeoServiceProviderFactoryV2 *>(instance);
diff --git a/src/location/maps/qgeoserviceprovider.h b/src/location/maps/qgeoserviceprovider.h
index 8e594977..b2e0be05 100644
--- a/src/location/maps/qgeoserviceprovider.h
+++ b/src/location/maps/qgeoserviceprovider.h
@@ -69,7 +69,8 @@ public:
NotSupportedError,
UnknownParameterError,
MissingRequiredParameterError,
- ConnectionError
+ ConnectionError,
+ LoaderError
};
enum RoutingFeature {
diff --git a/src/location/maps/qnavigationmanagerengine.cpp b/src/location/maps/qnavigationmanagerengine.cpp
index 1f82b4a1..770e30a6 100644
--- a/src/location/maps/qnavigationmanagerengine.cpp
+++ b/src/location/maps/qnavigationmanagerengine.cpp
@@ -54,7 +54,6 @@ class QAbstractNavigatorPrivate
public:
QLocale locale;
QLocale::MeasurementSystem measurementSystem;
- bool initialized = false;
};
QAbstractNavigator::QAbstractNavigator(QObject *parent)
diff --git a/src/location/maps/qnavigationmanagerengine_p.h b/src/location/maps/qnavigationmanagerengine_p.h
index d43e4842..4ac459cc 100644
--- a/src/location/maps/qnavigationmanagerengine_p.h
+++ b/src/location/maps/qnavigationmanagerengine_p.h
@@ -82,6 +82,7 @@ public:
public slots:
virtual bool start() = 0;
virtual bool stop() = 0;
+ virtual void setTrackPosition(bool trackPosition) = 0;
signals:
// These must be emitted by the engine