Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to get Address.text?



  • Hi!
    How to get Address.text?
    I need the coordinates and house numbers on the visible side of the map. Here is my code:

    import QtQuick 2.12
    import QtQuick.Window 2.12
    import QtLocation 5.12
    import QtPositioning 5.12
    
    Item {
        visible: true
        width: 480
        height: 720
    
        property double old : 19
        property double now
    
    
        Rectangle
        {
            anchors.fill: parent
            color: "#eee"
    
    
    
            PositionSource
            {
                id: src
    
            }
    
            Address
            {
             id:  address
            }
    
            Plugin
            {
                id: plugin
                name: "osm"
                PluginParameter { name: "osm.useragent"; value: "My great Qt OSM application" }
                PluginParameter { name: "osm.mapping.host"; value: "http://osm.tile.server.address/" }
                PluginParameter { name: "osm.mapping.copyright"; value: "All mine" }
                PluginParameter { name: "osm.routing.host"; value: "http://osrm.server.address/viaroute" }
                PluginParameter { name: "osm.geocoding.host"; value: "http://geocoding.server.address" }
                PluginParameter { name: "osm.places.host"; value: "http://geocoding.server.address" }
            }
    
            Map
            {
                id: maps
                anchors.fill: parent
                plugin: plugin
                gesture.enabled: true
                gesture.acceptedGestures: MapGestureArea.PinchGesture | MapGestureArea.PanGesture | MapGestureArea.FlickGesture
                gesture.flickDeceleration: 3000
                zoomLevel: 19
                center: QtPositioning.coordinate(59.91, 10.75) // Oslo
    
                onZoomLevelChanged:
                {
                    console.log("onZoomLevelChanged:")
                    console.log("coordinate ctnter:" + visibleRegion.center())
                    console.log("coordinate geoshape:" + visibleRegion.boundingGeoRectangle())
                }
    
                onCenterChanged:
                {
                    console.log("onCenterChanged:")
                    console.log("coordinate ctnter:" + visibleRegion.center())
                    console.log("coordinate geoshape:" + visibleRegion.boundingGeoRectangle())
                    console.log("address:" )
                }
    
                minimumZoomLevel: 1
    
                focus: true
    
    
            }
        }
    }
    

  • Lifetime Qt Champion

    @Mikeeeeee said in How to get Address.text?:

    How to get Address.text?

    I would say

    address.text
    

    or what do you mean?



  • I tried that, but nothing return.
    I need the house numbers and their coordinates on the visible side of the map.



  • @Mikeeeeee said in How to get Address.text?:

    I need the house numbers and their coordinates on the visible side of the map

    I never used QLocation/QPositioning, but I think you must first connect the Adress item with the Map. I don't know how you have to do it... But this seems to me to be the first step to do.
    I think you have to connect the Address.address property... but I don't really known :(



  • I tried writing Address in the body of map, but it didn't help. Address has very few methods and they don't allow me to set coordinates and map.



  • You can bind an address to a location, but it is not clear as to the location 4 enter the bounding coordinates.

            Location
            {
                id: myLocation
             /*coordinate{
             latitude:  - 27.3
             longitude:  153.1
                }*/
                    address:  Address {
                    id:  myAddress2
                }
            }
    


  • It turned out the address can be obtained so, but there are no coordinates and house numbers. Do you know where the coordinates and house numbers might be?

    import QtQuick 2.12
    import QtQuick.Window 2.12
    import QtLocation 5.12
    import QtPositioning 5.12
    
    Item {
        visible: true
        width: 480
        height: 720
    
        property double old : 19
        property double now
    
        Rectangle
        {
            anchors.fill: parent
            color: "#eee"
    
            Plugin
            {
                id: plugin
                name: "osm"
                //PluginParameter { name: "osm.useragent"; value: "My great Qt OSM application" }
            }
    
            Map
            {
                id: maps
                anchors.fill: parent
                plugin: plugin
                gesture.enabled: true
                gesture.acceptedGestures: MapGestureArea.PinchGesture | MapGestureArea.PanGesture | MapGestureArea.FlickGesture
                gesture.flickDeceleration: 3000
                zoomLevel: 19
                center: QtPositioning.coordinate(59.91, 10.75) // Oslo
    
                onCenterChanged:
                {
                    geocodeModel.query = visibleRegion.center()
                    geocodeModel.update()
                }
    
                minimumZoomLevel: 1
    
                focus: true
    
                GeocodeModel {
                    id: geocodeModel
                    plugin: plugin
                    onLocationsChanged:
                    {
                        console.log("onLocationsChanged")
                        if (count == 1) {
                            console.log("street:" + geocodeModel.get(0).address.street )
                            console.log("district:" + geocodeModel.get(0).address.district )
                            console.log("city:" + geocodeModel.get(0).address.city )
                            console.log("county:" + geocodeModel.get(0).address.county )
                            console.log("state:" + geocodeModel.get(0).address.state )
                            console.log("countryCode:" + geocodeModel.get(0).address.countryCode )
                            console.log("country:" + geocodeModel.get(0).address.country )
                            console.log("postalCode:" + geocodeModel.get(0).address.postalCode )
                            //console.log("postalCode:" + geocodeModel.get(0).address.text )
                        }
                    }
                }
            }
        }
    }
    
    


  • It turned out the house number is in text


Log in to reply