/// <summary>
        /// Gets a boundary from the Geodata API.
        /// </summary>
        private void GetGeodataBoundary_Clicked(object sender, RoutedEventArgs e)
        {
            var request = new GetBoundaryRequest()
            {
                EntityType        = (BoundaryEntityType)Enum.Parse(typeof(BoundaryEntityType), ((string)(GeodataEntityTypeCbx.SelectedItem as ComboBoxItem).Content)),
                LevelOfDetail     = int.Parse((string)(GeodataLevelOfDetailCbx.SelectedItem as ComboBoxItem).Content),
                UserRegion        = (string)(GeodataRegionCbx.SelectedItem as ComboBoxItem).Content,
                GetAllPolygons    = (GeodataGetPolysChbx.IsChecked.HasValue)? GeodataGetPolysChbx.IsChecked.Value : false,
                GetEntityMetadata = (GeodataGetMetadataChbx.IsChecked.HasValue)? GeodataGetMetadataChbx.IsChecked.Value : false,
                Culture           = "en-US"
            };

            double lat, lon;

            if (!string.IsNullOrEmpty(GeodataLatTbx.Text) && !string.IsNullOrEmpty(GeodataLonTbx.Text) &&
                double.TryParse(GeodataLatTbx.Text, out lat) && double.TryParse(GeodataLonTbx.Text, out lon))
            {
                request.Coordinate = new BingMapsSDSToolkit.GeodataLocation(lat, lon);
            }
            else if (!string.IsNullOrWhiteSpace(GeodataAddressTbx.Text))
            {
                request.Address = GeodataAddressTbx.Text;
            }

            if (request.Coordinate != null || !string.IsNullOrWhiteSpace(request.Address))
            {
                MakeGeodataRequest(request);
            }
            else
            {
                MessageBox.Show("Invalid location information provided.");
            }
        }
        /// <summary>
        /// Makes a request to get boundary data from the Geodata API.
        /// </summary>
        private async void MakeGeodataRequest(GetBoundaryRequest request)
        {
            Clear();
            OutputTab.IsSelected = true;

            try
            {
                var response = await GeodataManager.GetBoundary(request, BingMapsKey);

                if (response != null && response.Count > 0)
                {
                    var locs = new List <Microsoft.Maps.MapControl.WPF.Location>();

                    var sb = new StringBuilder();
                    sb.AppendFormat("Found {0} result(s) for query.\r\n\r\nResults:\r\n", response.Count);

                    for (int i = 0; i < response.Count; i++)
                    {
                        var r = response[i];

                        sb.AppendFormat("[{0}]\r\n", i);

                        if (r.Primitives != null)
                        {
                            sb.AppendFormat("\tConsists of {0} Polygons", r.Primitives.Length);

                            int numPoints = 0;

                            foreach (var p in r.Primitives)
                            {
                                var poly = p.GetPolygon();

                                numPoints += int.Parse(p.NumPoints);

                                var shapes = CreateComplexPolygon(poly);

                                if (shapes != null)
                                {
                                    foreach (var s in shapes)
                                    {
                                        MyMap.Children.Add(s);
                                    }

                                    locs.AddRange(shapes[0].Locations);
                                }
                            }

                            sb.AppendFormat(" with {0} points\r\n\r\n", numPoints);
                        }

                        if (r.EntityMetadata != null)
                        {
                            sb.AppendLine("\tMetadata:");

                            if (!string.IsNullOrEmpty(r.EntityMetadata.AreaSqKm))
                            {
                                sb.AppendFormat("\t\tArea in SQ KM: {0}\r\n", r.EntityMetadata.AreaSqKm);
                            }

                            if (!string.IsNullOrEmpty(r.EntityMetadata.BestMapViewBox))
                            {
                                sb.AppendFormat("\t\tBest Map View Box: {0}\r\n", r.EntityMetadata.BestMapViewBox);
                            }

                            if (!string.IsNullOrEmpty(r.EntityMetadata.OfficialCulture))
                            {
                                sb.AppendFormat("\t\tOfficial Culture: {0}\r\n", r.EntityMetadata.OfficialCulture);
                            }

                            if (!string.IsNullOrEmpty(r.EntityMetadata.PopulationClass))
                            {
                                sb.AppendFormat("\t\tPopulation Class: {0}\r\n", r.EntityMetadata.PopulationClass);
                            }

                            if (!string.IsNullOrEmpty(r.EntityMetadata.RegionalCulture))
                            {
                                sb.AppendFormat("\t\tRegional Culture: {0}\r\n", r.EntityMetadata.RegionalCulture);
                            }
                        }

                        if (r.Name != null)
                        {
                            sb.AppendLine("\tName:");

                            if (!string.IsNullOrEmpty(r.Name.Culture))
                            {
                                sb.AppendFormat("\t\tOfficial Culture: {0}\r\n", r.EntityMetadata.OfficialCulture);
                            }

                            if (!string.IsNullOrEmpty(r.Name.EntityName))
                            {
                                sb.AppendFormat("\t\tEntity Name: {0}\r\n", r.Name.EntityName);
                            }
                        }
                    }

                    OutputTbx.Text = sb.ToString();

                    SetMapView(locs);
                }
                else
                {
                    OutputTbx.Text += "No results found";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }