1

I want ask, how I can use the MapCircle outwith the Map {} object. I want write a function, which will draw a way, and I thought, that I can do somethink like that:

function putWay (way)
{
    for (var i = 0; i < getLatitude.count - 1; i++ )
    {
        way.center {
            longtitude: getLongtitude.get(i).longtitude
            latitude: getLatitude.get(i).latitude

        }
    }
}

Way = MapCircel

getLatitude = listView, where are my data (Latitude) from DB

getLongtitude, this same but Longtitude

And way would be a MapCircel id, but it doesn't work. I think becouse of using the Map properity outwith the Map object, but maybe is a way to using the Map properity outwith Map object? Maybe a pointer or somethink like that? Maybe I can create my own object/properity?

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
  • "And way would be a MapCircel id", also way is a Mapcircel, and getLatitude is the ListView, where a have my data feom DataBase – DragonCoder Dec 28 '18 at 22:19
  • I want display this data on the map. Draw a way by using this data, which I get from database. And i wrote this data to listView. – DragonCoder Dec 28 '18 at 22:26
  • Yes, one row is a one coordinate for the mapCircel. – DragonCoder Dec 28 '18 at 22:34
  • https://github.com/DragonCoderProject/Semestralwork.git here is the project. The function is pain at the bottom – DragonCoder Dec 28 '18 at 22:40
  • If u need comments in the code or somethink, I can do this – DragonCoder Dec 28 '18 at 23:27
  • Yes, I am using the facharbeit.db and I have problem with loading the data. I thought, that I did mistake by writing the name of table, but I checked it 3 times. It is one of mistake, that I can't read datas from the facharbeit.db. And the another is with using the mapCircel outwith Map – DragonCoder Dec 28 '18 at 23:39
  • So I need only to copy the files and using it for my database, but what with the mapcircel? – DragonCoder Dec 28 '18 at 23:48
  • Need I only sqlquerymodel.h, or should i read this one: https://wiki.qt.io/How_to_Use_a_QSqlQueryModel_in_QML, but i think, that it is same – DragonCoder Dec 29 '18 at 00:05

1 Answers1

1

If it were a single item, the solution is as follows:

way.center = QtPositioning.coordinate(getLongtitude.get(i).latitude, getLatitude.get(i).longtitude)

But in your case it is not ideal because the number of points is variable.

When you have a variable amount of data it is better to use a model, I see that you wanted to use LocalStorage but unfortunately it does not allow to read a sqlite by the path, so in this case you must implement a model, in a previous answer and implement it.

Then you have to use a MapItemView and pass it to the MapCircle as a delegate.

SqlQueryModel{
        id: querymodel
        query: "select * from coordinates"
    }
// ...
Map {
    // ...
    MapItemView{
        model: querymodel
        delegate:  MapCircle {
            center: QtPositioning.coordinate(latitude, longitude)
            radius: 1.0
            color: 'blue'
            border.width: 1
        }
    }

The above is the essential but I also took the liberty to improve your code so you can find it here.

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
  • QtPositioning.coordinate(latitude, longitude), and as latitude and logitude I use my Sqlquerymodel, and then the will be drawn? – DragonCoder Dec 29 '18 at 00:55
  • Can you explain me short, when the localstorage would be fine to use? – DragonCoder Dec 29 '18 at 00:56
  • Oh okay, now i understand that. I will analyze this and when I will have question, i will ask. First thanks for your help, and sorry for my english, beacouse I know, that ti doesn't help to analyze my problem and help me – DragonCoder Dec 29 '18 at 01:05
  • Can i do it so, that the points will drawn first after button clicked? I tried querymodel.cente = QtPositioning.coordinate(latitude, longitude), but it doesn't work, need I to creat a function? – DragonCoder Dec 29 '18 at 14:01
  • Okay, but I did it so, and the Circel wans't drawn. I check it second time. I unterstand that the SqlQueryModel is only for the query to database and nothink more. Maybe I did a mistake by writing the name, I will check it, thanks – DragonCoder Dec 29 '18 at 14:34
  • I have question. After Compiling and runing my project in Qt, I can draw the points on the Map, but when I start the programm without Qt, then it doesn't work. What can be the problem? – DragonCoder Jan 06 '19 at 13:17
  • yes I mean QtCreator. I compiled my app in the QtCreator and all works, but when I try to run my app without QtCreator, then I can't draw the MapCircel on the map. – DragonCoder Jan 06 '19 at 18:59
  • Linux Mint 19 (Tara) 64 bit – DragonCoder Jan 06 '19 at 19:04