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

How to find the coordinates of all objects on the map?



  • Hi!
    I use OSM map.
    How to find the coordinates of all objects on the map?
    And how do I know the number of objects on the map?

    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(55.845741, 37.660652) // Moscow
    
                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("text:" + geocodeModel.get(0).address.text )
                            //console.log("bounds:" + geocodeModel.bounds)
                        }
                    }
                }
            }
        }
    }
    
    
    


  • Maybe it can be implemented through PlaceSearchModel ?



  • Connected PlaceSearchModel and set the search area.
    Please tell me how to get from Place Search Model the number of objects and their coordinates?

    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(55.845741, 37.660652) // Moscow
    
                onCenterChanged:
                {
                    geocodeModel.query = visibleRegion.center()
                    geocodeModel.update()
                    mySearchModel.searchArea = visibleRegion.boundingGeoRectangle() //it's work
                    mySearchModel.update()
                }
    
                minimumZoomLevel: 1
    
                focus: true
    
                PlaceSearchModel {
                    id: mySearchModel
                    plugin: plugin
                    searchArea: visibleRegion.boundingGeoRectangle()
                    onSearchAreaChanged:  //it's work
                    {
                        console.log("onSearchAreaChanged :" )
                    }
                }
    
                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("text:" + geocodeModel.get(0).address.text )
    //                        //console.log("bounds:" + geocodeModel.bounds)
    //                    }
                    }
                }
            }
        }
    }
    


  • Learned that the number of found facilities can be to know so

    console.log("count :" + mySearchModel.count)
    

    But the question becomes about finding, tried not to search, or asked, but still nothing looking for

    my SearchModel.searchTerm = ""
    

    Also tried to enter the search number of the house on the screen, too, is not looking for anything

    mySearchModel.searchTerm = "211 K2"
    

    But the name of the store finds the object

    mySearchModel.searchTerm = "Golden Babylon"
    

    By street names, it displays the number of visible areas expensive:

    mySearchModel.searchTerm = "prospect Mira"
    

    The index also gives 1 result, apparently district. Please tell me how to search to get all the buildings?



  • @Mikeeeeee I see you in that forum frequently. You ask something about a map application. But no one answers sometimes. Even so, you learn so much! I am just writing to celebrate your effort :D
    Good work!
    Note: In general, you don't ask questions like "How can I see the building numbers on map?" on coding forums. You should get in to it more, and ask questions like "I got a variable like that and a function like that and how can I expose them?" and so...



  • Thanks. I tried asking the question "How can I see the building numbers on map?", but no one answers it. So I ask a question about the code and I hope that someone worked with it.
    Now I stopped at "PlaceSearchModel", I hope that someone knows how to solve it.



  • Can be somehow possible in a "Place Search Model" to search by type (mean search only on buildings, streets)?



  • There is a property: Place.UnspecifiedVisibility , it should show the field of view for the entire property. Can this can be as the fasten? Or maybe you can somehow get all the objects from the map and drive them through the Place.UnspecifiedVisibility ?


Log in to reply