Select to view content in your preferred language

How to add feature layer to map (basemap as mmpk and tif formats) using .shp file?

698
1
10-06-2020 04:39 AM
AbhijeetSatam
Occasional Contributor

I have 2 map files one is of the .mmpk format and other is .tif format. I want to add a feature layer to my map using .shp file.

m_map is declared as Esri::ArcGISRuntime::Map* m_map = nullptr;

and m_mapView  as Esri::ArcGISRuntime::MapGraphicsView* m_mapView = nullptr;

The code for feature layer is as follows:

Esri::ArcGISRuntime::LayerListModel* llModel;
Esri::ArcGISRuntime::FeatureLayer* layerA;
llModel = m_map->operationalLayers();
FeatureTable* featuretable_layerA = new ShapefileFeatureTable(pathToShpFile,this);
layerA = new FeatureLayer(featuretable_layerA,this);
connect(layerA, &FeatureLayer::doneLoading,this, [this,layerA](Error loadError)
    {
        if(!loadError.isEmpty())
            return;
        m_mapView->setViewpointCenter(layerA->fullExtent().center(),80000);

        qDebug("LAYERA CONNECTED");
    });


SimpleLineSymbol* simpleLine = new SimpleLineSymbol(SimpleLineSymbolStyle::Solid, 
                                                    QColor("red"), 3.0,layerA);
SimpleRenderer* simpleRenderer = new SimpleRenderer(simpleLine, this);
layerA->setRenderer(simpleRenderer);
llModel->append(layerA);‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

 This code works when  m_map uses the .tif file as the basemap but does not work for .mmpk format. Is .shp format only applicable to .tif basemaps?

Is any other format required to display feature layers in maps using mmpk file as basemap??.

0 Kudos
1 Reply
LucasDanzinger
Esri Frequent Contributor

shapefiles can be added as operational layers whether the basemap is a tif or the map is created from mmpk. Does the shapefile/featurelayer fail to load when you use a mmpk, or is it not rendering? If it fails to load, check the loadError.message and loadError.additionalMessage for more details.

0 Kudos