diff --git a/src/core/map.cpp b/src/core/map.cpp index 9933d0c..0e8b376 100644 --- a/src/core/map.cpp +++ b/src/core/map.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -1219,8 +1220,22 @@ void Map::updateSource(const QString &id, const QVariantMap ¶ms) { return; } - if (sourceImage != nullptr && params.contains("url")) { - sourceImage->setURL(params["url"].toString().toStdString()); + if (sourceImage != nullptr) { + if (params.contains("url")) { + sourceImage->setURL(params["url"].toString().toStdString()); + } + if (params.contains("coordinates") && params["coordinates"].toList().size() == 4) { + mbgl::style::conversion::Error error; + std::array coordinates; + for (std::size_t i = 0; i < 4; i++) { + auto latLng = mbgl::style::conversion::convert( + params["coordinates"].toList()[static_cast(i)], error); + if (latLng) { + coordinates[i] = *latLng; // NOLINT(cppcoreguidelines-pro-bounds-constant-array-index) + } + } + sourceImage->setCoordinates(coordinates); + } } else if (sourceGeoJSON != nullptr && params.contains("data")) { mbgl::style::conversion::Error error; auto result = mbgl::style::conversion::convert(params["data"], error); diff --git a/test/qml/qt6/tst_style_parameters.qml b/test/qml/qt6/tst_style_parameters.qml index d4d9d30..c197487 100644 --- a/test/qml/qt6/tst_style_parameters.qml +++ b/test/qml/qt6/tst_style_parameters.qml @@ -82,6 +82,19 @@ Item { radarSourceParam.url = "https://maplibre.org/maplibre-gl-js/docs/assets/radar4.gif" compare(radarSourceParam.url, "https://maplibre.org/maplibre-gl-js/docs/assets/radar4.gif") wait(250) + radarSourceParam.coordinates = [ + [-85.425, 46.437], + [-76.516, 46.437], + [-76.516, 37.936], + [-85.425, 37.936] + ] + compare(radarSourceParam.coordinates, [ + [-85.425, 46.437], + [-76.516, 46.437], + [-76.516, 37.936], + [-85.425, 37.936] + ]) + wait(250) } function test_style_2_paint_change() {