Beispiel #1
0
        private async void MyMapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs e)
        {
            try
            {
                // Perform the identify operation
                IdentifyLayerResult myIdentifyResult = await MyMapView.IdentifyLayerAsync(_wmsLayer, e.Position, 20, false);

                // Return if there's nothing to show
                if (myIdentifyResult.SublayerResults[1].GeoElements.Count < 1)
                {
                    return;
                }

                // Retrieve the identified feature, which is always a WmsFeature for WMS layers
                //WmsFeature identifiedFeature = (WmsFeature)myIdentifyResult.SublayerResults[0].GeoElements[0].Attributes.Values;
                var identifiedFeature = myIdentifyResult.SublayerResults
                                        .Select(x => x.GeoElements.Where(y => y.Attributes.Values.Contains("РГО")).FirstOrDefault().Attributes);

                var identifiedFeature2 = myIdentifyResult.SublayerResults[1].GeoElements.Where(x => x.Attributes.Count == 17).FirstOrDefault().Attributes;
                var identifiedFeature3 = myIdentifyResult.SublayerResults.Select(x => x.GeoElements.Where(y => y.Attributes.Count == 17).FirstOrDefault().Attributes);
                var coordinateX        = identifiedFeature2.Where(x => x.Key == "x").FirstOrDefault().Value.ToString();
                var coordinateY        = identifiedFeature2.Where(x => x.Key == "y").FirstOrDefault().Value.ToString();
                var pointNumber        = identifiedFeature2.Where(x => x.Key == "geoptnum").FirstOrDefault().Value.ToString();

                var clickedPoint = new Point();
                clickedPoint.CoordinateX = coordinateX;
                clickedPoint.CoordinateY = coordinateY;
                clickedPoint.Number      = pointNumber;

                var StakeOutViewModel = new StakeOutViewModel(clickedPoint);
                await Navigation.PushAsync(new StakeOutPage(StakeOutViewModel));

                // Retrieve the WmsFeature's HTML content
                // string htmlContent = identifiedFeature/*.Attributes["HTML"].ToString()*/;

                // Note that the service returns a boilerplate HTML result if there is no feature found.
                // This test should work for most arcGIS-based WMS services, but results may vary.
                //if (!htmlContent.Contains("OBJECTID"))
                {
                    // Return without showing the result
                    //await Navigation.PushAsync(new WmsIdentifyResultDisplayPage(htmlContent)
                }

                // Show a page with the HTML content
                // await Navigation.PushAsync(new WmsIdentifyResultDisplayPage(htmlContent));
            }
            catch (Exception ex)
            {
                //await Application.Current.MainPage.DisplayAlert("Error", ex.ToString(), "OK");
            }
        }
        public MainPageViewModel()
        {
            Points = new ObservableCollection <Point>();

            SavePointCommand = new Command(() =>
            {
                Points.Add(new Point {
                    CoordinateX = this.CoordinateX, CoordinateY = this.CoordinateY, Number = this.Number
                });
                CoordinateX = string.Empty;
                CoordinateY = string.Empty;
                Number      = string.Empty;
            },
                                           () => !string.IsNullOrEmpty(CoordinateX) && !string.IsNullOrEmpty(CoordinateY) && !string.IsNullOrEmpty(Number));

            ErasePointsCommand = new Command(() => Points.Clear());


            GoToMapCommand = new Command(async() =>
            {
                await Application.Current.MainPage.Navigation.PushAsync(new MapPage());
            });


            PointSelectedCommand = new Command(async() =>
            {
                if (SelectedPoint is null)
                {
                    return;
                }

                var detailViewModel = new StakeOutViewModel(SelectedPoint);

                await Application.Current.MainPage.Navigation.PushAsync(new StakeOutPage(detailViewModel));

                SelectedPoint = null;
            });
        }
Beispiel #3
0
        public StakeOutPage(StakeOutViewModel viewModel)
        {
            InitializeComponent();

            BindingContext = viewModel;
        }