Ejemplo n.º 1
0
void QDeclarativeGeoMap::onSupportedMapTypesChanged()
{
    QList<QDeclarativeGeoMapType *> supportedMapTypes;
    QList<QGeoMapType> types = m_mappingManager->supportedMapTypes();
    for (int i = 0; i < types.size(); ++i) {
        // types that are present and get removed will be deleted at QObject destruction
        QDeclarativeGeoMapType *type = findMapType(m_supportedMapTypes, types[i]);
        if (!type)
            type = new QDeclarativeGeoMapType(types[i], this);
        supportedMapTypes.append(type);
    }
    m_supportedMapTypes.swap(supportedMapTypes);
    if (m_supportedMapTypes.isEmpty()) {
        m_map->setActiveMapType(QGeoMapType()); // no supported map types: setting an invalid one
    } else {
        bool hasMapType = false;
        foreach (QDeclarativeGeoMapType *declarativeType, m_supportedMapTypes) {
            if (declarativeType->mapType() == m_map->activeMapType())
                hasMapType = true;
        }
        if (!hasMapType) {
            QDeclarativeGeoMapType *type = m_supportedMapTypes.at(0);
            m_activeMapType = type;
            m_map->setActiveMapType(type->mapType());
        }
    }

    emit supportedMapTypesChanged();
}
Ejemplo n.º 2
0
/*!
    \internal
    this function will only be ever called once
*/
void QDeclarativeGeoMap::mappingManagerInitialized()
{
    m_mappingManagerInitialized = true;

    m_map = m_mappingManager->createMap(this);
    m_gestureArea->setMap(m_map);

    // once mappingManagerInitilized_ is set zoomLevel() returns the default initialised
    // zoom level of the map controller. Overwrite it here to whatever the user chose.
    m_map->mapController()->setZoom(m_zoomLevel);

    //The zoom level limits are only restricted by the plugins values, if the user has set a more
    //strict zoom level limit before initialization nothing is done here.
    if (m_mappingManager->cameraCapabilities().minimumZoomLevel() > m_gestureArea->minimumZoomLevel())
        setMinimumZoomLevel(m_mappingManager->cameraCapabilities().minimumZoomLevel());

    if (m_gestureArea->maximumZoomLevel() < 0
            || m_mappingManager->cameraCapabilities().maximumZoomLevel() < m_gestureArea->maximumZoomLevel())
        setMaximumZoomLevel(m_mappingManager->cameraCapabilities().maximumZoomLevel());

    m_map->setActiveMapType(QGeoMapType());

    m_copyrights = new QDeclarativeGeoMapCopyrightNotice(this);
    connect(m_map, SIGNAL(copyrightsChanged(QImage)),
            m_copyrights.data(), SLOT(copyrightsChanged(QImage)));
    connect(m_map, SIGNAL(copyrightsChanged(QString)),
            m_copyrights.data(), SLOT(copyrightsChanged(QString)));
    connect(m_copyrights.data(), SIGNAL(linkActivated(QString)),
            this, SIGNAL(copyrightLinkActivated(QString)));

    connect(m_map,
            SIGNAL(updateRequired()),
            this,
            SLOT(update()));
    connect(m_map->mapController(),
            SIGNAL(centerChanged(QGeoCoordinate)),
            this,
            SLOT(mapCenterChanged(QGeoCoordinate)));
    connect(m_map->mapController(),
            SIGNAL(zoomChanged(qreal)),
            this,
            SLOT(mapZoomLevelChanged(qreal)));

    m_map->mapController()->setCenter(m_center);

    QList<QGeoMapType> types = m_mappingManager->supportedMapTypes();
    for (int i = 0; i < types.size(); ++i) {
        QDeclarativeGeoMapType *type = new QDeclarativeGeoMapType(types[i], this);
        m_supportedMapTypes.append(type);
    }

    if (!m_supportedMapTypes.isEmpty()) {
        QDeclarativeGeoMapType *type = m_supportedMapTypes.at(0);
        m_activeMapType = type;
        m_map->setActiveMapType(type->mapType());
    }

    // Map tiles are built in this call
    m_map->resize(width(), height());
    // This prefetches a buffer around the map
    m_map->prefetchData();
    m_map->update();

    connect(m_mappingManager, SIGNAL(supportedMapTypesChanged()), this, SLOT(onSupportedMapTypesChanged()));
    emit minimumZoomLevelChanged();
    emit maximumZoomLevelChanged();
    emit supportedMapTypesChanged();
    emit activeMapTypeChanged();

    // Any map items that were added before the plugin was ready
    // need to have setMap called again
    foreach (const QPointer<QDeclarativeGeoMapItemBase> &item, m_mapItems) {
        if (item)
            item.data()->setMap(this, m_map);
    }
}
Ejemplo n.º 3
0
/*!
    \internal
    this function will only be ever called once
*/
void QDeclarativeGeoMap::mappingManagerInitialized()
{
    mappingManagerInitialized_ = true;

    map_ = mappingManager_->createMap(this);
    gestureArea_->setMap(map_);

    //The zoom level limits are only restricted by the plugins values, if the user has set a more
    //strict zoom level limit before initialization nothing is done here.
    if (mappingManager_->cameraCapabilities().minimumZoomLevel() > gestureArea_->minimumZoomLevel())
        setMinimumZoomLevel(mappingManager_->cameraCapabilities().minimumZoomLevel());

    if (gestureArea_->maximumZoomLevel() < 0
            || mappingManager_->cameraCapabilities().maximumZoomLevel() < gestureArea_->maximumZoomLevel())
        setMaximumZoomLevel(mappingManager_->cameraCapabilities().maximumZoomLevel());

    map_->setActiveMapType(QGeoMapType());

    copyrightsWPtr_ = new QDeclarativeGeoMapCopyrightNotice(this);
    connect(map_,
            SIGNAL(copyrightsChanged(QImage,QPoint)),
            copyrightsWPtr_.data(),
            SLOT(copyrightsChanged(QImage,QPoint)));

    connect(map_,
            SIGNAL(updateRequired()),
            this,
            SLOT(update()));
    connect(map_->mapController(),
            SIGNAL(centerChanged(QGeoCoordinate)),
            this,
            SIGNAL(centerChanged(QGeoCoordinate)));
    connect(map_->mapController(),
            SIGNAL(zoomChanged(qreal)),
            this,
            SLOT(mapZoomLevelChanged(qreal)));

    map_->mapController()->setCenter(center_);
    map_->mapController()->setZoom(zoomLevel_);

    QList<QGeoMapType> types = mappingManager_->supportedMapTypes();
    for (int i = 0; i < types.size(); ++i) {
        QDeclarativeGeoMapType *type = new QDeclarativeGeoMapType(types[i], this);
        supportedMapTypes_.append(type);
    }

    if (!supportedMapTypes_.isEmpty()) {
        QDeclarativeGeoMapType *type = supportedMapTypes_.at(0);
        activeMapType_ = type;
        map_->setActiveMapType(type->mapType());
    }

    // Map tiles are built in this call
    map_->resize(width(), height());
    // This prefetches a buffer around the map
    map_->cameraStopped();
    map_->update();

    emit minimumZoomLevelChanged();
    emit maximumZoomLevelChanged();
    emit supportedMapTypesChanged();
    emit activeMapTypeChanged();

    // Any map items that were added before the plugin was ready
    // need to have setMap called again
    foreach (const QPointer<QDeclarativeGeoMapItemBase> &item, mapItems_) {
        if (item)
            item.data()->setMap(this, map_);
    }
}