166void QDeclarativeGeoMapQuickItem::geometryChange(
const QRectF &newGeometry,
const QRectF &oldGeometry)
168 if (!mapAndSourceItemSet_ || updatingGeometry_ ||
169 newGeometry.topLeft() == oldGeometry.topLeft()) {
170 QDeclarativeGeoMapItemBase::geometryChange(newGeometry, oldGeometry);
174 QGeoCoordinate newCoordinate = map()->geoProjection().
175 itemPositionToCoordinate(QDoubleVector2D(x(), y()) + QDoubleVector2D(anchorPoint_),
false);
177 if (newCoordinate.isValid())
178 setCoordinate(newCoordinate);
315void QDeclarativeGeoMapQuickItem::updatePolish()
317 if (!quickMap() && sourceItem_) {
318 mapAndSourceItemSet_ =
false;
319 sourceItem_.data()->setParentItem(0);
323 if (!quickMap() || !map() || !sourceItem_) {
324 mapAndSourceItemSet_ =
false;
328 if (!mapAndSourceItemSet_ && quickMap() && map() && sourceItem_) {
329 mapAndSourceItemSet_ =
true;
330 sourceItem_.data()->setParentItem(opacityContainer_);
331 sourceItem_.data()->setTransformOrigin(QQuickItem::TopLeft);
332 connect(sourceItem_.data(), &QQuickItem::xChanged,
333 this, &QDeclarativeGeoMapQuickItem::polishAndUpdate);
334 connect(sourceItem_.data(), &QQuickItem::yChanged,
335 this, &QDeclarativeGeoMapQuickItem::polishAndUpdate);
336 connect(sourceItem_.data(), &QQuickItem::widthChanged,
337 this, &QDeclarativeGeoMapQuickItem::polishAndUpdate);
338 connect(sourceItem_.data(), &QQuickItem::heightChanged,
339 this, &QDeclarativeGeoMapQuickItem::polishAndUpdate);
342 if (!coordinate_.isValid()) {
343 opacityContainer_->setVisible(
false);
346 opacityContainer_->setVisible(
true);
349 QScopedValueRollback<
bool> rollback(updatingGeometry_);
350 updatingGeometry_ =
true;
352 opacityContainer_->setOpacity(zoomLevelOpacity());
354 setWidth(sourceItem_.data()->width());
355 setHeight(sourceItem_.data()->height());
356 if (zoomLevel_ != 0.0
357 && map()->geoProjection().projectionType() == QGeoProjection::ProjectionWebMercator) {
358 const QGeoProjectionWebMercator &p =
static_cast<
const QGeoProjectionWebMercator&>(map()->geoProjection());
361 matrix_ =
new QMapQuickItemMatrix4x4(
this);
362 matrix_->appendToItem(opacityContainer_);
364 matrix_->setMatrix(p.quickItemTransformation(coordinate(), anchorPoint_, zoomLevel_));
365 setPosition(QPointF(0,0));
367 if (map()->geoProjection().projectionType() == QGeoProjection::ProjectionWebMercator) {
368 const QGeoProjectionWebMercator &p =
static_cast<
const QGeoProjectionWebMercator&>(map()->geoProjection());
369 if (map()->cameraData().tilt() > 0.0
370 && !p.isProjectable(p.geoToWrappedMapProjection(coordinate()))) {
373 matrix_ =
new QMapQuickItemMatrix4x4(
this);
374 matrix_->appendToItem(opacityContainer_);
376 matrix_->setMatrix(p.quickItemTransformation(coordinate(), anchorPoint_, map()->cameraData().zoomLevel()));
377 setPosition(QPointF(0,0));
380 matrix_->setMatrix(QMatrix4x4());
381 setPositionOnMap(coordinate(), anchorPoint_);
384 if (map()->cameraData().tilt() > 0.0
385 && qIsNaN(map()->geoProjection().coordinateToItemPosition(coordinate(),
false).x())) {
386 opacityContainer_->setVisible(
false);
389 matrix_->setMatrix(QMatrix4x4());
390 setPositionOnMap(coordinate(), anchorPoint_);