Nominate our 2022 Qt Champions!

[SOLVED] QML Map Element - center coordinate (loop detection issue)

    use toCoordinate instead of

    Text {
    id: latitude
    text: map.toCoordinate(Qt.point(180,320)).latitude

    Hi all, I have experimented around with Map element and tried to render via simlpe Text element to the screen the coordinates of the map center.
    Since property holds exactly the position I need to render I used:
    Text {
    id: latitude

    The example works fine but the console repeatedly states that there is "binding loop detected for property text".

    How can I make a proper reference to the center property to avoid that loop issue??

  • Problem solved...
    Just had to add Coordinate element which refered to first. and then the text value points now to Coordinate instead of Map element's center...

  • UPDATE#2 - hm it seems like its not solved as the console messages are still being fired off...
    Could someone tell me if I can just ignore these messages?

    I don't know what this really means (loop detected) but as long as it is working I am fine..

  • I have partially sorted out the issue by using map.toCoordinate method to render the Coordinate after user moves the map around. Problem is the documentation states:

    Map::toCoordinate ( QPointF screenPosition )
    Returns the coordinate which corresponds to the screen position screenPosition

    So I am able to get a coordinate onMovementEnded, but what is the Syntax for screenPosition??
    where to read about it? I tried:


    But all seems to be giving me same coordinate back like if I was using: map.toCoordinate without any indication oin the screen position...

    Please help!

  • Hi,

    I searched for this error and found your post now. Opposite to you I know what is this error but I am searching for some workaround to debug it and solve in a simple way than what I am using..

    The binding loop error occours when you assign some property circularly to one or more values. This is not always simple do focus because you should "think" like QML interpreter; loading a document it tries updating all the properties following a process where a property can be bound to another when it has alredy a value else there is an undefined assignent. Then a vcalue can't be assigned to another that bind itself with the first. A problem that occours with bindings is the time needed to some properties to be set.

    Is you assign a property to the resulting value of a js function it is possible that when the QML is loading the document there are some properties that are not yet "filled" with the correct value but in the meantime this property is bound to another. The resulting error maybe a binding loop. Then I am applying in these cases the Component.onCompleted. This means that some bound property values are assigned only when I am sure that all the component has been loaded.

    This works not in all cases so another workaround is to manage a signal fired when the component is loaded.

    Hope this can help you.

  • Hey! This is indeed a good explanation;) thank you.

Log in to reply