summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/location/declarativemaps/qdeclarativegeomap.cpp23
-rw-r--r--src/location/declarativemaps/qdeclarativegeomap_p.h5
2 files changed, 20 insertions, 8 deletions
diff --git a/src/location/declarativemaps/qdeclarativegeomap.cpp b/src/location/declarativemaps/qdeclarativegeomap.cpp
index 604b0c46..8ab29c1a 100644
--- a/src/location/declarativemaps/qdeclarativegeomap.cpp
+++ b/src/location/declarativemaps/qdeclarativegeomap.cpp
@@ -159,12 +159,6 @@ QT_BEGIN_NAMESPACE
application should open the link in a browser or display its contents to the user.
*/
-/*!
- \qmlsignal QtLocation::Map::initialized()
-
- This signal is emitted when the initialization of the map is complete.
-*/
-
QDeclarativeGeoMap::QDeclarativeGeoMap(QQuickItem *parent)
: QQuickItem(parent),
m_plugin(0),
@@ -424,7 +418,7 @@ void QDeclarativeGeoMap::initialize()
if (fovHasChanged)
emit fieldOfViewChanged(m_cameraData.fieldOfView());
- emit initialized();
+ emit mapReadyChanged(true);
}
/*!
@@ -1330,6 +1324,21 @@ QColor QDeclarativeGeoMap::color() const
return m_color;
}
+/*!
+ \qmlproperty color QtLocation::Map::mapReady
+
+ This property holds whether the map has been successfully initialized and is ready to be used.
+ Some methods, such as \l fromCoordinate and \l toCoordinate, will not work before the map is ready.
+ Due to the architecture of the \l Map, it's advised to use the signal emitted for this property
+ in place of \l Component.onCompleted, to make sure that everything behaves as expected.
+
+ \since 5.9
+*/
+bool QDeclarativeGeoMap::mapReady() const
+{
+ return m_initialized;
+}
+
// TODO: offer the possibility to specify the margins.
void QDeclarativeGeoMap::fitViewportToGeoShape()
{
diff --git a/src/location/declarativemaps/qdeclarativegeomap_p.h b/src/location/declarativemaps/qdeclarativegeomap_p.h
index ab5732e4..da430ce5 100644
--- a/src/location/declarativemaps/qdeclarativegeomap_p.h
+++ b/src/location/declarativemaps/qdeclarativegeomap_p.h
@@ -99,6 +99,7 @@ class Q_LOCATION_PRIVATE_EXPORT QDeclarativeGeoMap : public QQuickItem
Q_PROPERTY(QGeoShape visibleRegion READ visibleRegion WRITE setVisibleRegion)
Q_PROPERTY(bool copyrightsVisible READ copyrightsVisible WRITE setCopyrightsVisible NOTIFY copyrightsVisibleChanged)
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
+ Q_PROPERTY(bool mapReady READ mapReady NOTIFY mapReadyChanged)
Q_INTERFACES(QQmlParserStatus)
public:
@@ -150,6 +151,8 @@ public:
void setColor(const QColor &color);
QColor color() const;
+ bool mapReady() const;
+
QQmlListProperty<QDeclarativeGeoMapType> supportedMapTypes();
Q_INVOKABLE void removeMapItem(QDeclarativeGeoMapItemBase *item);
@@ -202,7 +205,7 @@ Q_SIGNALS:
void maximumFieldOfViewChanged(qreal maximumFieldOfView);
void copyrightsChanged(const QImage &copyrightsImage);
void copyrightsChanged(const QString &copyrightsHtml);
- void initialized();
+ void mapReadyChanged(bool ready);
protected:
void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE ;