How to load MPK File in Runtime .Net

5568
4
Jump to solution
04-16-2015 01:20 PM
JimFiddes
Occasional Contributor

I'm digging through examples on how to load a local mpk into my .net map and I don't see how to do this. There are old references to  ArcGISLocalDynamicMapServiceLayer but that isn't available now. The mpk was constructed in ArcMap 10.2 and the layers exist within a GeoDatabase. I am using 10.2.5 build of .Net as well.

If someone can point me in the right direction I would appreciate it.

Thanks,

Jim

0 Kudos
1 Solution

Accepted Solutions
AsserSwelam1
Occasional Contributor

Hi Jim,

Here is the way to add mpk layer to the map, you just need to use ArcGISDynamicMapServiceLayer and the ServiceUri will be a LocalMapService.UrlMapService

LocalMapService localMapService = new LocalMapService("mpk file path");

                await localMapService.StartAsync();

                ArcGISDynamicMapServiceLayer arcGISDynamicMapServiceLayer = new ArcGISDynamicMapServiceLayer()

                {

                    ID = "arcGISDynamicMapServiceLayer",

                    ServiceUri = localMapService.UrlMapService,

                };

  MyMapView.Map.Layers.Add(arcGISDynamicMapServiceLayer);

And there is a sample for that on GitHub​.  ArcGIS .NET Samples, in Desktop Samples > Layers > Dynamic Service Layer > ArcGIS Local Dynamic Service Layer Sample

Thanks,

Asser

View solution in original post

4 Replies
AsserSwelam1
Occasional Contributor

Hi Jim,

Here is the way to add mpk layer to the map, you just need to use ArcGISDynamicMapServiceLayer and the ServiceUri will be a LocalMapService.UrlMapService

LocalMapService localMapService = new LocalMapService("mpk file path");

                await localMapService.StartAsync();

                ArcGISDynamicMapServiceLayer arcGISDynamicMapServiceLayer = new ArcGISDynamicMapServiceLayer()

                {

                    ID = "arcGISDynamicMapServiceLayer",

                    ServiceUri = localMapService.UrlMapService,

                };

  MyMapView.Map.Layers.Add(arcGISDynamicMapServiceLayer);

And there is a sample for that on GitHub​.  ArcGIS .NET Samples, in Desktop Samples > Layers > Dynamic Service Layer > ArcGIS Local Dynamic Service Layer Sample

Thanks,

Asser

View solution in original post

JimFiddes
Occasional Contributor

When I run that code example I get this error:

It fails on the StartAsync call. Thoughts?

0 Kudos
MichaelBranscomb
Esri Frequent Contributor

Hi,

That is not an error - it is just the license protection warning. When the time comes to deploy your app, you will need to licensed your application at the Standard level (either by having an Organizational user sign in or by setting a Standard license code) and that message will no longer be displayed.

For more information see License your app—ArcGIS Runtime SDK for .NET | ArcGIS for Developers

Cheers

Mike

0 Kudos
JoeMadrigal
New Contributor II

I think Jim was talking about the "StartAsync" call (not the pop-up window).  I think you need to start a local server to run this correct?  And you need the standard level license to run a local server.

Joe

0 Kudos