Ejemplo n.º 1
0
        private async void DisplayBusPositions()
        {
            if (busLocations != null && busLocations.Length > 0)
            {
                TextBlockMessage.Text = "Last Updated: " + DateTime.Now.ToString("h:mm tt");

                // Set the map center to the position of the closest bus
                BasicGeoposition position = new BasicGeoposition();
                position.Latitude  = busLocations[0].Latitude;
                position.Longitude = busLocations[0].Longitude;
                await MapControlLocation.TrySetViewAsync(new Geopoint(position), 17D);

                // Display markers for the position of each bus
                foreach (BusLocation bus in busLocations)
                {
                    MapIcon icon = new MapIcon();
                    icon.Location = new Geopoint(new BasicGeoposition()
                    {
                        Latitude  = bus.Latitude,
                        Longitude = bus.Longitude
                    });
                    icon.NormalizedAnchorPoint = new Point(0.5, 1.0);
                    icon.Title = "To " + bus.Destination;
                    MapControlLocation.MapElements.Add(icon);
                }
            }
            else if (errorMessage != null)
            {
                DisplayErrorMessage(errorMessage.Message);
            }
            else
            {
                DisplayErrorMessage("An error occurred when getting bus locations. Please go back and try again.");
            }
        }
Ejemplo n.º 2
0
        private async void AutoSuggestBox_SuggestionChosen(AutoSuggestBox sender, AutoSuggestBoxSuggestionChosenEventArgs args)
        {
            MapSuggestionItem selected = args.SelectedItem as MapSuggestionItem;

            chosenSuggestion = selected.name;
            mapLocationPoint = selected.point;
            await MapControlLocation.TrySetViewAsync(mapLocationPoint, 15D);
        }
Ejemplo n.º 3
0
        private async void AutoSuggestBox_SuggestionChosen(AutoSuggestBox sender, AutoSuggestBoxSuggestionChosenEventArgs args)
        {
            MapLocation selected = args.SelectedItem as MapLocation;

            sender.Text      = selected.Address.FormattedAddress;
            mapLocationPoint = selected.Point;

            await MapControlLocation.TrySetViewAsync(mapLocationPoint, 15D);
        }
Ejemplo n.º 4
0
        private async void ShowDefaultLocation()
        {
            // Defaults to Vancouver
            BasicGeoposition position = new BasicGeoposition();

            position.Latitude  = 49.2555719;
            position.Longitude = -123.1290476;
            mapLocationPoint   = new Geopoint(position);

            await MapControlLocation.TrySetViewAsync(mapLocationPoint, 13D);
        }
Ejemplo n.º 5
0
        private async void ShowDefaultLocation()
        {
            // Defaults to the University of Waterloo
            BasicGeoposition position = new BasicGeoposition();

            position.Latitude  = 43.4722854;
            position.Longitude = -80.5448576;
            mapLocationPoint   = new Geopoint(position);

            await MapControlLocation.TrySetViewAsync(mapLocationPoint, 15D);
        }
        private async void DisplayVenue(Venue venue)
        {
            ScrollViewerVenueDetails.Visibility = Visibility.Visible;
            StackPanelFoursquare.Visibility     = Visibility.Visible;

            TextBlockTitle.Text = "Viewing " + venue.name;

            foursquareUrl = venue.canonicalUrl + "?ref=" + App.foursquareClientId;

            if (venue.location != null)
            {
                MapControlLocation.MapServiceToken = App.bingMapsApiKey;

                BasicGeoposition position = new BasicGeoposition();
                position.Latitude  = venue.location.lat;
                position.Longitude = venue.location.lng;
                Geopoint mapLocationPoint = new Geopoint(position);
                await MapControlLocation.TrySetViewAsync(mapLocationPoint, 16D);

                MapIcon icon = new MapIcon();
                icon.Location = new Geopoint(new BasicGeoposition()
                {
                    Latitude  = venue.location.lat,
                    Longitude = venue.location.lng
                });
                icon.NormalizedAnchorPoint = new Point(0.5, 1.0);
                icon.Title = venue.name;
                MapControlLocation.MapElements.Add(icon);

                MapControlLocation.Visibility = Visibility.Visible;
            }

            if (venue.location.formattedAddress.Length > 0)
            {
                StackPanelAddress.Visibility = Visibility.Visible;
                TextBlockAddress1.Text       = venue.location.formattedAddress[0];
                TextBlockAddress1.Visibility = Visibility.Visible;

                if (venue.location.formattedAddress.Length >= 2)
                {
                    TextBlockAddress2.Text       = venue.location.formattedAddress[1];
                    TextBlockAddress2.Visibility = Visibility.Visible;
                }

                if (venue.location.formattedAddress.Length >= 3)
                {
                    TextBlockAddress3.Text       = venue.location.formattedAddress[2];
                    TextBlockAddress3.Visibility = Visibility.Visible;
                }
            }

            if (venue.description != null)
            {
                StackPanelAbout.Visibility      = Visibility.Visible;
                TextBlockDescription.Text       = venue.description;
                TextBlockDescription.Visibility = Visibility.Visible;
            }

            if (venue.url != null)
            {
                StackPanelAbout.Visibility = Visibility.Visible;
                TextBlockUrl.Text          = venue.url;
                TextBlockUrl.Visibility    = Visibility.Visible;
            }

            if (venue.contact != null)
            {
                if (venue.contact.formattedPhone != null)
                {
                    StackPanelContact.Visibility = Visibility.Visible;
                    TextBlockPhone.Text          = venue.contact.formattedPhone;
                    TextBlockPhone.Visibility    = Visibility.Visible;
                }

                if (venue.contact.facebookName != null)
                {
                    StackPanelContact.Visibility  = Visibility.Visible;
                    StackPanelFacebook.Visibility = Visibility.Visible;
                    TextBlockFacebook.Text        = venue.contact.facebookName;
                    TextBlockFacebook.Visibility  = Visibility.Visible;

                    if (venue.contact.facebookUsername != null)
                    {
                        facebookUrl = facebookUrl + venue.contact.facebookUsername;
                    }
                    else if (venue.contact.facebook != null)
                    {
                        facebookUrl = facebookUrl + venue.contact.facebook;
                    }
                }
                else if (venue.contact.facebookUsername != null)
                {
                    StackPanelContact.Visibility  = Visibility.Visible;
                    StackPanelFacebook.Visibility = Visibility.Visible;
                    TextBlockFacebook.Text        = venue.contact.facebookUsername;
                    TextBlockFacebook.Visibility  = Visibility.Visible;
                }

                if (venue.contact.twitter != null)
                {
                    StackPanelContact.Visibility = Visibility.Visible;
                    StackPanelTwitter.Visibility = Visibility.Visible;
                    TextBlockTwitter.Text        = "@" + venue.contact.twitter;
                    TextBlockTwitter.Visibility  = Visibility.Visible;
                }
            }
        }