[Interest] MapItemView does not work on map

Kishore J kitts.mailinglists at gmail.com
Wed Aug 24 19:21:52 CEST 2016


In my QML file, I display a map and try to populate it with a MapItemView
but it does not seem to work. I have added a MapCircle statically and that
that works. Can anyone point out what is wrong in the following code.

/*******************BEGIN*****************/
import QtQuick 2.5
import QtLocation 5.6

Map {
    id: map
    objectName: "MyMap"
    zoomLevel: (maximumZoomLevel - minimumZoomLevel)/2

    plugin: Plugin {
        name: "here"
        PluginParameter {name: "here.app_id"; value: "xxxxxx"}
        PluginParameter {name: "here.token"; value: "xxxxxx"}
    }
    activeMapType: supportedMapTypes[3]
    center {
        latitude: 10
        longitude: 20
    }

    MapCircle {
        id: circle
        center {
            latitude: 5
            longitude: 10
        }
        radius: 500000.0
        color: 'yellow'
        border.width: 4
        border.color: 'yellow'
        Component.onCompleted: {
            console.debug("Loaded static MapCircle")
            console.debug(center + ' radius: ' + radius)
        }
    }

    MapItemView {
        id: mapitemview
        objectName: "MyMapItemView"
        model: ListModel {
            id: list
            ListElement{lat: 10; lon: 20; rad: 800000}
            ListElement{lat: 30; lon: 40; rad: 700000}
        }
        delegate: Component {
            id: delegate
            MapCircle {
                id: mapcircle
                center {
                    latitude: lat;
                    longitude: lon;
                }
                radius: rad
                color: 'black'
                border.width: 4
                border.color: 'black'
                Component.onCompleted: {
                    console.debug("Loaded a MapCircle")
                    console.debug(center + ' radius: ' + radius)
                }
            }
        }

        Component.onCompleted: {
            console.debug("Loaded Internal MapItemView")
            console.debug(model.count)
        }
    }

    Component.onCompleted:{
        center.latitude = 10
        center.longitude = 20
        zoomLevel = maximumZoomLevel - 2;
        console.debug('Loaded map ' + map.center)
    }
    function addItem(item) {
        addMapItem(item)
    }
}
/*******************END*******************/
The only possible explanation i find is the state in the docs for
MapItemView.model that says "Only QAbstractItemModel based models are
supported." and I'm not sure if ListModel is QAIM based.

I did find a reference (https://bugreports.qt.io/browse/QTBUG-25157) which
suggests that ListModel should work.

Also, following to the commit corresponding to the above bug (
https://codereview.qt-project.org/#/c/22423/2/tests/auto/declarative_ui/tst_map_itemview.qml)
indicates that i can assign a coordinate like this

/*****/
center: Coordinate { 238
                        latitude: lat; 239
                        longitude: lon; 240
                    }
/*****/
but that fails with an error for me.

Any help appreciated. Thanks in advance!
--
Regards,
Kishore
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160824/f75d2d1e/attachment.html>


More information about the Interest mailing list