Initializing map from map package

286
2
09-28-2017 01:41 PM
AlexZlotin1
New Contributor II

I am using the following code to load map from a mobile package:

MobileMapPackage mmpk = await MobileMapPackage.OpenAsync(packagePath);
Map map = mmpk.Maps[0];
MainMapView.Map = map;

while (Double.IsNaN(MainMapView.MapScale))
    System.Threading.Thread.Sleep(250);
scale.Text = Convert.ToInt32(MainMapView.MapScale).ToString("N0");

After the map is assigned to the map view, I expect the view to initialize and return a valid MapScale. This does not happen however, the while loop above is never exited. If I comment out the three lines above, the map is loaded in the view as expected, but a valid MapScale is returned only after I pan or zoom the map. Is there a way to access MapScale immediately after the map is loaded?

Any suggestions are welcome. I am using WPF Runtime 100.1.0.

0 Kudos
2 Replies
AnttiKajanus1
Regular Contributor II

How do you create the mmpk file? This is what I see when using one created through OfflineMapTask.

0 Kudos
AlexZlotin1
New Contributor II

I have solved the problem by setting map view initial extent after referencing the map package. Thanks Antti.

0 Kudos