private async void Initialize()
        {
            if (await ApiKeyManager.CheckKeyValidity() != ApiKeyStatus.Valid)
            {
                await new MessageDialog2("Please use the settings dialog to configure an API Key.", "Error").ShowAsync();
                return;
            }

            // Create new Map with basemap.
            Map myMap = new Map(Basemap.CreateImageryWithLabels());

            // Enable tap-for-info pattern on results.
            MyMapView.GeoViewTapped += MyMapView_GeoViewTapped;

            // Assign the map to the MapView.
            MyMapView.Map = myMap;

            try
            {
                // Initialize the LocatorTask with the provided service Uri.
                _geocoder = await LocatorTask.CreateAsync(_serviceUri);

                // Enable UI controls now that the geocoder is ready.
                AutoSuggestBox.IsEnabled            = true;
                AutoSuggestBox.IsSuggestionListOpen = true;
            }
            catch (Exception e)
            {
                await new MessageDialog2(e.ToString(), "Error").ShowAsync();
            }
        }
        private async void Initialize()
        {
            if (await ApiKeyManager.CheckKeyValidity() != ApiKeyStatus.Valid)
            {
                await new MessageDialog2("Please use the settings dialog to configure an API Key.", "Error").ShowAsync();
                return;
            }

            // Add event handler for when this sample is unloaded.
            Unloaded += SampleUnloaded;

            // Create new Map with basemap
            Map myMap = new Map(Basemap.CreateStreets());

            // Subscribe to location changed event so that map can zoom to location
            MyMapView.LocationDisplay.LocationChanged += LocationDisplay_LocationChanged;

            // Enable location display
            MyMapView.LocationDisplay.IsEnabled = true;

            // Enable tap-for-info pattern on results
            MyMapView.GeoViewTapped += MyMapView_GeoViewTapped;

            // Assign the map to the MapView
            MyMapView.Map = myMap;

            // Initialize the LocatorTask with the provided service Uri
            _geocoder = await LocatorTask.CreateAsync(_serviceUri);

            // Enable all controls now that the locator task is ready
            SearchEntry.IsEnabled      = true;
            LocationEntry.IsEnabled    = true;
            SearchButton.IsEnabled     = true;
            SearchViewButton.IsEnabled = true;
        }
        private async void Initialize()
        {
            if (await ApiKeyManager.CheckKeyValidity() != ApiKeyStatus.Valid)
            {
                await new MessageDialog2("Please use the settings dialog to configure an API Key.", "Error").ShowAsync();
                return;
            }

            // Create new Map with basemap.
            Map myMap = new Map(Basemap.CreateImageryWithLabels());

            // Provide used Map to the MapView.
            MyMapView.Map = myMap;

            // Add a graphics overlay to the map for showing where the user tapped.
            MyMapView.GraphicsOverlays.Add(new GraphicsOverlay());

            // Enable tap-for-info pattern on results.
            MyMapView.GeoViewTapped += MyMapView_GeoViewTapped;

            // Initialize the LocatorTask with the provided service Uri.
            try
            {
                _geocoder = await LocatorTask.CreateAsync(_serviceUri);
            }
            catch (Exception e)
            {
                await new MessageDialog2(e.ToString(), "Error configuring geocoder").ShowAsync();
            }

            // Set the initial viewpoint.
            await MyMapView.SetViewpointCenterAsync(34.058, -117.195, 5e4);
        }
        private async Task CheckApiKey()
        {
            // Attempt to load a locally stored API key.
            await ApiKeyManager.TrySetLocalKey();

            // Check that the current API key is valid.
            ApiKeyStatus status = await ApiKeyManager.CheckKeyValidity();

            if (status != ApiKeyStatus.Valid)
            {
                PromptForKey();
            }
        }
        private async Task CheckApiKey()
        {
            // Attempt to load a locally stored API key.
            await ApiKeyManager.TrySetLocalKey();

            // Check that the current API key is valid.
            ApiKeyStatus status = await ApiKeyManager.CheckKeyValidity();

            if (status != ApiKeyStatus.Valid)
            {
                NavigationController.PushViewController(new ApiKeyPrompt(), true);
            }
        }
예제 #6
0
        private async Task UpdateValidityText()
        {
            ApiKeyStatus status = await ApiKeyManager.CheckKeyValidity();

            if (status == ApiKeyStatus.Valid)
            {
                Status.Text = "API key is valid";
            }
            else
            {
                Status.Text = "API key is invalid";
            }
            CurrentKeyText.Text = Esri.ArcGISRuntime.ArcGISRuntimeEnvironment.ApiKey;
        }