コード例 #1
0
        private async void TourButton_Click(object sender, RoutedEventArgs e)
        {
            // Get the selected track info
            TrackInfo ti = ArtistListBox.SelectedItem as TrackInfo;

            // Filter the tour layer by artist ID
            string artistFilter = "artistid = '" + ti.ArtistId + "'";

            _tourLayer.DefinitionExpression = artistFilter;
            _tourLayer.IsVisible            = true;

            // Zoom to the extent of the tour
            QueryParameters query = new QueryParameters
            {
                WhereClause = artistFilter
            };
            FeatureQueryResult tourQueryResult = await _tourLayer.FeatureTable.QueryFeaturesAsync(query);

            // Zoom to the first result (assumed to be the next event?)
            Feature nextEvent = tourQueryResult.FirstOrDefault();

            if (nextEvent == null)
            {
                return;
            }

            // Zoom to the event
            await ArtistMapView.SetViewpointCenterAsync(nextEvent.Geometry as MapPoint);
        }
コード例 #2
0
        private async void ArtistListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            // Get the selected track info
            TrackInfo ti = ArtistListBox.SelectedItem as TrackInfo;

            // If the track info is good, show it in the info panel
            if (ti == null)
            {
                return;
            }
            ArtistInfoPanel.DataContext = ti;

            // Filter the layers by artist ID
            string artistFilter = "artistid = '" + ti.ArtistId + "'";

            _artistHometownLayer.DefinitionExpression = artistFilter;
            _listenerLayer.DefinitionExpression       = artistFilter;
            _otherLocationsLayer.DefinitionExpression = artistFilter;

            // Make sure all layers are visible except tours
            _artistHometownLayer.IsVisible = true;
            _listenerLayer.IsVisible       = true;
            _otherLocationsLayer.IsVisible = true;
            _tourLayer.IsVisible           = false;

            // Dismiss any tour event callouts
            ArtistMapView.DismissCallout();

            // Zoom the main map to the artist hometown
            await ArtistMapView.SetViewpointCenterAsync(ti.HometownLocation, 250000);

            // Zoom the listener map to the extent of features in the listener layer
            QueryParameters query = new QueryParameters
            {
                WhereClause = artistFilter
            };

            FeatureQueryResult listenerQueryResult = await _listenerLayer.FeatureTable.QueryFeaturesAsync(query);

            EnvelopeBuilder extentBuilder = new EnvelopeBuilder(ListenersMapView.SpatialReference);

            foreach (Feature f in listenerQueryResult)
            {
                extentBuilder.UnionOf(f.Geometry.Extent);
            }

            Envelope extent = extentBuilder.ToGeometry();

            if (extent.IsEmpty)
            {
                return;
            }

            await ListenersMapView.SetViewpointGeometryAsync(extentBuilder.ToGeometry(), 30);
        }
コード例 #3
0
        private async void ArtistMapViewTapped(object sender, GeoViewInputEventArgs e)
        {
            // Get the user-tapped location
            MapPoint mapLocation = e.Location;

            // Perform an identify across all layers, taking up to 10 results per layer.
            IdentifyLayerResult tourClickResult = await ArtistMapView.IdentifyLayerAsync(_tourLayer, e.Position, 15, false, 1);

            if (tourClickResult.GeoElements.Count == 0)
            {
                return;
            }

            // Get the clicked tour event
            GeoElement tourEvent = tourClickResult.GeoElements.FirstOrDefault();

            await(tourEvent as ArcGISFeature).LoadAsync();

            // Format the callout string to show info for this event
            string tourEventDescription = string.Format("Date: {0:D}\nVenue: {1}", tourEvent.Attributes["eventdate"], tourEvent.Attributes["venuename"].ToString());

            // Create a new callout definition using the formatted string
            CalloutDefinition tourEventCalloutDefinition = new CalloutDefinition(tourEvent.Attributes["artistname"].ToString() + " - Let's Rock Tour", tourEventDescription);
            // tourEventCalloutDefinition.Icon = tourImage;
            FrameworkElement tourPanel      = Application.Current.FindResource("TourCalloutPanel") as FrameworkElement;
            TextBlock        titleTextBlock = FindChild <TextBlock>(tourPanel, "TitleTextBlock");
            TextBlock        dateTextBlock  = FindChild <TextBlock>(tourPanel, "EventDateTextBlock");
            TextBlock        venueTextBlock = FindChild <TextBlock>(tourPanel, "EventVenueTextBlock");

            System.Windows.Controls.Image tourImage = FindChild <System.Windows.Controls.Image>(tourPanel, "TourImage");

            titleTextBlock.Text = tourEvent.Attributes["artistname"].ToString() + " - Let's Rock Tour";
            dateTextBlock.Text  = string.Format("{0:D}", tourEvent.Attributes["eventdate"]);
            venueTextBlock.Text = tourEvent.Attributes["venuename"].ToString();

            BitmapImage poster = new BitmapImage();

            poster.BeginInit();
            poster.UriSource = new Uri(@"https://ih1.redbubble.net/image.790993324.9948/flat,128x,075,f-pad,128x128,f8f8f8.u2.jpg");
            poster.EndInit();
            tourImage.Source = poster;

            // Display the callout
            ArtistMapView.ShowCalloutAt(mapLocation, tourPanel);
            //ArtistMapView.ShowCalloutAt(mapLocation, tourEventCalloutDefinition);
        }