Solved Scale QML map dynamically based on added items
I have a map in QML and I want to add some
MapQuickItemitems on it. These
MapQuickItemitems can be near or far from each. So I want to scale my map in such a way that after adding
MapQuickItemitems, 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
@morteza-ali-ahmadi hey, you could probably do this using visibleRegion in qml map and a geoshape cointaining all your locations :)
@MEMekaniske Thanks, I am a little confused in using
Is the following code correct?
property variant region: "shape()"
and I should to set my region and then
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.
Let me know if it works or I'll have a look at it :)
@morteza-ali-ahmadi but yes your code looks right..
@MEMekaniske Thank you very much,
fitViewportToMapItemsworks like a charm :)
@morteza-ali-ahmadi Cool :) No problem! Happy you got it working!