167void QDeclarativeGeoMapQuickItem::geometryChange(
const QRectF &newGeometry,
const QRectF &oldGeometry)
169 if (!mapAndSourceItemSet_ || updatingGeometry_ ||
170 newGeometry.topLeft() == oldGeometry.topLeft()) {
171 QDeclarativeGeoMapItemBase::geometryChange(newGeometry, oldGeometry);
175 QGeoCoordinate newCoordinate = map()->geoProjection().
176 itemPositionToCoordinate(QDoubleVector2D(x(), y()) + QDoubleVector2D(anchorPoint_),
false);
178 if (newCoordinate.isValid())
179 setCoordinate(newCoordinate);
328void QDeclarativeGeoMapQuickItem::updatePolish()
330 if (!quickMap() && sourceItem_) {
331 mapAndSourceItemSet_ =
false;
332 sourceItem_.data()->setParentItem(0);
336 if (!quickMap() || !map() || !sourceItem_) {
337 mapAndSourceItemSet_ =
false;
341 if (!mapAndSourceItemSet_ && quickMap() && map() && sourceItem_) {
342 mapAndSourceItemSet_ =
true;
343 sourceItem_.data()->setParentItem(opacityContainer_);
344 sourceItem_.data()->setTransformOrigin(QQuickItem::TopLeft);
345 connect(sourceItem_.data(), &QQuickItem::xChanged,
346 this, &QDeclarativeGeoMapQuickItem::polishAndUpdate);
347 connect(sourceItem_.data(), &QQuickItem::yChanged,
348 this, &QDeclarativeGeoMapQuickItem::polishAndUpdate);
349 connect(sourceItem_.data(), &QQuickItem::widthChanged,
350 this, &QDeclarativeGeoMapQuickItem::polishAndUpdate);
351 connect(sourceItem_.data(), &QQuickItem::heightChanged,
352 this, &QDeclarativeGeoMapQuickItem::polishAndUpdate);
355 if (!coordinate_.isValid()) {
356 opacityContainer_->setVisible(
false);
359 opacityContainer_->setVisible(
true);
362 QScopedValueRollback<
bool> rollback(updatingGeometry_);
363 updatingGeometry_ =
true;
365 opacityContainer_->setOpacity(zoomLevelOpacity());
367 setWidth(sourceItem_.data()->width());
368 setHeight(sourceItem_.data()->height());
369 if (zoomLevel_ != 0.0
370 && map()->geoProjection().projectionType() == QGeoProjection::ProjectionWebMercator) {
371 const QGeoProjectionWebMercator &p =
static_cast<
const QGeoProjectionWebMercator&>(map()->geoProjection());
374 matrix_ =
new QMapQuickItemMatrix4x4(
this);
375 matrix_->appendToItem(opacityContainer_);
377 matrix_->setMatrix(p.quickItemTransformation(coordinate(), anchorPoint_, zoomLevel_));
378 setPosition(QPointF(0,0));
380 if (map()->geoProjection().projectionType() == QGeoProjection::ProjectionWebMercator) {
381 const QGeoProjectionWebMercator &p =
static_cast<
const QGeoProjectionWebMercator&>(map()->geoProjection());
382 if (map()->cameraData().tilt() > 0.0
383 && !p.isProjectable(p.geoToWrappedMapProjection(coordinate()))) {
386 matrix_ =
new QMapQuickItemMatrix4x4(
this);
387 matrix_->appendToItem(opacityContainer_);
389 matrix_->setMatrix(p.quickItemTransformation(coordinate(), anchorPoint_, map()->cameraData().zoomLevel()));
390 setPosition(QPointF(0,0));
393 matrix_->setMatrix(QMatrix4x4());
394 setPositionOnMap(coordinate(), anchorPoint_);
397 if (map()->cameraData().tilt() > 0.0
398 && qIsNaN(map()->geoProjection().coordinateToItemPosition(coordinate(),
false).x())) {
399 opacityContainer_->setVisible(
false);
402 matrix_->setMatrix(QMatrix4x4());
403 setPositionOnMap(coordinate(), anchorPoint_);