/** * @RDE_HEADER@ * Declaration/Definition * $Id$ * $HeadURL$ * $Author$ */ #include #include #include #include #include #include #include #include "Map.h" #include "MapGraphicsView.h" #include "ArcGISLocalTiledLayer.h" #include "event_mouse_navigator.h" int main (int argc, char* argv[]) { QApplication app ( argc, argv ); // under windows for ArcGIS 10.2.6 and higher #ifdef Q_OS_WIN QCoreApplication::setAttribute( Qt::AA_UseOpenGLES ); #endif QApplication::setApplicationName(QString("Esri - Map Touch Test")); QWidget top; QHBoxLayout * layout = new QHBoxLayout( &top ); QTextEdit * console = new QTextEdit( &top ); EsriRuntimeQt::Map * map = new EsriRuntimeQt::Map(); EsriRuntimeQt::MapGraphicsView * mapGraphicsView = EsriRuntimeQt::MapGraphicsView::create(map); QString samplePath = EsriRuntimeQt::ArcGISRuntime::installDirectory(); samplePath.append("/sdk/samples/data/tpks/Topographic.tpk"); samplePath = QDir::toNativeSeparators(samplePath); if (!QFileInfo::exists(samplePath)) { qDebug() << "Load map from not existing file" << samplePath; } EsriRuntimeQt::ArcGISLocalTiledLayer * geoMapBaseLayer = new EsriRuntimeQt::ArcGISLocalTiledLayer( samplePath, &top ); geoMapBaseLayer -> setName( "Base Map Layer" ); QObject::connect( geoMapBaseLayer, &EsriRuntimeQt::ArcGISLocalTiledLayer::layerCreateError , []() { qDebug() << "Loading map failed!"; } ); QObject::connect( geoMapBaseLayer, &EsriRuntimeQt::ArcGISLocalTiledLayer::layerCreateComplete, []() { qDebug() << "Loading map finished."; } ); map->setAnimationMode( EsriRuntimeQt::AnimationMode::NoAnimation ); map->addLayer(geoMapBaseLayer); map->setWrapAroundEnabled(true); map->grid()->setType( EsriRuntimeQt::GridType::Mgrs ); map->grid()->setVisible(false); mapGraphicsView -> setFixedSize( 600, 400 ); SituationMap::RB::EventMouseNavigator * eventDispatcher = new SituationMap::RB::EventMouseNavigator( mapGraphicsView->viewport(), map ); layout->addWidget( mapGraphicsView ); layout->addWidget( console ); top.show(); QPushButton * button = new QPushButton( QString("Touch or Click me"), nullptr ); // button must be toplevel widget QGraphicsProxyWidget * widgetProxy = mapGraphicsView->scene()->addWidget( button ); widgetProxy -> setPos( mapGraphicsView->mapToScene(250,200) ); QObject::connect( button, &QPushButton::clicked, [console]() { console->append(QString("Button has been clicked.\n")); }); QObject::connect( button, &QPushButton::pressed, [console]() { console->append(QString("Button has been pressed.\n")); }); return app.exec(); } // main (int argc, char* argv[])