/*! * \example linesandpoints.cpp * This application demonstrates how to use Geometry objects and how to add them to a layer. * * Here are used three different point types: * - One which displays a image * - One which draws a plain circle * - One which uses a QPen to draw a circle * - One which has no markers * Then these Points were added to a LineString * * Also there is a keylistener. * * You can find this example here: MapAPI/Samples/LinesAndPoints * \image html sample_linesandpoints.png "screenshot" */ LinesAndPoints::LinesAndPoints(QWidget *parent) : QWidget(parent) { // the size which the QMapControl should fill QSize size = QSize(480,640); mc = new MapControl(size); // create layout QHBoxLayout* layout = new QHBoxLayout; layout->addWidget(mc); setLayout(layout); // create layer MapAdapter* mapadapter = new OSMMapAdapter(); Layer* l = new MapLayer("Custom Layer", mapadapter); mc->addLayer(l); // create a LineString QList<Point*> points; // Points with image points.append(new ImagePoint(8.259959, 50.001781, "images/bus_stop.png", "Mainz, Hauptbahnhof", Point::BottomLeft)); points.append(new ImagePoint(8.263758, 49.998917, "images/bus_stop.png", "Mainz, Münsterplatz", Point::BottomLeft)); points.append(new ImagePoint(8.265812, 50.001952, "images/bus_stop.png","Mainz, Neubrunnenplatz", Point::BottomLeft)); // Points with a circle points.append(new CirclePoint(8.2688, 50.004015, "Mainz, Bauhofstraße LRP", Point::Middle)); points.append(new CirclePoint(8.272845, 50.00495, "Mainz, Landtag", Point::Middle)); points.append(new CirclePoint(8.280349, 50.008173, "Mainz, Brückenkopf", Point::Middle)); // A QPen can be used to customize the QPen* pointpen = new QPen(QColor(0,255,0)); pointpen->setWidth(3); points.append(new CirclePoint(8.273573, 50.016315, 15, "Wiesbaden-Mainz-Kastel, Eleonorenstraße", Point::Middle, pointpen)); points.append(new CirclePoint(8.275145, 50.016992, 15, "Wiesbaden-Mainz-Kastel, Johannes-Goßner-Straße", Point::Middle, pointpen)); points.append(new CirclePoint(8.270476, 50.021426, 15, "Wiesbaden-Mainz-Kastel, Ruthof", Point::Middle, pointpen)); // "Blind" Points points.append(new Point(8.266445, 50.025913, "Wiesbaden-Mainz-Kastel, Mudra Kaserne")); points.append(new Point(8.260378, 50.030345, "Wiesbaden-Mainz-Amoneburg, Dyckerhoffstraße")); // A QPen also can use transparency QPen* linepen = new QPen(QColor(0, 0, 255, 100)); linepen->setWidth(5); // Add the Points and the QPen to a LineString LineString* ls = new LineString(points, "Busline 54", linepen); // Add the LineString to the layer l->addGeometry(ls); // Connect click events of the layer to this object connect(l, SIGNAL(geometryClicked(Geometry*, QPoint)), this, SLOT(geometryClicked(Geometry*, QPoint))); // Sets the view to the interesting area QList<QPointF> view; view.append(QPointF(8.24764, 50.0319)); view.append(QPointF(8.28412, 49.9998)); mc->setView(view); addZoomButtons(); }
/*! * \example mapviewer.cpp * This application is just a simple map viewer. A Mapadapter is created (OpenStreetmaps) * and added to a layer. The layer is given to the MapControl. * Two Buttons are available to adjust the zoom level. If the window is * resized the map widget will adjust its size. * * You can find this example here: QMapControl/Samples/Mapviewer * \image html sample_mapviewer.png "screenshot" */ Mapviewer::Mapviewer(QWidget *parent) : QMainWindow(parent) { // create MapControl mc = new MapControl(QSize(380, 540)); mc->showScale(true); // create mapadapter, for mainlayer and overlay mapadapter = new OSMMapAdapter(); // create a layer with the mapadapter and type MapLayer mainlayer = new MapLayer("OpenStreetMap-Layer", mapadapter); // add Layer to the MapControl mc->addLayer(mainlayer); addZoomButtons(); // show mapcontrol in mainwindow setCentralWidget(mc); }
MapDownloader::MapDownloader(QWidget *parent) : QMainWindow(parent) { resize(900,800); mc = new MapControl(frameSize()); // create mapadapter, for mainlayer and overlay mapadapter = new OSMMapAdapter(); mapAdapter = new OSMMapAdapter(); mainlayer = new MapLayer("map Layer", mapadapter); mc->addLayer(mainlayer); addZoomButtons(); setCentralWidget(mc); mc->setZoom(3); connect(mc, SIGNAL(mouseEventCoordinate(const QMouseEvent*, const QPointF)), this, SLOT(mouseEventCoordinate(const QMouseEvent*, const QPointF))); downloadListx = new QList<int>; downloadListy = new QList<int>; downloadListz = new QList<int>; updateView(); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); setWindowTitle( tr("TerraGear GUI") ); // create MapControl mc = new MapControl(QSize(458, 254)); mc->setMinimumSize(QSize(458,254)); mc->showScale(true); mapadapter = new OSMMapAdapter(); mainlayer = new MapLayer("OpenStreetMap-Layer", mapadapter); mc->addLayer(mainlayer); connect(mc, SIGNAL(boxDragged(QRectF)), this, SLOT(draggedRect(QRectF))); addZoomButtons(); mc->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); ui->mapLayout-> addWidget(mc); // restore variables from previous session loadSettings(); // TAB: Airports updateAirportRadios(); // hide the non-selected options // TAB: Construct ui->shapefilesTable->setSelectionBehavior(QAbstractItemView::SelectRows); ui->shapefilesTable->setHorizontalHeaderLabels(QStringList() << tr("Shapefile") << tr("Material")); #if QT_VERSION >= 0x050000 ui->shapefilesTable->horizontalHeader()->setSectionResizeMode( QHeaderView::Stretch); #else ui->shapefilesTable->horizontalHeader()->setResizeMode(QHeaderView::Stretch); #endif ui->shapefilesTable->horizontalHeader()->setStyleSheet("font: bold;"); ui->shapefilesTable->verticalHeader()->hide(); // create sub-directory variables dataDirectory = projectDirectory+"/data"; outpDirectory = projectDirectory+"/output"; workDirectory = projectDirectory+"/work"; // run functions on startup if (flightgearDirectory != 0) { updateMaterials(); if (airportFile.size() == 0) { // try to find apt.dat.gz file QString apfile = flightgearDirectory+"/Airports/apt.dat.gz"; QFile apf(apfile); if (apf.exists()) { airportFile = apfile; settings.setValue("paths/airportFile", airportFile); // keep the airport file found } } if (airportFile.size()) ui->aptFileField->setText(airportFile); } // re-apply the check boxes (for construct) bool ign_lm = settings.value("check/ignore_landmass").toBool(); ui->ignoreLandmassCB->setCheckState(ign_lm ? Qt::Checked : Qt::Unchecked); // Network manager _manager = new QNetworkAccessManager(this); connect(_manager, SIGNAL(finished(QNetworkReply*)), SLOT(downloadFinished(QNetworkReply*))); m_break = false; if (ui->tabWidget->currentIndex() == 1) { ui->textBrowser->hide(); mc->resize(QSize(458,254)); } // add context menu to table connect(ui->shapefilesTable, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(displayMenu(QPoint))); }
Citymap::Citymap(QWidget*) { // create MapControl mc = new MapControl(QSize(380,540)); mc->showScale(true); // display the MapControl in the application QVBoxLayout* layout = new QVBoxLayout; layout->addWidget(mc); layout->setContentsMargins(0,0,0,0); QWidget* w = new QWidget(); w->setLayout(layout); setCentralWidget(w); notepixmap = new QPixmap(QApplication::applicationDirPath() + "/images/note.png"); coord1 = QPointF(); coord2 = QPointF(); mapadapter = new OSMMapAdapter(); // create a layer with the mapadapter and type MapLayer l = new MapLayer("Custom Layer", mapadapter); mc->addLayer(l); notes = new GeometryLayer("Notes", mapadapter); createTours(); addSights(); addPubs(); addMuseums(); addZoomButtons(); createActions(); createMenus(); connect(mc, SIGNAL(viewChanged(QPointF,int)), this, SLOT(mapControlZoomChanged(QPointF,int)), Qt::QueuedConnection); mc->addLayer(notes); connect(notes, SIGNAL(geometryClicked(Geometry*, QPoint)), this, SLOT(editNote(Geometry*, QPoint))); mc->setView(QPointF(8.26,50)); mc->setZoom(13); ignoreClicks = false; addingNote = false; noteID = 0; notetextedit = new QTextEdit(mc); notetextedit->setGeometry(0,0,200,100); notepoint = new Point(0, 0, notetextedit, ".", Point::TopLeft); notepoint->setVisible(false); notes->addGeometry(notepoint); statusBar = new QStatusBar( this ); setStatusBar(statusBar); loadingProgress = new QLabel(""); statusBar->addWidget( loadingProgress ); loadingProgressTimer = new QTimer(this); connect(loadingProgressTimer, SIGNAL(timeout()), this, SLOT(updateProgress()), Qt::QueuedConnection ); loadingProgressTimer->start( 500 ); //update every 500ms cacheTiles(true); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); // create MapControl mc = new MapControl(QSize(638,370)); mc->setObjectName("MapControl"); mc->showScale(true); ui->verticalLayout->addWidget(mc); mapadapter = new GoogleMapAdapter(); //MapAdapter* mapadapter_overlay = new YahooMapAdapter("us.maps3.yimg.com", "/aerial.maps.yimg.com/png?v=2.2&t=h&s=256&x=%2&y=%3&z=%1"); // create a layer with the mapadapter and type MapLayer l = new MapLayer("Custom Layer", mapadapter); // overlay = new MapLayer("Overlay", mapadapter_overlay); // overlay->setVisible(false); mc->addLayer(l); // mc->addLayer(overlay); notes = new GeometryLayer("Sun", mapadapter); mc->addLayer(notes); QPen* pen = new QPen(QColor(0,0,255,100)); pen->setWidth(5); sunRise = new Vector(8.85,51.46, 1000, 45, "SunRiseArrow", Vector::Middle, pen); sunSet = new Vector(8.85,51.46, 1000, 45, "SunSetArrow", Vector::Middle, pen); pen = new QPen(QColor(255,0,0,100)); pen->setWidth(5); sunHeading = new Vector(8.85,51.46, 1000, 45, "SunArrow", Vector::Middle, pen); QList<Point*> points; points << sunHeading; points << sunRise; points << sunSet; LineString* sunArrows = new LineString(points, "", pen); notes->addGeometry(sunArrows); mc->setUseBoundingBox(false); mc->setView(QPointF(8.85,51.46)); mc->setZoom(10); ui->dateTimeEdit->setDateTime(QDateTime::currentDateTime()); ui->latEdit->setText("51,46"); ui->lngEdit->setText("8,85"); addZoomButtons(); setSunRiseAndSetVectors(QDateTime::currentDateTime()); setSunCurrentHeading(QDateTime::currentDateTime()); }