Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

147
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!