169void QDeclarativeGeoMapQuickItem::geometryChange(
const QRectF &newGeometry,
const QRectF &oldGeometry)
171 if (!mapAndSourceItemSet_ || updatingGeometry_ ||
172 newGeometry.topLeft() == oldGeometry.topLeft()) {
173 QDeclarativeGeoMapItemBase::geometryChange(newGeometry, oldGeometry);
177 QGeoCoordinate newCoordinate = map()->geoProjection().
178 itemPositionToCoordinate(QDoubleVector2D(x(), y()) + QDoubleVector2D(anchorPoint_),
false);
180 if (newCoordinate.isValid())
181 setCoordinate(newCoordinate);
330void QDeclarativeGeoMapQuickItem::updatePolish()
332 if (!quickMap() && sourceItem_) {
333 mapAndSourceItemSet_ =
false;
334 sourceItem_.data()->setParentItem(0);
338 if (!quickMap() || !map() || !sourceItem_) {
339 mapAndSourceItemSet_ =
false;
343 if (!mapAndSourceItemSet_ && quickMap() && map() && sourceItem_) {
344 mapAndSourceItemSet_ =
true;
345 sourceItem_.data()->setParentItem(opacityContainer_);
346 sourceItem_.data()->setTransformOrigin(QQuickItem::TopLeft);
347 connect(sourceItem_.data(), &QQuickItem::xChanged,
348 this, &QDeclarativeGeoMapQuickItem::polishAndUpdate);
349 connect(sourceItem_.data(), &QQuickItem::yChanged,
350 this, &QDeclarativeGeoMapQuickItem::polishAndUpdate);
351 connect(sourceItem_.data(), &QQuickItem::widthChanged,
352 this, &QDeclarativeGeoMapQuickItem::polishAndUpdate);
353 connect(sourceItem_.data(), &QQuickItem::heightChanged,
354 this, &QDeclarativeGeoMapQuickItem::polishAndUpdate);
357 if (!coordinate_.isValid()) {
358 opacityContainer_->setVisible(
false);
361 opacityContainer_->setVisible(
true);
364 QScopedValueRollback<
bool> rollback(updatingGeometry_);
365 updatingGeometry_ =
true;
367 opacityContainer_->setOpacity(zoomLevelOpacity());
369 setWidth(sourceItem_.data()->width());
370 setHeight(sourceItem_.data()->height());
371 if (zoomLevel_ != 0.0
372 && map()->geoProjection().projectionType() == QGeoProjection::ProjectionWebMercator) {
373 const QGeoProjectionWebMercator &p =
static_cast<
const QGeoProjectionWebMercator&>(map()->geoProjection());
376 matrix_ =
new QMapQuickItemMatrix4x4(
this);
377 matrix_->appendToItem(opacityContainer_);
379 matrix_->setMatrix(p.quickItemTransformation(coordinate(), anchorPoint_, zoomLevel_));
380 setPosition(QPointF(0,0));
382 if (map()->geoProjection().projectionType() == QGeoProjection::ProjectionWebMercator) {
383 const QGeoProjectionWebMercator &p =
static_cast<
const QGeoProjectionWebMercator&>(map()->geoProjection());
384 if (map()->cameraData().tilt() > 0.0
385 && !p.isProjectable(p.geoToWrappedMapProjection(coordinate()))) {
388 matrix_ =
new QMapQuickItemMatrix4x4(
this);
389 matrix_->appendToItem(opacityContainer_);
391 matrix_->setMatrix(p.quickItemTransformation(coordinate(), anchorPoint_, map()->cameraData().zoomLevel()));
392 setPosition(QPointF(0,0));
395 matrix_->setMatrix(QMatrix4x4());
396 setPositionOnMap(coordinate(), anchorPoint_);
399 if (map()->cameraData().tilt() > 0.0
400 && qIsNaN(map()->geoProjection().coordinateToItemPosition(coordinate(),
false).x())) {
401 opacityContainer_->setVisible(
false);
404 matrix_->setMatrix(QMatrix4x4());
405 setPositionOnMap(coordinate(), anchorPoint_);