Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. What is the correct way to change coordinates with GeocodeModel?

What is the correct way to change coordinates with GeocodeModel?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 232 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Samuel Ives
    wrote on last edited by
    #1
    import QtQuick 2.0
    import QtLocation 5.12
    import QtPositioning 5.12
    
    Rectangle{
    
        // Icone que representa um marcador no mapa
        Image {
            id: ic_marker
            source: "qrc:///icons/icons/ic_map_marker.svg"
            sourceSize.width:  50
            sourceSize.height: 50
        }
    
        // Plugin responsavel por executar requisicoes de dados para o mapa
        Plugin{
            id: osm
            name: "osm"
            PluginParameter{name: "osm.useragent"; value: "TGAdmin"}
            PluginParameter{name: "osm.mapping.custom.host"; value: "https://tile.openstreetmap.org"}
            PluginParameter{name: "osm.mapping.providersrepository.disabled"; value: true}
        }
    
        // Marcador da posicao do tiro de guerra no mapa
        MapQuickItem{
            id: tgMarker
            anchorPoint.x: tgMarker.width / 4
            anchorPoint.y: tgMarker.height
            coordinate: QtPositioning.coordinate(latitude, longitude)
            sourceItem: ic_marker
        }
    
        Address{
            id: endeAtirador
            street: rua
        }
    
        GeocodeModel{
    
            id: geoModel
            plugin: osm
            autoUpdate: false
    
            onLocationsChanged: {
    
                if(count > 0){
    
                    tgMarker.coordinate = get(0).coordinate
    
                    query.addWaypoint(QtPositioning.coordinate(latitude, longitude))
                    query.addWaypoint(get(0).coordinate)
                    route.update()
    
                    console.log("Coordenadas: ", get(0).coordinate)
                }
    
            }
        }
    
        Map{
    
           id: mapa
           zoomLevel: 17
           anchors.fill: parent
           center: QtPositioning.coordinate(latitude, longitude)
           plugin: osm
    
           RouteModel{
    
               id: route
               plugin: osm
               autoUpdate: false
               query: RouteQuery{id: query}
    
           }
    
           Component.onCompleted: {
               addMapItem(tgMarker)
    
               geoModel.query = endeAtirador
               geoModel.update()
    
           }
    
        }
    
    }
    

    I'm trying to create a route from one point to another, although it was getting the coordinates of the address I can not change the location of the other items with it

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved