168void QDeclarativeGeoMapQuickItem::geometryChange(
const QRectF &newGeometry,
const QRectF &oldGeometry)
170 if (!mapAndSourceItemSet_ || updatingGeometry_ ||
171 newGeometry.topLeft() == oldGeometry.topLeft()) {
172 QDeclarativeGeoMapItemBase::geometryChange(newGeometry, oldGeometry);
176 QGeoCoordinate newCoordinate = map()->geoProjection().
177 itemPositionToCoordinate(QDoubleVector2D(x(), y()) + QDoubleVector2D(anchorPoint_),
false);
179 if (newCoordinate.isValid())
180 setCoordinate(newCoordinate);
329void QDeclarativeGeoMapQuickItem::updatePolish()
331 if (!quickMap() && sourceItem_) {
332 mapAndSourceItemSet_ =
false;
333 sourceItem_.data()->setParentItem(0);
337 if (!quickMap() || !map() || !sourceItem_) {
338 mapAndSourceItemSet_ =
false;
342 if (!mapAndSourceItemSet_ && quickMap() && map() && sourceItem_) {
343 mapAndSourceItemSet_ =
true;
344 sourceItem_.data()->setParentItem(opacityContainer_);
345 sourceItem_.data()->setTransformOrigin(QQuickItem::TopLeft);
346 connect(sourceItem_.data(), &QQuickItem::xChanged,
347 this, &QDeclarativeGeoMapQuickItem::polishAndUpdate);
348 connect(sourceItem_.data(), &QQuickItem::yChanged,
349 this, &QDeclarativeGeoMapQuickItem::polishAndUpdate);
350 connect(sourceItem_.data(), &QQuickItem::widthChanged,
351 this, &QDeclarativeGeoMapQuickItem::polishAndUpdate);
352 connect(sourceItem_.data(), &QQuickItem::heightChanged,
353 this, &QDeclarativeGeoMapQuickItem::polishAndUpdate);
356 if (!coordinate_.isValid()) {
357 opacityContainer_->setVisible(
false);
360 opacityContainer_->setVisible(
true);
363 QScopedValueRollback<
bool> rollback(updatingGeometry_);
364 updatingGeometry_ =
true;
366 opacityContainer_->setOpacity(zoomLevelOpacity());
368 setWidth(sourceItem_.data()->width());
369 setHeight(sourceItem_.data()->height());
370 if (zoomLevel_ != 0.0
371 && map()->geoProjection().projectionType() == QGeoProjection::ProjectionWebMercator) {
372 const QGeoProjectionWebMercator &p =
static_cast<
const QGeoProjectionWebMercator&>(map()->geoProjection());
375 matrix_ =
new QMapQuickItemMatrix4x4(
this);
376 matrix_->appendToItem(opacityContainer_);
378 matrix_->setMatrix(p.quickItemTransformation(coordinate(), anchorPoint_, zoomLevel_));
379 setPosition(QPointF(0,0));
381 if (map()->geoProjection().projectionType() == QGeoProjection::ProjectionWebMercator) {
382 const QGeoProjectionWebMercator &p =
static_cast<
const QGeoProjectionWebMercator&>(map()->geoProjection());
383 if (map()->cameraData().tilt() > 0.0
384 && !p.isProjectable(p.geoToWrappedMapProjection(coordinate()))) {
387 matrix_ =
new QMapQuickItemMatrix4x4(
this);
388 matrix_->appendToItem(opacityContainer_);
390 matrix_->setMatrix(p.quickItemTransformation(coordinate(), anchorPoint_, map()->cameraData().zoomLevel()));
391 setPosition(QPointF(0,0));
394 matrix_->setMatrix(QMatrix4x4());
395 setPositionOnMap(coordinate(), anchorPoint_);
398 if (map()->cameraData().tilt() > 0.0
399 && qIsNaN(map()->geoProjection().coordinateToItemPosition(coordinate(),
false).x())) {
400 opacityContainer_->setVisible(
false);
403 matrix_->setMatrix(QMatrix4x4());
404 setPositionOnMap(coordinate(), anchorPoint_);