I want to implement an application like viber that can be able to fine user current location and send it on server. I use QT on android.
here is my code:
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QGeoPositionInfoSource *source = QGeoPositionInfoSource::createDefaultSource(0);
if (source){
qDebug() <<"source->sourceName():" << source->sourceName();
ui->textEdit->append("sourceName():" + source->sourceName());
}
else {
qDebug() <<"Error:"<< source->error();
ui->textEdit->append("Error:"+ source->error());
}
source->requestUpdate();
QGeoPositionInfo info = source->lastKnownPosition();
QGeoCoordinate coordinate = info.coordinate();
ui->textEdit->append("info.coordinate:"+ coordinate.toString());
QDateTime timestamp = info.timestamp();
ui->textEdit->append("info.timestamp():"+ timestamp.toString());
qDebug() <<"attribute:"<< info.attribute(QGeoPositionInfo::HorizontalAccurac y);
}
I finded user current location in "coordinate" variable. now my question is how can i show user current location on a map like viber?
Bookmarks