Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

138
Visualizações
Mapbox QML Can't remove MapParameters

I am currently building a navigation application using the Mapbox GL API for QML. I have a desired behavior to add Mapbox layers on top of the map dynamically when the user wants to. The layers are GeoJson files.

I am using QtLocation 5.15 and QtQuick 2.0 across my files.

    var sourceQml ="
        import QtQuick 2.0;                             \
        import QtLocation 5.15;                         \
        MapParameter {                                  \
            type: 'source';                             \
            property var name: '%1';                    \
            property var sourceType: '%2';              \
            property var data: '%3';                    \
        }"

    var layerQml ="import QtQuick 2.0;              \
                   import QtLocation 5.15;          \
                   MapParameter {                   \
                       type: 'layer';               \
                       property var name: '%1';     \
                       property var layerType: '%2';\
                       property var source: '%3';   \
                   }"

    var paintingQml = "import QtQuick 2.0;              \
                       import QtLocation 5.15;          \
                       MapParameter {                   \
                           type: 'paint';               \
                           property var layer: '%1';    \
                           property var lineColor: '%2';\
                           property var lineWidth: %3;  \
                       }"

    // Adding properties
    sourceQml   = sourceQml.arg(sourceName).arg(sourceType).arg(data)
    layerQml    = layerQml.arg(name).arg(layerType).arg(sourceName)
    paintingQml = paintingQml.arg(name).arg("blue").arg(4)

    var sourceObject    = Qt.createQmlObject(sourceQml,     map)
    var layerObject     = Qt.createQmlObject(layerQml,      map)
    var paintingObject  = Qt.createQmlObject(paintingQml,   map)

    map.addMapParameter(sourceObject)
    map.addMapParameter(layerObject)
    map.addMapParameter(paintingObject)

Adding the MapParameters using the above method works fine (e.g. the layers appear on the map). HOWEVER, I would like to enable the user to remove these layers (MapParameters). When the action is desired, I call the following method to clear all MapParameters of the map : map.clearMapParameters()

The layers are still completely visible on the map. To verify, I manually compared the list's length in the Map object since I saw that map parameters were stored in a list as a property of the object Map. The parameters are well being cleared in the mapParameters list.

How could that be? I'd love to get insight on why my layers are still showing up even if I removed all the MapParameters of the list?

about 4 years ago · Santiago Gelvez
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda