Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How do I get the map's visible coordinates?
Forum Updated to NodeBB v4.3 + New Features

How do I get the map's visible coordinates?

Scheduled Pinned Locked Moved Solved Mobile and Embedded
4 Posts 1 Posters 434 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.
  • M Offline
    M Offline
    Mikeeeeee
    wrote on last edited by
    #1

    Hi!
    How do I get the map's visible coordinates?
    This 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
    //    width: Screen.width
    //    height: Screen.height
    
            property double old : 19
            property double now
    
        Rectangle
        {
            anchors.fill: parent
            color: "#eee"
    
            Component.onCompleted:
            {
                circle.center = src.position.coordinate
                circle1.center = src.position.coordinate
                circle2.center = src.position.coordinate
                maps.center = src.position.coordinate
            }
    
            PositionSource
            {
                id: src
                active: true
                updateInterval: 1000
                onPositionChanged:
                {
                    circle.center = position.coordinate
                    circle1.center = position.coordinate
                    circle2.center = position.coordinate
                }
            }
    
            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
    
                onZoomLevelChanged:
                {
    
                }
    
                minimumZoomLevel: 1
    
                focus: true
    
    
            }
        }
    }
    
    
    1 Reply Last reply
    0
    • M Offline
      M Offline
      Mikeeeeee
      wrote on last edited by
      #2

      Tried to do so, but the coordinates are not returned. Please tell me how to do it.

      import QtQuick 2.12
      import QtQuick.Window 2.12
      import QtLocation 5.12
      import QtPositioning 5.12
      //console.log("открылась Page1") //вывод текста в консоль
      
      Item {
          visible: true
          width: 480
          height: 720
          //    width: Screen.width
          //    height: Screen.height
      
          property double old : 19
          property double now
      
      
          Rectangle
          {
              anchors.fill: parent
              color: "#eee"
      
              /*Component.onCompleted:
              {
                  circle.center = src.position.coordinate
                  circle1.center = src.position.coordinate
                  circle2.center = src.position.coordinate
                  maps.center = src.position.coordinate
              }*/
      
              PositionSource
              {
                  id: src
                  active: true
                  updateInterval: 1000
                  onPositionChanged:
                  {
                      console.log("PositionSource:" )
      //                circle.center = position.coordinate
      //                circle1.center = position.coordinate
      //                circle2.center = position.coordinate
                  }
              }
      
              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
      
                  onZoomLevelChanged:
                  {
                      console.log("onZoomLevelChanged:")
                  }
      
                  onCenterChanged:
                  {
                      console.log("onCenterChanged:")
                      console.log("coordinate:" + src.position.coordinate)
                  }
      
                  minimumZoomLevel: 1
      
                  focus: true
      
                  /*MapCircle {
                      id: circle
                      z: 2
                      color: "#fff"
                      radius: 8
                      border.color: "#fff"
                      center
                      {
                          latitude: src.position.coordinate.latitude
                          longitude: src.position.coordinate.longitude
                      }
                  }
      
                  MapCircle {
                      id: circle2
                      z: 3
                      color: "#0084ff"
                      radius: 4
                      border.color: "#0084ff"
                      center
                      {
                          latitude: src.position.coordinate.latitude
                          longitude: src.position.coordinate.longitude
                      }
                  }
      
                  MapCircle {
                      id: circle1
                      z: 1
                      color: "#0084ff"
                      border.color: "#0084ff"
                      opacity: 0.25
                      radius: 19
                      center
                      {
                          latitude: src.position.coordinate.latitude
                          longitude: src.position.coordinate.longitude
                      }
                  }*/
              }
          }
      }
      
      
      1 Reply Last reply
      0
      • M Offline
        M Offline
        Mikeeeeee
        wrote on last edited by
        #3

        So you can find the center. But how can you determine the size of the visible map?

        console.log("coordinate center:" + visibleRegion.center())
        
        1 Reply Last reply
        0
        • M Offline
          M Offline
          Mikeeeeee
          wrote on last edited by
          #4

          It's works

                          console.log("coordinate ctnter:" + visibleRegion.center())
                          console.log("coordinate geoshape:" + visibleRegion.boundingGeoRectangle())
          
          1 Reply Last reply
          1

          • Login

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