How to access to a specific layer in my MPK file and display it ?

1286
9
07-17-2017 02:05 AM
ManelKEDDAR
New Contributor III

Hello every one ,

I have an (.MPK ) that contains two layers (Geom3D) and (Geom2D) , and i need to display each one of the 

them separately , I have two issues, firstly Do I have to use for each one of them( a 2D map and a 3D scene ) so therefore on my (.xaml ) I have to declare <esri: MapView> so < ESRI: SceneView>

Secondly:
I do not know how I can access a specific layer in .MPK and display it? I need an example of the code , can any one show me how to do that ? i'am using arcGis runtime Version 100.1

Thanks in advanced

i've joind a picture that explains how i want to display my layers 

Tags (3)
0 Kudos
9 Replies
PreetiMaske
Esri Contributor

In general, to Open an MMPK and access a layer, you could use the following code:

mmpk = await MobileMapPackage.OpenAsync(mmpkPath);
Esri.ArcGISRuntime.Mapping.Map map = mmpk.Maps[0];
var opLayers = map.OperationalLayers;
Layer layer = opLayers[0];

...

...

To render 3D symbols you would need a SceneView. I am not sure what is the type of data in your Geom3D layer so can't really tell for sure what will happen. If it is possible to share the data , then share the MMPK and I can give a quick try with your data.

0 Kudos
ManelKEDDAR
New Contributor III

I have a map package not a mobile map package it's (.mpk)  , i can't create a mobile map package since i have arcMap 10.4 version and not ArcGis pro  is there a solution for this  please need your help? thanks in advanced 

Preeti Maske wrote:

In general, to Open an MMPK and access a layer, you could use the following code:

mmpk = await MobileMapPackage.OpenAsync(mmpkPath);
Esri.ArcGISRuntime.Mapping.Map map = mmpk.Maps[0];
var opLayers = map.OperationalLayers;
Layer layer = opLayers[0];

...

...

 

To render 3D symbols you would need a SceneView. I am not sure what is the type of data in your Geom3D layer so can't really tell for sure what will happen. If it is possible to share the data , then share the MMPK and I can give a quick try with your data.

0 Kudos
MichaelBranscomb
Esri Frequent Contributor

Hi,

If you're using ArcMap 10.4, I would recommend using the `Create Runtime Content` tool to turn your data into a mobile geodatabase (.geodatabase file). Then you can open the geodatabase using Geodatabase.OpenAsync(), and access your data as GeodatabaseFeatureTables, which are the source for FeatureLayers in your Map or Scene. To display 2D data you should use the MapView, and for 3D data use the SceneView.

Note that in 3D, feature layers are draped on the surface (currently). Therefore you will need to query the GeodatabaseFeatureTable that contains your 3D data and create a Graphic in a GraphicOverlay for each Feature in the table. GraphicsOverlays have SurfacePlacement options in the SceneView. You will probably want to use the Absolute option (GraphicsOverlay.SceneProperties.SurfacePlacement).

For more info see:

Geodatabase.OpenAsync Method 

Geodatabase.GeodatabaseFeatureTables Property 

FeatureLayer Class 

GraphicsOverlay Class 

LayerSceneProperties.SurfacePlacement Property 

Cheers

Mike

ManelKEDDAR
New Contributor III

I used the method that you said , and i generated my (.geodatabase) file the fact is that i can display layers of my GeodatabaseFeatureTables but i can't edit them when i try table.CreateFeature(IEnumerable,Geometry); it says that the function is not supported , and when i try by  passing a template it says (An internal geodatabase error.: Create is not supported on the table) although i created my (.geodatabase)using a Standard ArcMap 10.4  I don't have the possibility to edit my featureTable can you help me please ,i've shared my Geodatabase and here's my code.Thanks in advance

private async void startLocalDB()
{


var gdb = await Esri.ArcGISRuntime.Data.Geodatabase.OpenAsync(@"C:\Users\mkeddar\Documents\ArcGIS\geodblocal\poly\data\pocdb.geodatabase");
var table = gdb .GeodatabaseFeatureTables.ElementAt(0);
await table.LoadAsync();
MapPoint locationPoint = new MapPoint(-2.708471, 56.096575, 5000, SpatialReferences.Wgs84);
var pointCollection = new Esri.ArcGISRuntime.Geometry.PointCollection(SpatialReferences.Wgs84);
pointCollection.Add(-109.048, 40.998);
pointCollection.Add(-102.047, 40.998);
pointCollection.Add(-102.037, 36.989);
pointCollection.Add(-109.048, 36.998);

var poly = new Esri.ArcGISRuntime.Geometry.Polygon(pointCollection);
var attributes = new Dictionary<string, object>();
attributes.Add("polygon", poly);
if (table.LoadStatus == Esri.ArcGISRuntime.LoadStatus.Loaded)
{
// var lyr = new FeatureLayer(table);
MyMapView.Map = new Map();
// MyMapView.Map.OperationalLayers.Add(lyr);
var template = table.FeatureTemplates.FirstOrDefault() ?? table.FeatureTypes.FirstOrDefault(t => t.Templates.Any())?.Templates?.FirstOrDefault();
var feature = table.CreateFeature(template);
await table.AddFeatureAsync(feature);

}

}

cheers

0 Kudos
ManelKEDDAR
New Contributor III

@Preeti Maske,    I've shared my (.mpk) i don't have (.mmpk) can you tell me what i can do with my (.mpk) i realy need to render a 3D SceneLayer and visualise it on the sceneView , can you tell me how to do that please

thanks

0 Kudos
PreetiMaske
Esri Contributor

Sure, I will try with the mpk and let you know what I find.

0 Kudos
PreetiMaske
Esri Contributor

Actually I gave a quick try with you sample mpk. It appears to have a featurelayer with geometry type multipatch which isn't supported in current release. Support for multipatch is slated in the plan for future releases but has no specified timeline though.

0 Kudos
ManelKEDDAR
New Contributor III

Hello every one ,

What if i will use (.slpk) sceneLayerPackage ? will it be possible ?

0 Kudos
PreetiMaske
Esri Contributor

ArcGIS 100.1 supports viewing SceneLayerPackages. But is not same as accessing a .mpk that requires use of local server. You can add/view the Slpk from a sceneview but won't be able to access a layer in that package.

0 Kudos