Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Scale QML map dynamically based on added items
QtWS25 Last Chance

Scale QML map dynamically based on added items

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 2 Posters 580 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
    morteza ali ahmadi
    wrote on last edited by
    #1

    I have a map in QML and I want to add some MapQuickItem items on it. These MapQuickItem items can be near or far from each. So I want to scale my map in such a way that after adding MapQuickItem items, all of them can be displayed on the screen. But I can't find a property to do that. How can I scale my map dynamically based on the MapQuickItem items?

    M 1 Reply Last reply
    0
    • M morteza ali ahmadi

      I have a map in QML and I want to add some MapQuickItem items on it. These MapQuickItem items can be near or far from each. So I want to scale my map in such a way that after adding MapQuickItem items, all of them can be displayed on the screen. But I can't find a property to do that. How can I scale my map dynamically based on the MapQuickItem items?

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

      @morteza-ali-ahmadi hey, you could probably do this using visibleRegion in qml map and a geoshape cointaining all your locations :)

      M 1 Reply Last reply
      1
      • M MEMekaniske

        @morteza-ali-ahmadi hey, you could probably do this using visibleRegion in qml map and a geoshape cointaining all your locations :)

        M Offline
        M Offline
        morteza ali ahmadi
        wrote on last edited by
        #3

        @MEMekaniske Thanks, I am a little confused in using geoshape.
        Is the following code correct?
        property variant region: "shape()"
        and I should to set my region and then
        myMap.visibleRegion=region

        M 2 Replies Last reply
        0
        • M morteza ali ahmadi

          @MEMekaniske Thanks, I am a little confused in using geoshape.
          Is the following code correct?
          property variant region: "shape()"
          and I should to set my region and then
          myMap.visibleRegion=region

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

          @morteza-ali-ahmadi

          I havent used it myself, so not sure how to set it up, have to take a look at it if I'm going to be of any help..

          But I found fitViewportToMapItems() which might be the feature you're looking for, without having to use the shape feature.
          myMap.fitViewportToMapItems();

          Let me know if it works or I'll have a look at it :)

          M 1 Reply Last reply
          2
          • M morteza ali ahmadi

            @MEMekaniske Thanks, I am a little confused in using geoshape.
            Is the following code correct?
            property variant region: "shape()"
            and I should to set my region and then
            myMap.visibleRegion=region

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

            @morteza-ali-ahmadi but yes your code looks right..

            1 Reply Last reply
            1
            • M MEMekaniske

              @morteza-ali-ahmadi

              I havent used it myself, so not sure how to set it up, have to take a look at it if I'm going to be of any help..

              But I found fitViewportToMapItems() which might be the feature you're looking for, without having to use the shape feature.
              myMap.fitViewportToMapItems();

              Let me know if it works or I'll have a look at it :)

              M Offline
              M Offline
              morteza ali ahmadi
              wrote on last edited by morteza ali ahmadi
              #6

              @MEMekaniske Thank you very much, fitViewportToMapItems works like a charm :)

              M 1 Reply Last reply
              1
              • M morteza ali ahmadi

                @MEMekaniske Thank you very much, fitViewportToMapItems works like a charm :)

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

                @morteza-ali-ahmadi Cool :) No problem! Happy you got it working!

                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