ArcGis Qt的C++开发包定义了namespace Esri::ArcGISRuntime,几乎所有的类都在此命名空间下,主要用于显示界面的类是MapGraphicsView,必须通过其构造或setMap传入一个Map对象,Map对象同时又必须依赖Basemap,也就是地图的基础图,可以有多张图叠加而成,Basemap又分为基础层和相关层,基础层一般不修改,可以看做是底图,相关层可能动态修改,一般用于显示特征等图层。不要被吓倒了,特别的简单。直接上代码吧,当前的界面类继承于QWidget
m_map = new Map(this);//构建Map对象
QList<Layer*> baseLayers;
QList<Layer*> referenceLayers;
ArcGISTiledLayer* tiledLayer = new ArcGISTiledLayer(url, this);//url为REST图层地址或tpk文件路径
baseLayers->append(tiledLayer);
ServiceFeatureTable* featrueTable = new ServiceFeatureTable(url,this);//url为特征图层地址
FeatureLayer* featureLayer = new FeatureLayer(featrueTable, this);
referenceLayers->append(featureLayer );
m_map->setBasemap( new Basemap(baseLayers,referenceLayers,this) );//设置基础图层
m_mapView = new MapGraphicsViewEx(m_map, this);//构建地图显示界面
QHBoxLayout* layout = new QHBoxLayout(this);
layout->addWidget( m_mapView );
layout->setContentsMargins( 0, 0, 0, 0 );
网友评论