How to consume mobile map package in Xamarin.forms

2226
7
Jump to solution
06-14-2016 12:39 PM
MichaelMitchell1
New Contributor III

Using the samples I can utilize a FeatureLayer but haven't been able to figure out how to load a mobile map package.  Any suggestions?

Thanks

0 Kudos
1 Solution

Accepted Solutions
AlexanderNohe1
Occasional Contributor III

I see what you are asking.  It is a static method so it would be something more like this:

_mappackage = await MobileMapPackage.OpenAsync("D:\\Source code\\Data\\Test.mmpk"); 

View solution in original post

7 Replies
MichaelMitchell1
New Contributor III
            _mappackage = await OpenAsync("D:\\Source code\\Data\\Test.mmpk");
            var mapPackageUri = new Uri(_mappackage.Item.Url);
            var mapTable = new ServiceFeatureTable(mapPackageUri);
            var mapPackageFeatureLayer = new FeatureLayer(mapTable);
            myMap.OperationalLayers.Add(mapPackageFeatureLayer);

More specifically I'm not sure what to do for the OpenAsync method.

0 Kudos
AlexanderNohe1
Occasional Contributor III

I don't understand your question.  What do you mean you are not sure what to do?

This MSDN documentation may help better explain how await works:

await (C# Reference)

0 Kudos
MichaelMitchell1
New Contributor III

I'll dig into that a bit more because I'm sure this stems from my lack of experience in c# and Xamarin.  In my bit of code above I get the error that OpenAsync does not exist in the current context.  I'm not sure if I need to import something else or if I need to define OpenAsync myself.

0 Kudos
AlexanderNohe1
Occasional Contributor III

I see what you are asking.  It is a static method so it would be something more like this:

_mappackage = await MobileMapPackage.OpenAsync("D:\\Source code\\Data\\Test.mmpk"); 

MichaelMitchell1
New Contributor III

Thanks a lot Alexander.  That's what I needed.

0 Kudos
AlexanderNohe1
Occasional Contributor III

Awesome!  Glad that helped!  You may want to visit the Early Adopter community as well for more direct feedback with the development team.

ArcGIS Runtime SDK for Xamarin

0 Kudos
MichaelMitchell1
New Contributor III

I'm working off of the Xamarin.Forms api found at (MobileMapPackage.OpenAsync Method )

0 Kudos