示例#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 MyMapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs e)
        {
            this.MyMapView.GraphicsOverlays[0].Graphics.Clear();

            QueryParameters queryParameters = new QueryParameters();

            queryParameters.Geometry = e.Location;
            string sum = string.Empty;
            List <CalloutDefinition> calloutDefinitions = new List <CalloutDefinition>();
            //List<Feature> features = new List<Feature>();
            StringBuilder stringBuilder = new StringBuilder();

            this.ViewModel.Fields.Clear();
            foreach (var table in this.ViewModel.ServiceFeatureTables)
            {
                FeatureTable arcGISFeatureTable = table as FeatureTable;
                FeatureLayer layer = table.Layer as FeatureLayer;
                layer.ClearSelection();
                if (this.ViewModel.EsriMap.OperationalLayers.Contains(layer))
                {
                    string[]           outputFields = { "*" };
                    FeatureQueryResult fqr          = await table.QueryFeaturesAsync(queryParameters, QueryFeatureFields.LoadAll);

                    Feature feature = fqr.FirstOrDefault();
                    if (feature != null)
                    {
                        stringBuilder.Append(feature.Attributes.First().Value + Environment.NewLine);
                        //features.Add(feature);
                        layer.SelectFeature(feature);
                        StringBuilder       sb      = new StringBuilder();
                        FeatureTableWrapper wrapper = new FeatureTableWrapper();
                        wrapper.TableName = layer.FeatureTable.TableName;
                        wrapper.KeyValues = new Dictionary <string, string>();
                        foreach (var att in feature.Attributes)
                        {
                            if (!wrapper.KeyValues.ContainsKey(att.Key))
                            {
                                wrapper.KeyValues.Add(att.Key, att.Value.ToString());
                            }
                        }
                        this.ViewModel.Fields.Add(wrapper);
                    }
                }
            }
            this.MyMapView.GraphicsOverlays[0].Graphics.Add(new Esri.ArcGISRuntime.UI.Graphic(e.Location));
            CalloutDefinition callout = new CalloutDefinition(this.ViewModel.GeoviProject.Name, stringBuilder.ToString());
            Point             point   = new Point(e.Location.X, e.Location.Y);

            this.MyMapView.ShowCalloutAt(e.Location, callout);
        }