summaryrefslogtreecommitdiffstats
path: root/examples/location/places_list/places_list.qml
blob: bbe1269c7cac2ecc805ef210ca609730c87be54d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

//! [Imports]
import QtQuick
import QtPositioning
import QtLocation
//! [Imports]

Rectangle {
    width: 360
    height: 640
    property variant startCoordinate: QtPositioning.coordinate( 59.9485, 10.7686) // The Qt Company in Oslo

    //! [Initialize Plugin]
    Plugin {
        id: myPlugin
        name: "osm"
        //specify plugin parameters as necessary
        //PluginParameter {...}
        //PluginParameter {...}
        //...
    }
    //! [Initialize Plugin]

    //! [PlaceSearchModel]
    PlaceSearchModel {
        id: searchModel

        plugin: myPlugin

        searchTerm: "food"
        searchArea: QtPositioning.circle(startCoordinate, 5000 /* 5 km radius */);

        Component.onCompleted: update()

    }
    //! [PlaceSearchModel]

    //! [Places ListView]
    ListView {
        anchors.fill: parent
        model: searchModel
        delegate: Component {
            Row {
                spacing: 5
                Marker { height: parent.height }
                Column {
                    Text { text: title; font.bold: true }
                    Text { text: place.location.address.text }
                }
            }
        }
    }
    //! [Places ListView]

    Connections {
        target: searchModel
        function onStatusChanged() {
            if (searchModel.status == PlaceSearchModel.Error)
                console.log(searchModel.errorString());
        }
    }
}