summaryrefslogtreecommitdiff
path: root/src/location
diff options
context:
space:
mode:
Diffstat (limited to 'src/location')
-rw-r--r--src/location/declarativemaps/qdeclarativegeocodemodel.cpp6
-rw-r--r--src/location/declarativemaps/qdeclarativegeomap.cpp25
-rw-r--r--src/location/declarativemaps/qdeclarativegeomapcopyrightsnotice.cpp21
-rw-r--r--src/location/declarativemaps/qdeclarativegeomapcopyrightsnotice_p.h1
-rw-r--r--src/location/declarativemaps/qdeclarativegeomapitemgroup.cpp12
-rw-r--r--src/location/declarativemaps/qdeclarativegeomapitemgroup_p.h5
-rw-r--r--src/location/declarativemaps/qdeclarativegeomapquickitem.cpp17
-rw-r--r--src/location/declarativemaps/qdeclarativegeoserviceprovider.cpp20
-rw-r--r--src/location/declarativemaps/qdeclarativegeoserviceprovider_p.h5
-rw-r--r--src/location/doc/src/plugins/mapbox.qdoc3
-rw-r--r--src/location/maps/qgeoprojection.cpp2
-rw-r--r--src/location/maps/qgeotiledmapscene.cpp2
12 files changed, 95 insertions, 24 deletions
diff --git a/src/location/declarativemaps/qdeclarativegeocodemodel.cpp b/src/location/declarativemaps/qdeclarativegeocodemodel.cpp
index d874f9a2..ee435a5a 100644
--- a/src/location/declarativemaps/qdeclarativegeocodemodel.cpp
+++ b/src/location/declarativemaps/qdeclarativegeocodemodel.cpp
@@ -69,9 +69,9 @@ QT_BEGIN_NAMESPACE
will update its output automatically. Otherwise, the \l{update} method may
be used. By default, autoUpdate is disabled.
- The data stored and returned in the GeocodeModel consists of \l{Location}
+ The data stored and returned in the GeocodeModel consists of \l [QML] {Location}
objects, as a list with the role name "locationData". See the documentation
- for \l{Location} for further details on its structure and contents.
+ for \l [QML] {Location} for further details on its structure and contents.
\section2 Example Usage
@@ -519,7 +519,7 @@ int QDeclarativeGeocodeModel::count() const
/*!
\qmlmethod Location QtLocation::GeocodeModel::get(int)
- Returns the Location at given index. Use \l count property to check the
+ Returns the \l [QML] {Location} at given index. Use \l count property to check the
amount of locations available. The locations are indexed from zero, so the accessible range
is 0...(count - 1).
diff --git a/src/location/declarativemaps/qdeclarativegeomap.cpp b/src/location/declarativemaps/qdeclarativegeomap.cpp
index 9f4dae3f..f5d2bdb5 100644
--- a/src/location/declarativemaps/qdeclarativegeomap.cpp
+++ b/src/location/declarativemaps/qdeclarativegeomap.cpp
@@ -1324,7 +1324,17 @@ QGeoShape QDeclarativeGeoMap::visibleRegion() const
for (const QDoubleVector2D &c: visibleRegion)
path.addCoordinate(m_map->geoProjection().wrappedMapProjectionToGeo(c));
- return path.boundingGeoRectangle();
+ QGeoRectangle vr = path.boundingGeoRectangle();
+
+ bool empty = vr.topLeft().latitude() == vr.bottomRight().latitude() ||
+ qFuzzyCompare(vr.topLeft().longitude(), vr.bottomRight().longitude()); // QTBUG-57690
+
+ if (empty) {
+ vr.setTopLeft(QGeoCoordinate(vr.topLeft().latitude(), -180));
+ vr.setBottomRight(QGeoCoordinate(vr.bottomRight().latitude(), 180));
+ }
+
+ return vr;
}
/*!
@@ -1831,9 +1841,7 @@ void QDeclarativeGeoMap::clearMapItems()
\qmlmethod void QtLocation::Map::addMapItemGroup(MapItemGroup itemGroup)
Adds the map items contained in the given \a itemGroup to the Map
- (for example MapQuickItem, MapCircle). These items will be reparented, and the map
- will be their new parent. Property bindings defined using \e{parent.} inside a MapItemGroup
- will therefore not work.
+ (for example MapQuickItem, MapCircle).
\sa MapItemGroup, removeMapItemGroup
@@ -1841,13 +1849,11 @@ void QDeclarativeGeoMap::clearMapItems()
*/
void QDeclarativeGeoMap::addMapItemGroup(QDeclarativeGeoMapItemGroup *itemGroup)
{
- if (!itemGroup)
+ if (!itemGroup || itemGroup->quickMap()) // || Already added to some map
return;
+ itemGroup->setQuickMap(this);
QPointer<QDeclarativeGeoMapItemGroup> g(itemGroup);
- if (m_mapItemGroups.contains(g))
- return;
-
m_mapItemGroups.append(g);
const QList<QQuickItem *> quickKids = g->childItems();
for (auto c: quickKids) {
@@ -1869,7 +1875,7 @@ void QDeclarativeGeoMap::addMapItemGroup(QDeclarativeGeoMapItemGroup *itemGroup)
*/
void QDeclarativeGeoMap::removeMapItemGroup(QDeclarativeGeoMapItemGroup *itemGroup)
{
- if (!itemGroup)
+ if (!itemGroup || itemGroup->quickMap() != this) // cant remove an itemGroup added to another map
return;
QPointer<QDeclarativeGeoMapItemGroup> g(itemGroup);
@@ -1882,6 +1888,7 @@ void QDeclarativeGeoMap::removeMapItemGroup(QDeclarativeGeoMapItemGroup *itemGro
if (mapItem)
removeMapItem(mapItem);
}
+ itemGroup->setQuickMap(nullptr);
itemGroup->setParentItem(0);
}
diff --git a/src/location/declarativemaps/qdeclarativegeomapcopyrightsnotice.cpp b/src/location/declarativemaps/qdeclarativegeomapcopyrightsnotice.cpp
index 1101eb18..1a8489eb 100644
--- a/src/location/declarativemaps/qdeclarativegeomapcopyrightsnotice.cpp
+++ b/src/location/declarativemaps/qdeclarativegeomapcopyrightsnotice.cpp
@@ -129,20 +129,29 @@ void QDeclarativeGeoMapCopyrightNotice::setMapSource(QDeclarativeGeoMap *mapSour
if (mapSource) {
m_mapSource = mapSource;
// First update the copyright. Only Image will do here, no need to store HTML right away.
- if (!mapSource->m_copyrights->m_copyrightsImage.isNull())
+ if (mapSource->m_copyrights && !mapSource->m_copyrights->m_copyrightsImage.isNull())
m_copyrightsImage = mapSource->m_copyrights->m_copyrightsImage;
connect(m_mapSource, SIGNAL(copyrightsChanged(QImage)),
this, SLOT(copyrightsChanged(QImage)));
connect(m_mapSource, SIGNAL(copyrightsChanged(QString)),
this, SLOT(copyrightsChanged(QString)));
- connect(m_mapSource->m_map, SIGNAL(copyrightsStyleSheetChanged(QString)),
- this, SLOT(onCopyrightsStyleSheetChanged(QString)));
- connect(this, SIGNAL(linkActivated(QString)),
- m_mapSource, SIGNAL(copyrightLinkActivated(QString)));
- onCopyrightsStyleSheetChanged(m_mapSource->m_map->copyrightsStyleSheet());
+ if (m_mapSource->m_map)
+ connectMap();
+ else
+ connect(m_mapSource, &QDeclarativeGeoMap::mapReadyChanged, this, &QDeclarativeGeoMapCopyrightNotice::connectMap);
}
+}
+
+void QDeclarativeGeoMapCopyrightNotice::connectMap()
+{
+ connect(m_mapSource->m_map, SIGNAL(copyrightsStyleSheetChanged(QString)),
+ this, SLOT(onCopyrightsStyleSheetChanged(QString)));
+ connect(this, SIGNAL(linkActivated(QString)),
+ m_mapSource, SIGNAL(copyrightLinkActivated(QString)));
+
+ onCopyrightsStyleSheetChanged(m_mapSource->m_map->copyrightsStyleSheet());
update();
emit mapSourceChanged();
diff --git a/src/location/declarativemaps/qdeclarativegeomapcopyrightsnotice_p.h b/src/location/declarativemaps/qdeclarativegeomapcopyrightsnotice_p.h
index b09d7c1d..0d7f7a20 100644
--- a/src/location/declarativemaps/qdeclarativegeomapcopyrightsnotice_p.h
+++ b/src/location/declarativemaps/qdeclarativegeomapcopyrightsnotice_p.h
@@ -96,6 +96,7 @@ protected:
void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
void rasterizeHtmlAndUpdate();
+ void connectMap();
private:
void createCopyright();
diff --git a/src/location/declarativemaps/qdeclarativegeomapitemgroup.cpp b/src/location/declarativemaps/qdeclarativegeomapitemgroup.cpp
index ee382353..59aaaa26 100644
--- a/src/location/declarativemaps/qdeclarativegeomapitemgroup.cpp
+++ b/src/location/declarativemaps/qdeclarativegeomapitemgroup.cpp
@@ -135,7 +135,7 @@ QT_BEGIN_NAMESPACE
\image api-mapitemgroup.png
*/
-QDeclarativeGeoMapItemGroup::QDeclarativeGeoMapItemGroup(QQuickItem *parent): QQuickItem(parent)
+QDeclarativeGeoMapItemGroup::QDeclarativeGeoMapItemGroup(QQuickItem *parent): QQuickItem(parent), m_quickMap(nullptr)
{
}
@@ -145,4 +145,14 @@ QDeclarativeGeoMapItemGroup::~QDeclarativeGeoMapItemGroup()
}
+void QDeclarativeGeoMapItemGroup::setQuickMap(QDeclarativeGeoMap *quickMap)
+{
+ m_quickMap = quickMap;
+}
+
+QDeclarativeGeoMap *QDeclarativeGeoMapItemGroup::quickMap() const
+{
+ return m_quickMap;
+}
+
QT_END_NAMESPACE
diff --git a/src/location/declarativemaps/qdeclarativegeomapitemgroup_p.h b/src/location/declarativemaps/qdeclarativegeomapitemgroup_p.h
index 1b008d71..f91d291c 100644
--- a/src/location/declarativemaps/qdeclarativegeomapitemgroup_p.h
+++ b/src/location/declarativemaps/qdeclarativegeomapitemgroup_p.h
@@ -53,6 +53,7 @@
QT_BEGIN_NAMESPACE
+class QDeclarativeGeoMap;
class Q_LOCATION_PRIVATE_EXPORT QDeclarativeGeoMapItemGroup : public QQuickItem
{
Q_OBJECT
@@ -60,6 +61,10 @@ public:
explicit QDeclarativeGeoMapItemGroup(QQuickItem *parent = 0);
virtual ~QDeclarativeGeoMapItemGroup();
+ void setQuickMap(QDeclarativeGeoMap *quickMap);
+ QDeclarativeGeoMap *quickMap() const;
+private:
+ QDeclarativeGeoMap *m_quickMap;
};
QT_END_NAMESPACE
diff --git a/src/location/declarativemaps/qdeclarativegeomapquickitem.cpp b/src/location/declarativemaps/qdeclarativegeomapquickitem.cpp
index cb5cce9a..86d67cf8 100644
--- a/src/location/declarativemaps/qdeclarativegeomapquickitem.cpp
+++ b/src/location/declarativemaps/qdeclarativegeomapquickitem.cpp
@@ -393,9 +393,20 @@ void QDeclarativeGeoMapQuickItem::updatePolish()
matrix_->setMatrix(map()->geoProjection().quickItemTransformation(coordinate(), anchorPoint_, zoomLevel_));
setPosition(QPointF(0,0));
} else {
- if (matrix_)
- matrix_->setMatrix(QMatrix4x4());
- setPositionOnMap(coordinate(), anchorPoint_);
+ // if the coordinate is behind the camera, we use the transformation to get the item out of the way
+ if (map()->cameraData().tilt() > 0.0
+ && !map()->geoProjection().isProjectable(map()->geoProjection().geoToWrappedMapProjection(coordinate()))) {
+ if (!matrix_) {
+ matrix_ = new QMapQuickItemMatrix4x4(this);
+ matrix_->appendToItem(opacityContainer_);
+ }
+ matrix_->setMatrix(map()->geoProjection().quickItemTransformation(coordinate(), anchorPoint_, map()->cameraData().zoomLevel()));
+ setPosition(QPointF(0,0));
+ } else {
+ if (matrix_)
+ matrix_->setMatrix(QMatrix4x4());
+ setPositionOnMap(coordinate(), anchorPoint_);
+ }
}
}
diff --git a/src/location/declarativemaps/qdeclarativegeoserviceprovider.cpp b/src/location/declarativemaps/qdeclarativegeoserviceprovider.cpp
index 54f70c11..4b8b2d7c 100644
--- a/src/location/declarativemaps/qdeclarativegeoserviceprovider.cpp
+++ b/src/location/declarativemaps/qdeclarativegeoserviceprovider.cpp
@@ -36,6 +36,7 @@
#include "qdeclarativegeoserviceprovider_p.h"
#include <QtQml/QQmlInfo>
+#include <QtQml/QQmlEngine>
QT_BEGIN_NAMESPACE
@@ -399,6 +400,19 @@ QDeclarativeGeoServiceProviderRequirements *QDeclarativeGeoServiceProvider::requ
return required_;
}
+void QDeclarativeGeoServiceProvider::setRequirements(QDeclarativeGeoServiceProviderRequirements *req)
+{
+ if (!name().isEmpty() || !req)
+ return;
+
+ if (required_ && *required_ == *req)
+ return;
+
+ delete required_;
+ required_ = req;
+ QQmlEngine::setObjectOwnership(req, QQmlEngine::CppOwnership); // To prevent the engine from making this object disappear
+}
+
/*!
\qmlproperty stringlist Plugin::preferred
@@ -732,6 +746,12 @@ bool QDeclarativeGeoServiceProviderRequirements::matches(const QGeoServiceProvid
return true;
}
+bool QDeclarativeGeoServiceProviderRequirements::operator == (const QDeclarativeGeoServiceProviderRequirements &rhs) const
+{
+ return (mapping_ == rhs.mapping_ && routing_ == rhs.routing_
+ && geocoding_ == rhs.geocoding_ && places_ == rhs.places_);
+}
+
/*******************************************************************************
*******************************************************************************/
diff --git a/src/location/declarativemaps/qdeclarativegeoserviceprovider_p.h b/src/location/declarativemaps/qdeclarativegeoserviceprovider_p.h
index bcf67124..426c6b4d 100644
--- a/src/location/declarativemaps/qdeclarativegeoserviceprovider_p.h
+++ b/src/location/declarativemaps/qdeclarativegeoserviceprovider_p.h
@@ -100,7 +100,7 @@ class Q_LOCATION_PRIVATE_EXPORT QDeclarativeGeoServiceProvider : public QObject,
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
Q_PROPERTY(QStringList availableServiceProviders READ availableServiceProviders CONSTANT)
Q_PROPERTY(QQmlListProperty<QDeclarativeGeoServiceProviderParameter> parameters READ parameters)
- Q_PROPERTY(QDeclarativeGeoServiceProviderRequirements *required READ requirements)
+ Q_PROPERTY(QDeclarativeGeoServiceProviderRequirements *required READ requirements WRITE setRequirements)
Q_PROPERTY(QStringList locales READ locales WRITE setLocales NOTIFY localesChanged)
Q_PROPERTY(QStringList preferred READ preferred WRITE setPreferred NOTIFY preferredChanged)
Q_PROPERTY(bool allowExperimental READ allowExperimental WRITE setAllowExperimental NOTIFY allowExperimentalChanged)
@@ -182,6 +182,7 @@ public:
QStringList availableServiceProviders();
QDeclarativeGeoServiceProviderRequirements *requirements() const;
+ void setRequirements(QDeclarativeGeoServiceProviderRequirements *req);
QStringList preferred() const;
void setPreferred(const QStringList &val);
@@ -259,6 +260,8 @@ public:
Q_INVOKABLE bool matches(const QGeoServiceProvider *provider) const;
+ bool operator == (const QDeclarativeGeoServiceProviderRequirements &rhs) const;
+
Q_SIGNALS:
void mappingRequirementsChanged(const QDeclarativeGeoServiceProvider::MappingFeatures &features);
void routingRequirementsChanged(const QDeclarativeGeoServiceProvider::RoutingFeatures &features);
diff --git a/src/location/doc/src/plugins/mapbox.qdoc b/src/location/doc/src/plugins/mapbox.qdoc
index e962bead..8f83ae55 100644
--- a/src/location/doc/src/plugins/mapbox.qdoc
+++ b/src/location/doc/src/plugins/mapbox.qdoc
@@ -70,6 +70,9 @@ The following table lists optional parameters that can be passed to the Mapbox p
\li \l{https://www.mapbox.com/help/define-map-id/}{ID} of the Mapbox map to show. An example ID is "examples.map-zr0njcqy".
If this parameter is present, the specified map type will be used by default, unless another is selected.
If not present, the default Mapbox map ID is "mapbox.streets".
+ \b{Note:} neither in this parameter nor in \b{mapbox.mapping.additional_map_ids} it is allowed to use repeated map_ids.
+ This includes the map_ids bundled in the plugin by default (documented \l{https://www.mapbox.com/api-documentation/#maps}{here} under
+ \b{Mapbox classic map IDs}). Failing to do so will cause tile cache corruption.
\row
\li mapbox.mapping.additional_map_ids
\li Additional, comma separated, Mapbox map IDs to be added to the available map types.
diff --git a/src/location/maps/qgeoprojection.cpp b/src/location/maps/qgeoprojection.cpp
index 319bf906..783193ed 100644
--- a/src/location/maps/qgeoprojection.cpp
+++ b/src/location/maps/qgeoprojection.cpp
@@ -254,7 +254,7 @@ QGeoCoordinate QGeoProjectionWebMercator::wrappedMapProjectionToGeo(const QDoubl
return mapProjectionToGeo(unwrapMapProjection(wrappedProjection));
}
-QMatrix4x4 QGeoProjectionWebMercator::quickItemTransformation(const QGeoCoordinate &coordinate, const QPointF &anchorPoint, double zoomLevel) const
+QMatrix4x4 QGeoProjectionWebMercator::quickItemTransformation(const QGeoCoordinate &coordinate, const QPointF &anchorPoint, qreal zoomLevel) const
{
const QDoubleVector2D coordWrapped = geoToWrappedMapProjection(coordinate);
double scale = std::pow(0.5, zoomLevel - m_cameraData.zoomLevel());
diff --git a/src/location/maps/qgeotiledmapscene.cpp b/src/location/maps/qgeotiledmapscene.cpp
index 422082fc..ab15e37b 100644
--- a/src/location/maps/qgeotiledmapscene.cpp
+++ b/src/location/maps/qgeotiledmapscene.cpp
@@ -609,6 +609,8 @@ void QGeoTiledMapRootNode::updateTiles(QGeoTiledMapTileContainerNode *root,
#if QT_CONFIG(opengl)
if (ogl)
static_cast<QSGDefaultImageNode *>(node)->setAnisotropyLevel(QSGTexture::Anisotropy16x);
+#else
+ Q_UNUSED(ogl)
#endif
dirtyBits |= QSGNode::DirtyMaterial;
}