0

I'm currently working on a Qt Quick application that will provide a map viewer. I want to create irregular shapes (more than one shape) and then put them on the map. is it a good way to do this with QQuickPaintedItem (Writing QML Extensions with C++) or is there another way to do this? or is it anyway to create my own shape like MapCircle (for example MapCustom) in Map Viewer?

Behzad
  • 121
  • 1
  • 16
  • What kind of irregular shapes do you mean ?, why do not you use MapPolygon? – eyllanesc Dec 18 '17 at 06:10
  • Thank you for your comment (@eyllanesc), I want to use more than one irregular shape (all shapes have the same shape), but instead of repeating them in the Qml map (because of poor performance), I want to paint all of them in one QQucikItem. – Behzad Dec 18 '17 at 06:24
  • 1
    If you want to create your items from C ++, the appropriate option is QQuickPaintedItem. What kind of answers do you expect? – eyllanesc Dec 18 '17 at 06:26
  • first I'm finding the appropriate way (I got the answer), second, how can I convert the position of my irregular shapes to Qt location coordinate? – Behzad Dec 18 '17 at 06:31
  • 1
    You should inherit from the class QDeclarativeGeoMapItemView, but this is a class that is in the private part of Qt. – eyllanesc Dec 18 '17 at 06:43
  • first I tried to create my shape with QDeclarativeGeoMapItemView and I faced this is a private part of their project. – Behzad Dec 18 '17 at 06:58
  • If you're worried about performance you should use `QQuickItem`, not `QQuickPaintedItem`. But how do you suppose to synchronize your item with the map (moving, zooming etc.)? – folibis Dec 18 '17 at 07:55
  • That is my major problem. Actually I'm looking a way to create my custom shape, for example, MapCustom like MapCircle in Qml. – Behzad Dec 18 '17 at 07:58
  • I don't think you will be able to create some geo shape better then Qt guys. Of course I don't know your skills, may be you actually can. At best you'll just do the same. But I advice to use one of existing item like `MapPolygon` – folibis Dec 18 '17 at 08:02

1 Answers1

0

If your shape does not have to be georeferenced (like the vertices do not have to be actual geo coordinates) but you simply want a placeholder looking special, you may want to give QtQuick Shapes a go

Pa_
  • 641
  • 1
  • 5
  • 17
  • But @Paul I want to create my own shape that derives from GeoMapItemView. – Behzad Dec 24 '17 at 05:46
  • @Behzad please read your comment again :-) Are you sure you want to reimplement QGeoMapItemView? That's a view that draws nothing by default, but requires a delegate. If you mean, create your own shape that derives from QGeoMapItemBase, then you should be more specific on your use case. Should it be georeferenced or not? can you make an example for it? – Pa_ Dec 24 '17 at 18:51
  • You're right @Paul, my comment is a little vague. I want to create a thousand shapes as one item in QML that should be georeferenced. In other words, instead of repeating my shape in the Qml map (because of poor performance), I want to create all my shape as one item and show it on the map. I also want to synchronize my item with the map (moving, zooming etc.). That is why it should be georeferenced. – Behzad Dec 25 '17 at 05:59
  • Sounds like what you need is a sort of MultiPolygon object, where you can have multiple separate paths in the same item? How dynamic do your shapes have to be? Once created, are they supposed to be static? – Pa_ Dec 25 '17 at 09:28
  • all my shape have to be dynamic. I consider anchoring my map Item as a fill parent (main map)(separately layer on the whole map). Therefore I can draw all my thousand shapes on the map as one item instead of repeating them. – Behzad Dec 25 '17 at 10:21
  • please define dynamic.. does each shape change its data (vertex coordinates) over time? If that's the case, i'm afraid that the only supported approach QtLocation currently offers is MapItemView + MapPolygon. If you want to create such a map item, you have to subclass QGeoMapItemBase, but then you will be on your own – Pa_ Dec 25 '17 at 15:33
  • Yes, my shape changes its data over time. But QGeoMapItemBase is a class that is in the private part of Qt. – Behzad Dec 27 '17 at 14:15