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. QML Map set min/max longitude latitude
Forum Updated to NodeBB v4.3 + New Features

QML Map set min/max longitude latitude

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
7 Posts 2 Posters 850 Views 1 Watching
  • 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.
  • patrikdP Offline
    patrikdP Offline
    patrikd
    wrote on last edited by
    #1

    Hi all,
    I'm trying to limit the visible area on a map. Is there a way to set a min/max for longitude/latitude for the gesture area?
    Couldn't find anything working to restrict the area.
    thx,
    patrik

    1 Reply Last reply
    0
    • M Offline
      M Offline
      MEMekaniske
      wrote on last edited by
      #2

      Hello :)

      You can accomplish this using this parameter,
      "fieldOfView : real

      This property holds the field of view of the camera used to look at the map, in degrees. If the plugin property of the map is not set, or the plugin does not support mapping, the value is 45 degrees.

      Note that changing this value implicitly changes also the distance between the camera and the map, so that, at a tilting angle of 0 degrees, the resulting image is identical for any value used for this property.

      For more information about this parameter, consult the Wikipedia articles about Field of view and Angle of view."
      https://doc.qt.io/qt-5/qml-qtlocation-map.html#fieldOfView-prop

      1 Reply Last reply
      0
      • patrikdP Offline
        patrikdP Offline
        patrikd
        wrote on last edited by
        #3

        Hi MEMekaniske,
        seems not to work. Can put there any value but I can move the map with no boundaries...
        thx,
        patrik

        M 1 Reply Last reply
        0
        • patrikdP patrikd

          Hi MEMekaniske,
          seems not to work. Can put there any value but I can move the map with no boundaries...
          thx,
          patrik

          M Offline
          M Offline
          MEMekaniske
          wrote on last edited by
          #4

          @patrikd hey!

          Ok, so you want there to be no drag/flick etc enabled?

          Took this from the Qt docs, you can disable gestures using the following example and only allow the ones that you want to be enabled.
          Or since you don't want any movement you can just remove gesture feature and remove focus from the map object.

          Example Usage
          The following example enables the pinch and pan gestures on the map, but not flicking. So the map scrolling will halt immediately on releasing the mouse button / touch.
          
          Map {
              gesture.enabled: true
              gesture.acceptedGestures: MapGestureArea.PinchGesture | MapGestureArea.PanGesture
          }
          
          "
          MapGestureArea.NoGesture        Don't support any additional gestures (value: 0x0000).
          MapGestureArea.PinchGesture	Support the map pinch gesture (value: 0x0001).
          MapGestureArea.PanGesture	Support the map pan gesture (value: 0x0002).
          MapGestureArea.FlickGesture	Support the map flick gesture (value: 0x0004).
          MapGestureArea.RotationGesture	Support the map rotation gesture (value: 0x0008).
          MapGestureArea.TiltGesture	Support the map tilt gesture (value: 0x0010).
          

          Or if you want there to be a limmit on zooming in and out, you can use the following.

          maximumZoomLevel : real
          minimumZoomLevel : real
          
          1 Reply Last reply
          0
          • patrikdP Offline
            patrikdP Offline
            patrikd
            wrote on last edited by
            #5

            Hi MEMakaniske,
            thx for your advice but still not the result. My target is this functionality:
            https://docs.mapbox.com/ios/maps/examples/constraining-gestures/

            But I can't find a way to restrict my map view. The min/max zoom doesn't help on this
            and it seems like restricting the gestures doesn't help. I can still move my map out of the view.
            best,
            patrik

            1 Reply Last reply
            0
            • M Offline
              M Offline
              MEMekaniske
              wrote on last edited by MEMekaniske
              #6

              Ok, now I understand.

              I was wrong in the previous revision of this reply, that was for getting address lists etc from a shape of set by coordinates.
              You need the GeoShape module
              https://doc.qt.io/qt-5/qml-geoshape.html

              I'll give this a shot myself in the morning! hope you get it working right with geoshape!

              1 Reply Last reply
              0
              • M Offline
                M Offline
                MEMekaniske
                wrote on last edited by
                #7

                @patrikd

                I have been trying to search the docs for any way to do this easily and with gestures.
                But I am only able to do this easily with MouseArea.

                I think you would need to use the map plugin you reffered in the link, which is also available in Qt if you'd want to do this with as few lines of code as possible.

                https://doc.qt.io/qt-5/location-plugin-mapboxgl.html

                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