Scale QML map dynamically based on added items
-
I have a map in QML and I want to add some
MapQuickItem
items on it. TheseMapQuickItem
items can be near or far from each. So I want to scale my map in such a way that after addingMapQuickItem
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 theMapQuickItem
items? -
I have a map in QML and I want to add some
MapQuickItem
items on it. TheseMapQuickItem
items can be near or far from each. So I want to scale my map in such a way that after addingMapQuickItem
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 theMapQuickItem
items?@morteza-ali-ahmadi hey, you could probably do this using visibleRegion in qml map and a geoshape cointaining all your locations :)
-
@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
geoshape
.
Is the following code correct?
property variant region: "shape()"
and I should to set my region and then
myMap.visibleRegion=region
-
@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
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 :)
-
@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
@morteza-ali-ahmadi but yes your code looks right..
-
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 :)
@MEMekaniske Thank you very much,
fitViewportToMapItems
works like a charm :) -
@MEMekaniske Thank you very much,
fitViewportToMapItems
works like a charm :)@morteza-ali-ahmadi Cool :) No problem! Happy you got it working!