Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

136
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda