[Qt] Added 'image' MapParameter type
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#define QQUICKMAPBOXGL_H
|
||||
|
||||
#include <QColor>
|
||||
#include <QImage>
|
||||
#include <QGeoCoordinate>
|
||||
#include <QGeoServiceProvider>
|
||||
#include <QGeoShape>
|
||||
@@ -132,6 +133,11 @@ private:
|
||||
PitchNeedsSync = 1 << 5,
|
||||
};
|
||||
|
||||
struct Image {
|
||||
QString name;
|
||||
QImage sprite;
|
||||
};
|
||||
|
||||
struct StyleProperty {
|
||||
enum Type {
|
||||
Paint = 0,
|
||||
@@ -146,6 +152,7 @@ private:
|
||||
};
|
||||
|
||||
void processMapParameter(QQuickMapboxGLMapParameter *);
|
||||
bool parseImage(QQuickMapboxGLMapParameter *);
|
||||
bool parseStyle(QQuickMapboxGLMapParameter *);
|
||||
bool parseStyleProperty(QQuickMapboxGLMapParameter *, const QString &name);
|
||||
bool parseStyleLayer(QQuickMapboxGLMapParameter *);
|
||||
@@ -162,6 +169,7 @@ private:
|
||||
QGeoShape m_visibleRegion;
|
||||
QColor m_color;
|
||||
QString m_styleUrl;
|
||||
QList<Image> m_imageChanges;
|
||||
QList<StyleProperty> m_stylePropertyChanges;
|
||||
QList<QVariantMap> m_layerChanges;
|
||||
QList<QVariantMap> m_sourceChanges;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
namespace {
|
||||
|
||||
static const QRegularExpression s_camelCase {"([a-z0-9])([A-Z])"};
|
||||
static const QStringList s_parameterTypes = QStringList() << "style" << "paint" << "layout" << "layer" << "source" << "filter";
|
||||
static const QStringList s_parameterTypes = QStringList() << "style" << "paint" << "layout" << "layer" << "source" << "filter" << "image";
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -251,6 +251,15 @@ void QQuickMapboxGL::onMapChanged(QMapbox::MapChange change)
|
||||
}
|
||||
}
|
||||
|
||||
bool QQuickMapboxGL::parseImage(QQuickMapboxGLMapParameter *param)
|
||||
{
|
||||
m_imageChanges << Image {
|
||||
param->property("name").toString(),
|
||||
QImage(param->property("sprite").toString())
|
||||
};
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QQuickMapboxGL::parseStyle(QQuickMapboxGLMapParameter *param)
|
||||
{
|
||||
QString url = param->property("url").toString();
|
||||
@@ -367,6 +376,9 @@ void QQuickMapboxGL::processMapParameter(QQuickMapboxGLMapParameter *param)
|
||||
case 5: // filter
|
||||
needsUpdate |= parseStyleFilter(param);
|
||||
break;
|
||||
case 6: // image
|
||||
needsUpdate |= parseImage(param);
|
||||
break;
|
||||
}
|
||||
if (needsUpdate) update();
|
||||
}
|
||||
@@ -405,6 +417,9 @@ void QQuickMapboxGL::onParameterPropertyUpdated(const QString &propertyName)
|
||||
case 5: // filter
|
||||
needsUpdate |= parseStyleFilter(param);
|
||||
break;
|
||||
case 6: // image
|
||||
needsUpdate |= parseImage(param);
|
||||
break;
|
||||
}
|
||||
if (needsUpdate) update();
|
||||
}
|
||||
|
||||
@@ -96,6 +96,11 @@ void QQuickMapboxGLRenderer::synchronize(QQuickFramebufferObject *item)
|
||||
}
|
||||
quickMap->m_filterChanges.clear();
|
||||
|
||||
for (const auto& change : quickMap->m_imageChanges) {
|
||||
m_map->addImage(change.name, change.sprite);
|
||||
}
|
||||
quickMap->m_imageChanges.clear();
|
||||
|
||||
for (const auto& change : quickMap->m_stylePropertyChanges) {
|
||||
if (change.type == QQuickMapboxGL::StyleProperty::Paint) {
|
||||
m_map->setPaintProperty(change.layer, change.property, change.value, change.klass);
|
||||
|
||||
Reference in New Issue
Block a user