Select to view content in your preferred language

How to consume mobile map package in Xamarin.forms

2544
7
Jump to solution
06-14-2016 12:39 PM
MichaelMitchell1
Deactivated User

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
Honored Contributor

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
Deactivated User
            _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
Honored Contributor

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
Deactivated User

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
Honored Contributor

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
Deactivated User

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

0 Kudos
AlexanderNohe1
Honored Contributor

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
Deactivated User

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

0 Kudos