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. Qt Location: Marking multi addresses on Map
Forum Update on Monday, May 27th 2025

Qt Location: Marking multi addresses on Map

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 385 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.
  • a-r-tA Offline
    a-r-tA Offline
    a-r-t
    wrote on last edited by a-r-t
    #1

    Thank you for looking here !

    The one question is: How can I use the same plugin connection on both qml & cpp files?

    qml file > Plugin{ id: mapPlugin name: "osm" }
    and ...
    cpp file > QgeoServiceProvider, QGeoCodingManager

    (one direction and other direction qml->cpp and cpp->qml plugin)

    Main question: I draw multi points on map using the bellow code.
    My question is how can I transform the addMarker() function instead of giving Latitude/Longitude to give the address city/street/zip etc names ?

    MapView.qml

    Item
    {
        id: window
    
        Plugin
        {
            id: mapPlugin
            name: "osm"
        }
    
        function addMarker(name, lat, lon)
        {
            var component = Qt.createComponent("qrc:///qml/marker.qml")
            var item = component.createObject(window, {coordinate: QtPositioning.coordinate(lat, lon), labelText: name})
            map.addMapItem(item)
        }
    
        Map
        {
            id: map
            anchors.fill: parent
            plugin: mapPlugin
            center: QtPositioning.coordinate(38, 23)
            zoomLevel: 8
    
            Component.onCompleted:
            {
                addMarker("house", 38.0, 23.0)
                addMarker("lake", 38.2, 23.2)
                addMarker("church", 38.3, 23.3)
            }
        }
    }
    
    

    marker.qml

    MapQuickItem
    {
        id: marker
        anchorPoint.x: marker.width / 2
        anchorPoint.y: marker.height / 2
        property string labelText
    
        sourceItem: Item
        {
            Image
            {
                id: icon
                source: "///images/point.png"
            }
    
            Rectangle
            {
                id: tag
                anchors.centerIn: label
                width: label.width + 4
                height: label.height + 2
                color: "black"
            }
    
            Label
            {
                id:label
                text: labelText
            }
        }
    }
    
    

    to be something like ...

    
        function addMarker(Street, City, Country, State, PostalCode)
        {
             Address {
                       id :markAddress
                       street: Street
                       city: City
                       country: Country
                       state : State
                       postalCode: PostalCode
            }
            
            ...
            map.addMapItem(itemAddress)
        }
    
    

    or this one ...

        GeocodeModel 
        {
              id: geocodeModel
              plugin: mapPlugin
              autoUpdate: false
        }
    
        function addMarker(onelineaddress)  //"53 Praxitelis St, Plains, Greece"
        {
              geocodeModel.query = onelineaddress
              geocodeModel.update()
              ...
              ...
              map.addMapItem(itemAddress)
        }
    
    
    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