Пример #1
0
        /// <summary>
        /// Initializes and if necessary provisions the data needed for the application
        /// </summary>
        /// <returns></returns>
        public async Task LoadAsync()
        {
            try
            {
                await ProvisionDataAsync();
            }
            catch (System.Exception ex)
            {
                UpdateLoadStatus("Failed to provision data:\n" + ex.Message);
            }
            UpdateLoadStatus("Initializing map...");
            GeocodeHelper.Initialize();

            PictureMarkerSymbol a;
            PictureMarkerSymbol b;

            using (var markera = typeof(MapViewModel).Assembly.GetManifestResourceStream("OfficeLocator.Core.MarkerA.png"))
            {
                a = new PictureMarkerSymbol(await RuntimeImage.FromStreamAsync(markera))
                {
                    Width = 20, Height = 20
                };
            }
            using (var markerb = typeof(MapViewModel).Assembly.GetManifestResourceStream("OfficeLocator.Core.MarkerB.png"))
            {
                b = new PictureMarkerSymbol(await RuntimeImage.FromStreamAsync(markerb))
                {
                    Width = 20, Height = 20
                };
            }

            Overlays[1].Graphics.Add(new Graphic()
            {
                Symbol = a
            });                                                     //From
            Overlays[1].Graphics.Add(new Graphic()
            {
                Symbol = b
            });                                                     //To
            try
            {
                await InitializeMap();

                InitializeScene();
                IsLoaded = true;
                UpdateLoadStatus("");
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsLoaded)));
                DoStartupZoomIn();
            }
            catch (System.Exception ex)
            {
                System.Diagnostics.Debug.WriteLine($"An unexpected error occured while loading the map: {ex.Message}");
                UpdateLoadStatus(ex.Message);
            }
        }
Пример #2
0
        public async void GeocodeToLocation(string text)
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;
            Overlays[1].Graphics[1].Geometry = await GeocodeHelper.GeocodeAsync(text);

            CalculateRoute();
            IsBusy = false;
            ZoomToData();
        }
        /// <summary>
        /// Initializes and if necessary provisions the data needed for the application
        /// </summary>
        /// <returns></returns>
        public async Task LoadAsync()
        {
            try
            {
                await ProvisionDataAsync();
            }
            catch (System.Exception ex)
            {
                UpdateLoadStatus("Failed to provision data:\n" + ex.Message);
            }
            UpdateLoadStatus("Initializing map...");
            GeocodeHelper.Initialize();
#if NETFX_CORE
            var a = new PictureMarkerSymbol(new Uri("ms-appx:///MarkerA.png"));
            var b = new PictureMarkerSymbol(new Uri("ms-appx:///MarkerB.png"));
            a.Width = a.Height = b.Width = b.Height = 20;
#else
            var a = new SimpleMarkerSymbol()
            {
                Color = Colors.Red, Size = 20
            };
            var b = new SimpleMarkerSymbol()
            {
                Color = Colors.Green, Size = 20
            };
#endif
            Overlays[1].Graphics.Add(new Graphic()
            {
                Symbol = a
            });                                                     //From
            Overlays[1].Graphics.Add(new Graphic()
            {
                Symbol = b
            });                                                     //To
            try
            {
                await InitializeMap();

                InitializeScene();
                IsLoaded = true;
                UpdateLoadStatus("");
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsLoaded)));
                DoStartupZoomIn();
            }
            catch (System.Exception ex)
            {
                System.Diagnostics.Debug.WriteLine($"An unexpected error occured while loading the map: {ex.Message}");
                UpdateLoadStatus(ex.Message);
            }
        }
Пример #4
0
        private async void AutocompleteTextView_TextChanged(object sender, Android.Text.TextChangedEventArgs e)
        {
            var autocompleteTextView = (AutoCompleteTextView)sender;

            if (string.IsNullOrWhiteSpace(e.Text.ToString()))
            {
                var adapter = autocompleteTextView.Adapter as SuggestGeocodeCompleteAdapter;
                adapter.UpdateList(new string[] { });
            }
            else
            {
                string text        = e.Text.ToString();
                var    suggestions = await GeocodeHelper.SuggestAsync(e.Text.ToString());

                var adapter = autocompleteTextView.Adapter as SuggestGeocodeCompleteAdapter;
                adapter.UpdateList(suggestions);
            }
        }