AnsweredAssumed Answered

How to wait for MapView to Load?

Question asked by mjk5000 on Oct 24, 2017
Latest reply on Oct 25, 2017 by UHarano-esristaff

In my configuration project, my startup page allows a user to pick a "Location", using this location I create a new project for them.  I then want to get the MapView and load up some feature layers for that location and zoom to that location.  But it seems i have to wait for the Map to load before i can do what I want.  


So I call this Command from my xaml BlankProjectCommand


public ICommand BlankProjectCommand
         return new RelayCommand((args) => BlankSelectionViewModelHelper.NewBlankProject(_Location), () => true); ;


Then it returns this function NewBlankProject, but the following function wont work fully because i cant reference the MapView.Active.Map as I want to load some feature layers for the Location and zoom to that location.  Is there anyway I can wait for the map to load after var newProject = await Project.CreateAsync(cps);


internal static async void NewBlankProject(string inLocation)
     string defaultName = inLocation;
     string defaultFolder = DefaultFolder();
     string templatePath = GetDefaultMapTemplate(); //Map

     if (!string.IsNullOrEmpty(defaultFolder) && !string.IsNullOrEmpty(templatePath))
          var cps = new CreateProjectSettings()

               Name = defaultName,
               LocationPath = DefaultFolder(),
               TemplatePath = GetDefaultMapTemplate()

          var newProject = await Project.CreateAsync(cps);

          if (MapView.Active != null && MapView.Active.Map != null)
               MapSettings newMapSettings = new MapSettings();
               newMapSettings.PlantCode = inPlantCode;
               newMapSettings.HarvestYear = inHarvestYear;
               newMapSettings.HarvestTrimester = inHarvestTrimester;
               newMapSettings.MaterialGroup = inMaterialGroup;
               newMapSettings.Environment = Settings.CurrentEnvironment;

               List<UserPlantData> UserPlantDataList = new List<UserPlantData>();
               UserPlantDataList = await WebServiceUtility.GetUserPlantDataAsync();

               if (!newMapSettings.Equals(Settings.CurrentMapSettings))
                    await FeatureServiceManagement.LoadFeatureServiceAsync(newMapSettings);
                    await Navigation.ZoomToPlantExtentAsync();