private async void OnMapViewTapped(object sender, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs e)
        {
            var tolerance        = 10d;   // Use larger tolerance for touch
            var maximumResults   = 1;     // Only return one graphic
            var onlyReturnPopups = false; // Don't return only popups

            // Use the following method to identify graphics in a specific graphics overlay
            IdentifyGraphicsOverlayResult identifyResults = await MyMapView.IdentifyGraphicsOverlayAsync(
                overlay,
                e.Position,
                tolerance,
                onlyReturnPopups,
                maximumResults
                );

            // Check if we got results
            if (identifyResults.Graphics.Count > 0)
            {
                // Make sure that the UI changes are done in the UI thread
                Device.BeginInvokeOnMainThread(async() => {
                    var json = JsonConvert.SerializeObject(identifyResults.Graphics[0].Attributes, Formatting.Indented);
                    await DisplayAlert("", json, "OK");
                });
            }
        }
        private async void MyMapView_GeoViewTapped(object sender, GeoViewInputEventArgs e)
        {
            // Identify the tapped graphics.
            IdentifyGraphicsOverlayResult result = null;

            try
            {
                result = await _myMapView.IdentifyGraphicsOverlayAsync(_graphicsOverlay, e.Position, 1, false);
            }
            catch (Exception ex)
            {
                new UIAlertView("Error", ex.ToString(), (IUIAlertViewDelegate)null, "OK", null).Show();
            }

            // Return if there are no results.
            if (result == null || result.Graphics.Count < 1)
            {
                return;
            }

            // Get the smallest identified graphic.
            Graphic identifiedGraphic = result.Graphics.OrderBy(graphic => GeometryEngine.Area(graphic.Geometry)).First();

            // Clear any existing selection, then select the tapped graphic.
            _graphicsOverlay.ClearSelection();
            identifiedGraphic.IsSelected = true;

            // Get the selected graphic's geometry.
            Geometry selectedGeometry = identifiedGraphic.Geometry;

            // Perform the calculation and show the results.
            _resultTextView.Text = GetOutputText(selectedGeometry);
        }
Beispiel #3
0
        private async Task <Graphic> GetGraphicAsync()
        {
            Window w = Window.GetWindow(this);

            myMapView = (MapView)w.FindName("myMapView");
            // Wait for the user to click a location on the map
            Esri.ArcGISRuntime.Geometry.Geometry mapPoint = await myMapView.SketchEditor.StartAsync(SketchCreationMode.Point, false);

            // Convert the map point to a screen point
            Point screenCoordinate = myMapView.LocationToScreen((MapPoint)mapPoint);

            // Identify graphics in the graphics overlay using the point
            IReadOnlyList <IdentifyGraphicsOverlayResult> results = await myMapView.IdentifyGraphicsOverlaysAsync(screenCoordinate, 2, false);

            // If results were found, get the first graphic
            Graphic graphic = null;
            IdentifyGraphicsOverlayResult idResult = results.FirstOrDefault();

            if (idResult != null && idResult.Graphics.Count > 0)
            {
                graphic = idResult.Graphics.FirstOrDefault();
            }

            // Return the graphic (or null if none were found)
            return(graphic);
        }
Beispiel #4
0
        private async void MyMapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs e)
        {
            // Identify the tapped graphics
            IdentifyGraphicsOverlayResult result = null;

            try
            {
                result = await MyMapView.IdentifyGraphicsOverlayAsync(_graphicsOverlay, e.Position, 1, false);
            }
            catch (Exception ex)
            {
                await((Page)Parent).DisplayAlert("Error", ex.ToString(), "OK");
            }

            // Return if there are no results
            if (result == null || result.Graphics.Count < 1)
            {
                return;
            }

            // Get the first identified graphic
            Graphic identifiedGraphic = result.Graphics.First();

            // Clear any existing selection, then select the tapped graphic
            _graphicsOverlay.ClearSelection();
            identifiedGraphic.IsSelected = true;

            // Get the selected graphic's geometry
            Geometry selectedGeometry = identifiedGraphic.Geometry;

            // Perform the calculation and show the results
            ResultTextbox.Text = GetOutputText(selectedGeometry);
        }
        private async void OnMapViewTapped(object sender, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs e)
        {
            double tolerance        = 10d;   // Use larger tolerance for touch
            int    maximumResults   = 1;     // Only return one graphic
            bool   onlyReturnPopups = false; // Don't return only popups

            try
            {
                // Use the following method to identify graphics in a specific graphics overlay
                IdentifyGraphicsOverlayResult identifyResults = await MyMapView.IdentifyGraphicsOverlayAsync(
                    _polygonOverlay,
                    e.Position,
                    tolerance,
                    onlyReturnPopups,
                    maximumResults);

                // Check if we got results
                if (identifyResults.Graphics.Count > 0)
                {
                    // Make sure that the UI changes are done in the UI thread
                    Device.BeginInvokeOnMainThread(async() => {
                        await((Page)Parent).DisplayAlert("", "Tapped on graphic", "OK");
                    });
                }
            }
            catch (Exception ex)
            {
                await((Page)Parent).DisplayAlert("Error", ex.ToString(), "OK");
            }
        }
Beispiel #6
0
        private async void MapViewTapped(object sender, GeoViewInputEventArgs geoViewInputEventArgs)
        {
            // Identify the tapped graphics
            IdentifyGraphicsOverlayResult result = null;

            try
            {
                result = await MyMapView.IdentifyGraphicsOverlayAsync(_graphicsOverlay, geoViewInputEventArgs.Position, 1, false);
            }
            catch (Exception e)
            {
                await new MessageDialog(e.ToString(), "Error").ShowAsync();
            }

            // Return if there are no results
            if (result == null || result.Graphics.Count < 1)
            {
                return;
            }

            // Get the first identified graphic
            Graphic identifiedGraphic = result.Graphics.First();

            // Clear any existing selection, then select the tapped graphic
            _graphicsOverlay.ClearSelection();
            identifiedGraphic.IsSelected = true;

            // Get the selected graphic's geometry
            Geometry selectedGeometry = identifiedGraphic.Geometry;

            // Perform the calculation and show the results
            ResultTextbox.Text = GetOutputText(selectedGeometry);
        }
Beispiel #7
0
        private async void OnMapViewTapped(object sender, GeoViewInputEventArgs e)
        {
            double tolerance        = 10d;   // Use larger tolerance for touch
            int    maximumResults   = 1;     // Only return one graphic
            bool   onlyReturnPopups = false; // Don't return only popups

            try
            {
                // Use the following method to identify graphics in a specific graphics overlay
                IdentifyGraphicsOverlayResult identifyResults = await MyMapView.IdentifyGraphicsOverlayAsync(
                    _polygonOverlay,
                    e.Position,
                    tolerance,
                    onlyReturnPopups,
                    maximumResults);

                // Check if we got results
                if (identifyResults.Graphics.Count > 0)
                {
                    //  Display to the user the identify worked.
                    await new MessageDialog("Tapped on graphic", "").ShowAsync();
                }
            }
            catch (Exception ex)
            {
                await new MessageDialog(ex.ToString(), "Error").ShowAsync();
            }
        }
Beispiel #8
0
        private async void OnMapViewTapped(object sender, GeoViewInputEventArgs e)
        {
            var tolerance        = 10d;   // Use larger tolerance for touch
            var maximumResults   = 1;     // Only return one graphic
            var onlyReturnPopups = false; // Don't only return popups

            // Use the following method to identify graphics in a specific graphics overlay
            IdentifyGraphicsOverlayResult identifyResults = await _myMapView.IdentifyGraphicsOverlayAsync(
                _polygonOverlay,
                e.Position,
                tolerance,
                onlyReturnPopups,
                maximumResults);

            // Check if we got results
            if (identifyResults.Graphics.Count > 0)
            {
                // Make sure that the UI changes are done in the UI thread
                InvokeOnMainThread(() =>
                {
                    var alert = new UIAlertView("", "Tapped on graphic", null, "OK", null);
                    alert.Show();
                });
            }
        }
        private async void OnMapViewTapped(object sender, GeoViewInputEventArgs e)
        {
            try
            {
                // Use the following method to identify graphics in a specific graphics overlay.
                IdentifyGraphicsOverlayResult identifyResults = await _myMapView.IdentifyGraphicsOverlayAsync(
                    graphicsOverlay : _polygonOverlay,
                    screenPoint : e.Position,
                    tolerance : 10d,
                    returnPopupsOnly : false,
                    maximumResults : 1);

                // Check if we got results.
                if (identifyResults.Graphics.Count > 0)
                {
                    // Make sure that the UI changes are done in the UI thread.
                    InvokeOnMainThread(() =>
                    {
                        UIAlertView alert = new UIAlertView("", "Tapped on graphic", (IUIAlertViewDelegate)null, "OK", null);
                        alert.Show();
                    });
                }
            }
            catch (Exception ex)
            {
                new UIAlertView(title: "Error", message: ex.ToString(), del: (IUIAlertViewDelegate)null, cancelButtonTitle: "OK", otherButtons: null).Show();
            }
        }
        private async void OnMapViewTapped(object sender, GeoViewInputEventArgs e)
        {
            double tolerance        = 10d;   // Use larger tolerance for touch
            int    maximumResults   = 1;     // Only return one graphic
            bool   onlyReturnPopups = false; // Don't only return popups

            // Use the following method to identify graphics in a specific graphics overlay
            IdentifyGraphicsOverlayResult identifyResults = await _myMapView.IdentifyGraphicsOverlayAsync(
                _polygonOverlay,
                e.Position,
                tolerance,
                onlyReturnPopups,
                maximumResults);

            // Check if we got results
            if (identifyResults.Graphics.Count > 0)
            {
                // Make sure that the UI changes are done in the UI thread
                RunOnUiThread(() =>
                {
                    AlertDialog.Builder alert = new AlertDialog.Builder(this);
                    alert.SetMessage("Tapped on graphic");
                    alert.Show();
                });
            }
        }
Beispiel #11
0
        private async void OnMapViewTapped(object sender, GeoViewInputEventArgs e)
        {
            double tolerance        = 10d;   // Use larger tolerance for touch.
            int    maximumResults   = 1;     // Only return one graphic  .
            bool   onlyReturnPopups = false; // Don't only return popups.

            try
            {
                // Use the following method to identify graphics in a specific graphics overlay.
                IdentifyGraphicsOverlayResult identifyResults = await _myMapView.IdentifyGraphicsOverlayAsync(
                    _polygonOverlay,
                    e.Position,
                    tolerance,
                    onlyReturnPopups,
                    maximumResults);

                // Check if we got results.
                if (identifyResults.Graphics.Count > 0)
                {
                    // Make sure that the UI changes are done in the UI thread.
                    InvokeOnMainThread(() =>
                    {
                        UIAlertView alert = new UIAlertView("", "Tapped on graphic", (IUIAlertViewDelegate)null, "OK", null);
                        alert.Show();
                    });
                }
            }
            catch (Exception ex)
            {
                new UIAlertView("Error", ex.ToString(), (IUIAlertViewDelegate)null, "OK", null).Show();
            }
        }
        private async void TagMapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.UI.Controls.GeoViewInputEventArgs e)
        {
            InstaAutoBot.SelectedGraphics.Clear();

            if (TagMapView.GraphicsOverlays.Count > 0)
            {
                var tolerance        = 10d;   // Use larger tolerance for touch
                var maximumResults   = 3;     // Only return one graphic
                var onlyReturnPopups = false; // Return more than popups

                var graphicColl = new List <Graphic>();

                foreach (var go in TagMapView.GraphicsOverlays)
                {
                    // Use the following method to identify graphics in a specific graphics overlay
                    IdentifyGraphicsOverlayResult identifyResults = await TagMapView.IdentifyGraphicsOverlayAsync(
                        go,
                        e.Position,
                        tolerance,
                        onlyReturnPopups,
                        maximumResults);

                    if (identifyResults.Graphics.Count > 0)
                    {
                        IdentifyExpander.IsExpanded = true;
                        identifyResults.Graphics.ToList().ForEach(g => InstaAutoBot.SelectedGraphics.Add(g));
                    }
                }
            }
        }
Beispiel #13
0
        private async void myMapView_GeoViewTapped(object sender, GeoViewInputEventArgs e)
        {
            // Identify the tapped graphics
            IdentifyGraphicsOverlayResult result = null;

            try
            {
                result = await _myMapView.IdentifyGraphicsOverlayAsync(_graphicsOverlay, e.Position, 1, false);
            }
            catch (Exception ex)
            {
                new AlertDialog.Builder(this).SetMessage(ex.ToString()).SetTitle("Error").Show();
            }

            // Return if there are no results
            if (result == null || result.Graphics.Count < 1)
            {
                return;
            }

            // Get the first identified graphic
            Graphic identifiedGraphic = result.Graphics.First();

            // Clear any existing selection, then select the tapped graphic
            _graphicsOverlay.ClearSelection();
            identifiedGraphic.IsSelected = true;

            // Get the selected graphic's geometry
            Geometry selectedGeometry = identifiedGraphic.Geometry;

            // Perform the calculation and show the results
            _resultTextView.Text = GetOutputText(selectedGeometry);
        }
Beispiel #14
0
        private async void MapViewTapped(object sender, GeoViewInputEventArgs geoViewInputEventArgs)
        {
            IdentifyGraphicsOverlayResult result = null;

            try
            {
                // Identify the tapped graphics
                result = await MyMapView.IdentifyGraphicsOverlayAsync(_graphicsOverlay, geoViewInputEventArgs.Position, 1, false);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString(), "Error");
            }

            // Return if there are no results
            if (result == null || result.Graphics.Count < 1)
            {
                return;
            }

            // Get the first identified graphic
            Graphic identifiedGraphic = result.Graphics.First();

            // Clear any existing selection, then select the tapped graphic
            _graphicsOverlay.ClearSelection();
            identifiedGraphic.IsSelected = true;

            // Get the selected graphic's geometry
            Geometry selectedGeometry = identifiedGraphic.Geometry;

            // Update the spatial relationship display
            switch (selectedGeometry.GeometryType)
            {
            case GeometryType.Point:
                PointTreeEntry.ItemsSource    = null;
                PolygonTreeEntry.ItemsSource  = GetSpatialRelationships(selectedGeometry, _polygonGraphic.Geometry);
                PolylineTreeEntry.ItemsSource = GetSpatialRelationships(selectedGeometry, _polylineGraphic.Geometry);
                break;

            case GeometryType.Polygon:
                PolygonTreeEntry.ItemsSource  = null;
                PointTreeEntry.ItemsSource    = GetSpatialRelationships(selectedGeometry, _pointGraphic.Geometry);
                PolylineTreeEntry.ItemsSource = GetSpatialRelationships(selectedGeometry, _polylineGraphic.Geometry);
                break;

            case GeometryType.Polyline:
                PolylineTreeEntry.ItemsSource = null;
                PointTreeEntry.ItemsSource    = GetSpatialRelationships(selectedGeometry, _pointGraphic.Geometry);
                PolygonTreeEntry.ItemsSource  = GetSpatialRelationships(selectedGeometry, _polygonGraphic.Geometry);
                break;
            }

            // Expand the tree view
            PolylineTreeEntry.IsExpanded = true;
            PolygonTreeEntry.IsExpanded  = true;
            PointTreeEntry.IsExpanded    = true;
        }
Beispiel #15
0
        //private void Initialize()
        //{
        //    // Hook into tapped event
        //    MyMapview.GeoViewTapped += OnMapViewTapped;
        //}

        public async void OnMapViewTapped(object sender, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs e)
        {
            var      tolerance        = 10d;   // Use larger tolerance for touch
            var      maximumResults   = 1;     // Only return one graphic
            var      onlyReturnPopups = false; // Don't return only popups
            MapPoint mapLocation      = e.Location;
            // Use the following method to identify graphics in a specific graphics overlay
            IdentifyGraphicsOverlayResult identifyResults = await MyMapview.IdentifyGraphicsOverlayAsync(
                MyMapview.GraphicsOverlays["MyGraphics"],
                e.Position,
                tolerance,
                onlyReturnPopups,
                maximumResults);

            // Check if we got results
            if (identifyResults.Graphics.Count > 0)
            {
                // initialize the callout, with the title "GeoNote"
                CalloutDefinition myCalloutDefinition = new CalloutDefinition("GeoNote");

                // create a button image, with the buttonclicked action of close the callout
                Uri uri   = new Uri("https://www.us.elsevierhealth.com/skin/frontend/enterprise-zurb/themeus/images/close-button.png");
                var image = new RuntimeImage(uri);
                myCalloutDefinition.ButtonImage = image;

                myCalloutDefinition.OnButtonClick = CloseCallout;
                Action <object> ClosePop = CloseCallout;

                void CloseCallout(object i)
                {
                    MyMapview.DismissCallout();
                }

                // Create the Display messge of the callout
                List <object> names = new List <object>();

                string mapLocationDescription = string.Format("this is a piece of information");

                foreach (var g in identifyResults.Graphics)
                {
                    object graphicsName   = "Data Type: " + g.Attributes["Type"] + Environment.NewLine;
                    object graphicsNumber = "Number: " + g.Attributes["Number"] + Environment.NewLine;
                    names.Add(graphicsNumber);
                    names.Add(graphicsName);
                }
                string combindedString = string.Join("", names.ToArray());
                myCalloutDefinition.DetailText = "_________________________" + Environment.NewLine + combindedString;

                // Make sure that the UI changes are done in the UI thread
                Device.BeginInvokeOnMainThread(async() =>
                {
                    // Display the callout
                    MyMapview.ShowCalloutAt(mapLocation, myCalloutDefinition);
                });
            }
        }
        async void MyMapView_GeoViewTapped(System.Object sender, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs e)
        {
            // Clear any currently visible callouts, route graphics, or selections
            MyMapView.DismissCallout();
            _routeGraphicsOverlay.Graphics.Clear();
            _placesGraphicsOverlay.ClearSelection();

            // Get the place under the tap
            IdentifyGraphicsOverlayResult idResult = await MyMapView.IdentifyGraphicsOverlayAsync(_placesGraphicsOverlay, e.Position, 12, false);

            Graphic clickedElement = idResult.Graphics.FirstOrDefault();

            if (clickedElement != null)
            {
                // Select the place to highlight it; get name and address
                clickedElement.IsSelected = true;
                string name    = clickedElement.Attributes["Name"].ToString();
                string address = clickedElement.Attributes["Address"].ToString();

                // Create a callout definition that shows the name and address for the place; set the element as a tag
                CalloutDefinition definition = new CalloutDefinition(name, address);
                definition.Tag = clickedElement;

                // Handle button clicks for the button on the callout
                // This event receives the value assigned as the CalloutDefinition.Tag
                // ** Fix API ref for this!
                // https://developers.arcgis.com/net/latest/wpf/api-reference/html/P_Esri_ArcGISRuntime_UI_CalloutDefinition_OnButtonClick.htm
                definition.OnButtonClick = new Action <object>(async(tag) =>
                {
                    // Get the geoelement that represents the place
                    GeoElement poiElement = tag as GeoElement;
                    if (poiElement == null)
                    {
                        return;
                    }

                    // Call a function in the viewmodel that will route to this location
                    var routeGraphic = await _viewModel.RouteToPoiAsync(_deviceLocation, poiElement.Geometry as MapPoint, MyMapView.SpatialReference);

                    // Add the route graphic to the map view and zoom to its extent
                    _routeGraphicsOverlay.Graphics.Add(routeGraphic);
                    await MyMapView.SetViewpointGeometryAsync(routeGraphic.Geometry, 30);
                });

                // Set the button icon and show the callout at the click location
                definition.ButtonImage = WalkIcon;
                MyMapView.ShowCalloutAt(e.Location, definition);
            }
        }
Beispiel #17
0
        private async Task <Graphic> GetGraphicAsync()
        {
            MapPoint mapPoint = (MapPoint)await WorldMapView.SketchEditor.StartAsync(SketchCreationMode.Point, false);

            var screenCoordinate = WorldMapView.LocationToScreen(mapPoint);

            IReadOnlyList <IdentifyGraphicsOverlayResult> results = await WorldMapView.IdentifyGraphicsOverlaysAsync(screenCoordinate, 2, false);

            Graphic graphic = null;
            IdentifyGraphicsOverlayResult idResult = results.FirstOrDefault();

            if (idResult != null && idResult.Graphics.Count > 0)
            {
                graphic = idResult.Graphics.FirstOrDefault();
            }

            return(graphic);
        }
        /// <summary>
        /// 地图点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void sceneView_GeoViewTappedAsync(object sender, Esri.ArcGISRuntime.UI.Controls.GeoViewInputEventArgs e)
        {
            //MapPoint mapLocation = e.Location;
            //Esri.ArcGISRuntime.Geometry.Geometry myGeometry = GeometryEngine.Project(mapLocation, SpatialReferences.Wgs84);
            //MapPoint projectedLocation = myGeometry as MapPoint;

            double tolerance        = 0;
            int    maximumResults   = 1;
            bool   onlyReturnPopups = false;

            IdentifyGraphicsOverlayResult identifyResults = await sceneView.IdentifyGraphicsOverlayAsync(
                CylinderOverlayForVisitorData,
                e.Position,
                tolerance,
                onlyReturnPopups,
                maximumResults);

            if (identifyResults.Graphics.Count > 0)
            {
                Graphic     graphic     = identifyResults.Graphics[0];
                MapPoint    mapPoint    = graphic.Geometry as MapPoint;
                VisitorItem visitorItem = GraphicsAttributes.ContainsKey(graphic) ? (GraphicsAttributes[graphic] as VisitorItem) : null;
                if (visitorItem != null)
                {
                    List <VisitorItem> visitorList = new List <VisitorItem>();
                    for (int month = 0; month < VisitorsByMonthAndPlace.Count; month++)
                    {
                        for (int viewIndex = 0; viewIndex < VisitorsByMonthAndPlace[month].Count; viewIndex++)
                        {
                            if (VisitorsByMonthAndPlace[month][viewIndex].ViewId == visitorItem.ViewId)
                            {
                                visitorList.Add(VisitorsByMonthAndPlace[month][viewIndex]);
                            }
                        }
                    }
                    //显示回调框
                    sceneView.ShowCalloutAt(mapPoint, new VisitorCallout(visitorList), new Point(0, 0));
                }
            }
            else
            {
                sceneView.DismissCallout();
            }
        }
Beispiel #19
0
        private async void OnMapViewTapped(object sender, GeoViewInputEventArgs e)
        {
            double tolerance        = 10d;   // Use larger tolerance for touch
            int    maximumResults   = 1;     // Only return one graphic
            bool   onlyReturnPopups = false; // Return more than popups

            // Use the following method to identify graphics in a specific graphics overlay
            IdentifyGraphicsOverlayResult identifyResults = await MyMapView.IdentifyGraphicsOverlayAsync(
                _polygonOverlay,
                e.Position,
                tolerance,
                onlyReturnPopups,
                maximumResults);

            // Check if we got results
            if (identifyResults.Graphics.Count > 0)
            {
                //  Display to the user the identify worked.
                MessageBox.Show("Tapped on graphic", "");
            }
        }
        private async Task <Graphic> GetGraphicAsync()
        {
            // Wait for the user to click a location on the map
            var mapPoint = (MapPoint)await MyMapView.SketchEditor.StartAsync(SketchCreationMode.Point, false);

            // Convert the map point to a screen point
            var screenCoordinate = MyMapView.LocationToScreen(mapPoint);

            // Identify graphics in the graphics overlay using the point
            var results = await MyMapView.IdentifyGraphicsOverlaysAsync(screenCoordinate, 2, false);

            // If results were found, get the first graphic
            Graphic graphic = null;
            IdentifyGraphicsOverlayResult idResult = results.FirstOrDefault();

            if (idResult != null && idResult.Graphics.Count > 0)
            {
                graphic = idResult.Graphics.FirstOrDefault();
            }

            // Return the graphic (or null if none were found)
            return(graphic);
        }
        private async void myMapView_GeoViewTapped(object sender, GeoViewInputEventArgs e)
        {
            // Identify the tapped graphics
            IdentifyGraphicsOverlayResult result = await _myMapView.IdentifyGraphicsOverlayAsync(_graphicsOverlay, e.Position, 1, false);

            // Return if there are no results
            if (result.Graphics.Count < 1)
            {
                return;
            }

            // Get the first identified graphic
            Graphic identifiedGraphic = result.Graphics.First();

            // Clear any existing selection, then select the tapped graphic
            _graphicsOverlay.ClearSelection();
            identifiedGraphic.IsSelected = true;

            // Get the selected graphic's geometry
            Geometry selectedGeometry = identifiedGraphic.Geometry;

            // Perform the calculation and show the results
            _resultTextView.Text = GetOutputText(selectedGeometry);
        }
Beispiel #22
0
        private async void MapView_GeoViewTapped(object sender, GeoViewInputEventArgs e)
        {
            //await CreatePictureMarkerSymbolFromResources(overlay);
            IdentifyGraphicsOverlayResult identifyResults = await MapView.IdentifyGraphicsOverlayAsync(
                overlay,
                e.Position,
                10,
                false,
                1);

            if (identifyResults.Graphics.Count() > 0)
            {
                identifyResults.Graphics[0].IsSelected = !identifyResults.Graphics[0].IsSelected;
                if (identifyResults.Graphics[0].IsSelected)
                {
                    var mPage = new EMB_InspectionActivityPage {
                    };
                    await Navigation.PushModalAsync(new NavigationPage(mPage));

                    mPage.InitializePage(workitem);
                }
                // if (identifyResults.Graphics[0].IsSelected) await Navigation.PushAsync(new NavigationPage(new EMB_InspectionActivityPage()));// await Navigation.PushModalAsync(new NavigationPage(new AboutPage()));
            }
        }
Beispiel #23
0
        /// <summary>
        /// creates the layers and sets the initial properties for filtering to the region and date and zooms to the extent of the region/user's extent
        /// </summary>
        /// <param name="mapView">This parameter is from the usercontrol directly.  Needed for making viewport changes.</param>
        public async Task <bool> InitializeMap(MapView mapView)
        {
            bool result = false;

            if (this.Map != null)
            {
                //this.Map.LoadStatusChanged += async (s, e) =>
                //{
                //    if (e.Status == LoadStatus.FailedToLoad)
                //    {
                //    }
                //    else if (e.Status == LoadStatus.Loaded)
                //    {

                //    }
                //};


                this._mapView = mapView;

                // Update stored values of map scale and units for clustering calculations
                this.MapView.ViewpointChanged += (s, e) =>
                {
                    if (_isInitialized)
                    {
                        Settings.MapScale         = this._mapView.MapScale;
                        Settings.MapUnitsPerPixel = this._mapView.UnitsPerPixel;
                        Settings.MapExtent        = this.MapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry).TargetGeometry.ToWebMercator() as Envelope;
                    }
                };

                // Standard map configuration
                this._mapView.InteractionOptions = new Esri.ArcGISRuntime.UI.MapViewInteractionOptions
                {
                    IsRotateEnabled    = false,
                    WheelZoomDirection = Esri.ArcGISRuntime.UI.WheelZoomDirection.Default
                };


                // Handle navigation completed to clear labels
                this.MapView.NavigationCompleted += async(o, e) =>
                {
                    if (this.Labels.Count > 0)
                    {
                        this.Labels.Clear();
                    }
                };

                // Create and initialize the dispatch features
                this.Dispatches = new DispatchesModel();
                await this.Dispatches.Initialize();

                // Add the dispatches graphics overlay to the map
                this.MapView.GraphicsOverlays.Add(this.Dispatches.FeatureGraphicsLayer);

                // Zoom in to points
                await this.MapView.SetViewpointGeometryAsync(this.Dispatches.FeatureGraphicsLayer.Extent, 10);


                // Handle map click event
                this.MapView.GeoViewTapped += async(s, e) =>
                {
                    try
                    {
                        if (this.Labels.Count > 0)
                        {
                            this.Labels.Clear();
                        }
                        this.MapView.DismissCallout();
                        _dispatches.FeatureGraphicsLayer.ClearSelection();

                        double tolerance        = 10d;   // Use larger tolerance for touch
                        int    maximumResults   = 10;    // Only return one graphic
                        bool   onlyReturnPopups = false; // Return more than popups

                        // Use the following method to identify graphics in a specific graphics overlay
                        IdentifyGraphicsOverlayResult identifyResults = await this.MapView.IdentifyGraphicsOverlayAsync(
                            this.Dispatches.FeatureGraphicsLayer,
                            e.Position,
                            tolerance,
                            onlyReturnPopups,
                            maximumResults);

                        if (identifyResults.Graphics.Count > 0)
                        {
                            if (this.IsSelectEnabled)
                            {
                                // Select the features based on query parameters defined above.
                                _dispatches.FeatureGraphicsLayer.SelectGraphics(identifyResults.Graphics);
                            }
                            if (this.IsClickLabelsEnabled)
                            {
                                this.LabelLocationX = e.Position.X;
                                this.LabelLocationY = e.Position.Y;
                                identifyResults.Graphics.ForEach(p => this.Labels.Add(((CustomGraphic)p).ID.ToString()));
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString(), "Error");
                    }
                };

                // Handle mouse move to show callout at given location
                this.MapView.MouseMove += async(s, e) =>
                {
                    if (this.IsMoveLabelsEnabled)
                    {
                        // Get the curent mouse position.
                        Point position = e.GetPosition(this.MapView);

                        // Identify the raster cell at that position.
                        ShowCalloutTopDispatches(position);
                    }
                };

                result = true;
            }
            _isInitialized = true;
            return(result);
        }
        private async void WaveSelected()
        {
            // clear existing overlays
            _mapView.GraphicsOverlays.Clear();

            //tide prediction array
            string[,] tidePrediction = new string[, ] {
                //Alabama
                { "30.2786", "-87.5550", "8730667" },
                { "30.2333", "-88.0200", "8734635" },
                { "30.2799", "-87.6843", "8731439" },
                { "30.3033", "-87.7350", "8731952" },
                { "30.2500", "-88.0750", "8735180" },
                { "30.4436", "-88.1139", "8735523" },
                { "30.3766", "-88.1586", "8738043" },
                { "30.4866", "-87.9345", "8733821" },
                { "30.5652", "-88.0880", "8735391" },
                { "30.6483", "-88.0583", "8736897" },
                { "30.6672", "-87.9364", "8733839" },
                { "30.7083", "-88.0433", "8737048" },
                { "30.7819", "-88.0736", "8737138" },
                { "30.8183", "-87.9150", "8737182" },
                { "30.3717", "-88.2750", "8739051" },
                { "30.4057", "-88.2477", "8739803" },

                //Mississippi
                { "30.4132", "-88.4029", "8740166" },
                { "30.3867", "-88.4400", "8740448" },
                { "30.3867", "-88.7733", "8743081" },
                { "30.2033", "-88.4417", "8740405" },
                { "30.2133", "-88.9717", "8740405" },
                { "30.2383", "-88.6667", "8742221" },
                { "30.3478", "-88.5058", "8741041" },
                { "30.3400", "-88.5333", "8741196" },
                { "30.3617", "-88.6633", "8742205" },
                { "30.3600", "-89.0817", "8745557" },
                { "30.3900", "-88.8567", "8743735" },
                { "30.4267", "-89.0533", "8745375" },
                { "30.4067", "-89.0267", "8745101" },
                { "30.2317", "-89.1167", "8745799" },
                { "30.3100", "-89.2450", "8746819" },
                { "30.3583", "-89.2733", "8748038" },
                { "30.3250", "-89.3250", "8747437" },
                { "30.2817", "-89.3667", "8747766" },
                { "30.2400", "-89.6150", "8749704" },

                //Louisiana
                { "30.1667", "-89.7367", "8761402" },
                { "30.2717", "-89.7933", "8761473" },
                { "30.3783", "-90.1600", "8761993" },
                { "30.0272", "-90.1133", "8761927" },
                { "30.0650", "-89.8000", "8761487" },
                { "30.0067", "-89.9367", "8761678" },
                { "29.8681", "-89.6732", "8761305" },
                { "30.1267", "-89.2217", "8760668" },
                { "30.0483", "-88.8717", "8760172" },
                { "29.8233", "-89.2700", "8760742" },
                { "29.5983", "-89.6183", "8761108" },
                { "29.4933", "-89.1733", "8760595" },
                { "29.3667", "-89.3450", "8760841" },
                { "29.2283", "-89.0500", "8760424" },
                { "29.3866", "-89.3801", "8760889" },
                { "30.0000", "-89.9333", "8760412" },
                { "29.2633", "-89.9567", "8761724" },
                { "29.2667", "-89.9667", "TEC4455" },
                { "29.3100", "-89.9383", "8761677" },
                { "29.3183", "-89.9800", "8761742" },
                { "29.4267", "-89.9767", "8761732" },
                { "29.6667", "-90.1117", "8761899" },
                { "29.2100", "-90.0400", "8761826" },
                { "29.1142", "-90.1993", "8762075" },
                { "29.2483", "-90.2117", "8762084" },
                { "29.3733", "-90.2650", "8762184" },
                { "29.0867", "-90.5267", "8762675" },
                { "29.0767", "-90.2850", "8762223" },
                { "29.1283", "-90.4233", "8762481" },
                { "29.0783", "-90.5867", "8762850" },
                { "29.2450", "-90.6617", "8762928" },
                { "29.0717", "-90.6400", "8762888" },
                { "29.0633", "-90.8067", "8763206" },
                { "29.0633", "-90.9617", "8763506" },
                { "29.1748", "-90.9764", "8763535" },
                { "29.3675", "-91.3839", "8764314" },
                { "29.3333", "-91.3533", "8764256" },
                { "29.4733", "-91.3050", "8764165" },
                { "29.7433", "-91.2300", "8764025" },
                { "29.5183", "-91.5550", "8764634" },
                { "29.4200", "-91.5933", "8764706" },
                { "29.4850", "-91.7633", "8765026" },
                { "29.5233", "-92.0433", "8765568" },
                { "28.9150", "-91.0717", "8763719" },
                { "29.7350", "-91.7133", "8764931" },
                { "29.5800", "-92.0350", "8765551" },
                { "29.7134", "-91.8800", "8765251" },
                { "29.8372", "-91.8375", "8765148" },
                { "29.5517", "-92.3052", "8766072" },
                { "29.7500", "-93.1000", "TEC4495" },
                { "29.7682", "-93.3429", "8768094" },
                { "30.1902", "-93.3008", "8767961" },
                { "30.2236", "-93.2217", "8767816" },

                //Texas

                { "29.7284", "-93.8701", "8770570" },
                { "29.6894", "-93.8419", "8770822" },
                { "29.8671", "-93.9310", "8770475" },
                { "29.9800", "-93.8817", "8770520" },
                { "29.3573", "-94.7248", "8771341" },
                { "29.3267", "-94.6933", "8771416" },
                { "29.3100", "-94.7933", "8771450" },
                { "29.3650", "-94.7800", "8771328" },
                { "29.3833", "-94.8833", "TEC4513" },
                { "29.4800", "-94.9183", "8771013" },
                { "29.5633", "-95.0667", "8770933" },
                { "29.6817", "-94.9850", "8770613" },
                { "29.7649", "-95.0789", "8770733" },
                { "29.7262", "-95.2658", "8770777" },
                { "29.7133", "-94.6900", "8770559" },
                { "29.6800", "-94.8683", "8770625" },
                { "29.7400", "-94.8317", "8770557" },
                { "29.5156", "-94.5106", "8770971" },
                { "29.5947", "-94.3903", "8770808" },
                { "29.5167", "-94.4833", "TEC4525" },
                { "29.3026", "-94.8971", "8771486" },
                { "29.2000", "-94.9850", "8771721" },
                { "29.1667", "-95.1250", "8771801" },
                { "29.0810", "-95.1313", "8771972" },
                { "29.0417", "-95.1750", "8772132" },
                { "29.2853", "-94.7894", "8771510" },
                { "28.7714", "-95.6172", "8772985" },
                { "28.9357", "-95.2942", "8772471" },
                { "28.9483", "-95.3083", "8772440" },
                { "28.7101", "-95.9140", "8773146" },
                { "28.4269", "-96.3301", "8773767" },
                { "28.4069", "-96.7124", "8773037" },
                { "28.2283", "-96.7950", "8774230" },
                { "28.1144", "-97.0244", "8774513" },
                { "28.4459", "-96.3956", "8773701" },
                { "28.6406", "-96.6098", "8773259" },
                { "27.8328", "-97.4859", "8775244" },
                { "27.8366", "-97.0391", "8775241" },
                { "27.8397", "-97.0725", "8775237" },
                { "27.5800", "-97.2167", "8775870" },
                { "27.8149", "-97.3892", "8775296" },
                { "27.6333", "-97.2367", "8775792" },
                { "26.0674", "-97.1548", "8779749" },
                { "26.0683", "-97.1567", "8779750" },
                { "26.0783", "-97.1700", "8779724" },
                { "26.0717", "-97.1917", "8779739" },
                { "26.0612", "-97.2155", "8779770" },
                { "26.0517", "-97.1817", "8779768" },
            };

            // Create simple marker symbol for tide predictions
            SimpleMarkerSymbol tideMarker = new SimpleMarkerSymbol()
            {
                Color = Color.Blue,
                Size  = 10,
                Style = SimpleMarkerSymbolStyle.Circle
            };

            // create graphics overlay
            GraphicsOverlay tideLayer = new GraphicsOverlay();

            // create graphics for each tide location
            int tideLength = tidePrediction.Length / 3;

            for (int i = 0; i < tideLength; i++)
            {
                string   latLon      = tidePrediction[i, 0].ToString() + " " + tidePrediction[i, 1].ToString();
                MapPoint tide        = CoordinateFormatter.FromLatitudeLongitude(latLon, SpatialReferences.Wgs84);
                Graphic  tideGraphic = new Graphic(tide, tideMarker);
                tideLayer.Graphics.Add(tideGraphic);
            }

            // add layer to map
            _mapView.GraphicsOverlays.Add(tideLayer);

            // method for when tide point is clicked
            _mapView.GeoViewTapped += async(s, e) =>
            {
                try
                {
                    //identify tide overlay
                    IdentifyGraphicsOverlayResult identifyResults = await _mapView.IdentifyGraphicsOverlayAsync(
                        tideLayer,
                        e.Position,
                        10d,
                        false,
                        1

                        );

                    // get user tap point
                    Geometry          myGeo      = GeometryEngine.Project(e.Location, SpatialReferences.Wgs84);
                    MapPoint          projection = (MapPoint)myGeo;
                    CalloutDefinition myCallout;
                    int latitidueFinal = 0;

                    // compare user point to map points
                    if (identifyResults.Graphics.Count > 0)
                    {
                        string description = " ";
                        for (int i = 0; i < tideLength; i++)
                        {
                            for (int j = 1; j < 3; j++)
                            {
                                double latNDBC        = Convert.ToDouble(tidePrediction[i, 0]);
                                double latNDBCRounded = Math.Round(latNDBC, 1);

                                double latClick        = Convert.ToDouble(projection.Y);
                                double latClickRounded = Math.Round(latClick, 1);

                                double lowerLat = latClickRounded - .1;
                                double upperLat = latClickRounded + .1;

                                double lonNDBC        = Convert.ToDouble(tidePrediction[i, 1]);
                                double lonNDBCRounded = Math.Round(lonNDBC, 1);

                                double lonClick        = Convert.ToDouble(projection.X);
                                double lonClickRounded = Math.Round(lonClick, 1);

                                double lowerLon = lonClickRounded - .1;
                                double upperLon = lonClickRounded + .1;



                                if (lowerLat <= latNDBCRounded && upperLat >= latNDBCRounded && lowerLon <= lonNDBCRounded && upperLon >= lonNDBCRounded)
                                {
                                    latitidueFinal = i;
                                }
                            }
                        }



                        // create callout
                        string title             = tidePrediction[latitidueFinal, 2];
                        string latLonDescription = "Latitude: " + tidePrediction[latitidueFinal, 0] + "\n" + "Longitude: " + tidePrediction[latitidueFinal, 1] + "\n";
                        string url = "https://tidesandcurrents.noaa.gov/noaatidepredictions.html?id=" + tidePrediction[latitidueFinal, 2];

                        description += latLonDescription;


                        myCallout = new CalloutDefinition(title, description);
                        _mapView.ShowCalloutAt(e.Location, myCallout);
                    }
                    // if user does not click on a tide point, get rid of any existing callouts
                    else
                    {
                        _mapView.DismissCallout();
                    }
                }
                catch (Exception ex)
                {
                }
            };
        }
        private async void InitializeMarkers(string buoyData)
        {
            // create 2d array from buoy data string
            string newResults    = Regex.Replace(buoyData, " {4,}", " ");
            string newResultsTwo = Regex.Replace(newResults, " {2,}", " ");
            char   delimiter     = '\n';

            String[] data = newResultsTwo.Split(delimiter);

            int length = data.Length;


            String[,] dataParsed = new String[length, 22];

            char delimiterTwo = ' ';

            for (int i = 0; i < data.Length; i++)
            {
                String[] fields = data[i].Split(delimiterTwo);

                for (int j = 0; j < fields.Length; j++)
                {
                    dataParsed[i, j] = fields[j];
                }
            }



            // Create simple marker symbol for user location
            SimpleMarkerSymbol userMarker = new SimpleMarkerSymbol()
            {
                Color = Color.Red,
                Size  = 10,
                Style = SimpleMarkerSymbolStyle.Diamond
            };

            // Create simple marker symbol for buoy locations
            SimpleMarkerSymbol buoyMarker = new SimpleMarkerSymbol()
            {
                Color = Color.Black,
                Size  = 10,
                Style = SimpleMarkerSymbolStyle.Circle
            };

            // Create graphics overlay for buoys
            GraphicsOverlay buoys = new GraphicsOverlay();

            buoys.Id = "BuoyLayer";

            //get user location
            string userLat = "";
            string userLon = "";

            try
            {
                var request      = new GeolocationRequest(GeolocationAccuracy.Medium);
                var userLocation = await Geolocation.GetLocationAsync(request);

                if (userLocation != null)
                {
                    userLat = userLocation.Latitude.ToString();
                    userLon = userLocation.Longitude.ToString();

                    string   userLocationFormatted = userLat + " " + userLon;
                    MapPoint userMapPoint          = CoordinateFormatter.FromLatitudeLongitude(userLocationFormatted, SpatialReferences.Wgs84);
                    Graphic  userGraphic           = new Graphic(userMapPoint, userMarker);

                    buoys.Graphics.Add(userGraphic);
                }
            }
            catch (FeatureNotSupportedException fnsEx)
            {
                // Handle not supported on device exception
            }
            catch (FeatureNotEnabledException fneEx)
            {
                // Handle not enabled on device exception
            }
            catch (PermissionException pEx)
            {
                // Handle permission exception
            }
            catch (Exception ex)
            {
                // Unable to get location
            }

            //MapPoint startingLocation;
            length = data.Length - 1;

            // create buoy marker for each location from buoy array
            for (int i = 3; i < length; i++)
            {
                if (Convert.ToDouble(dataParsed[i, 2]) > -100 && Convert.ToDouble(dataParsed[i, 2]) < -80)
                {
                    if (Convert.ToDouble(dataParsed[i, 1]) > 17 && Convert.ToDouble(dataParsed[i, 1]) < 31)
                    {
                        string   location         = dataParsed[i, 1] + " " + dataParsed[i, 2];
                        MapPoint startingLocation = CoordinateFormatter.FromLatitudeLongitude(location, SpatialReferences.Wgs84);

                        Graphic graphicWithBuoy = new Graphic(startingLocation, buoyMarker);
                        buoys.Graphics.Add(graphicWithBuoy);
                    }
                }
            }

            // add overlay to map
            _mapView.GraphicsOverlays.Add(buoys);

            // method for when user clicks on buoy
            _mapView.GeoViewTapped += async(s, e) =>
            {
                try
                {
                    // identify buoy layer
                    IdentifyGraphicsOverlayResult identifyResults = await _mapView.IdentifyGraphicsOverlayAsync(
                        buoys,
                        e.Position,
                        10d,
                        false,
                        1

                        );

                    Geometry          myGeo      = GeometryEngine.Project(e.Location, SpatialReferences.Wgs84);
                    MapPoint          projection = (MapPoint)myGeo;
                    CalloutDefinition myCallout;
                    int latitidueFinal = 0;


                    //compare user click point to buoy locations from array
                    if (identifyResults.Graphics.Count > 0)
                    {
                        string description = " ";
                        for (int i = 3; i < length; i++)
                        {
                            for (int j = 1; j < 3; j++)
                            {
                                double latNDBC        = Convert.ToDouble(dataParsed[i, 1]);
                                double latNDBCRounded = Math.Round(latNDBC, 1);

                                double latClick        = Convert.ToDouble(projection.Y);
                                double latClickRounded = Math.Round(latClick, 1);

                                double lowerLat = latClickRounded - .1;
                                double upperLat = latClickRounded + .1;

                                double lonNDBC        = Convert.ToDouble(dataParsed[i, 2]);
                                double lonNDBCRounded = Math.Round(lonNDBC, 1);

                                double lonClick        = Convert.ToDouble(projection.X);
                                double lonClickRounded = Math.Round(lonClick, 1);

                                double lowerLon = lonClickRounded - .1;
                                double upperLon = lonClickRounded + .1;


                                // find the line in the array for the buoy the user clicked on
                                if (lowerLat <= latNDBCRounded && upperLat >= latNDBCRounded && lowerLon <= lonNDBCRounded && upperLon >= lonNDBCRounded)
                                {
                                    latitidueFinal = i;
                                }
                            }
                        }


                        // translate degree number into NSWE
                        string degrees = "";

                        double degreesDouble = Convert.ToDouble(dataParsed[latitidueFinal, 8]);
                        if (degreesDouble > 349 && degreesDouble <= 360)
                        {
                            degrees = "N";
                        }
                        else if (degreesDouble >= 0 && degreesDouble <= 11)
                        {
                            degrees = "N";
                        }
                        else if (degreesDouble > 11 && degreesDouble <= 34)
                        {
                            degrees = "NNE";
                        }
                        else if (degreesDouble > 34 && degreesDouble <= 56)
                        {
                            degrees = "NE";
                        }
                        else if (degreesDouble > 56 && degreesDouble <= 79)
                        {
                            degrees = "ENE";
                        }
                        else if (degreesDouble > 79 && degreesDouble <= 101)
                        {
                            degrees = "E";
                        }
                        else if (degreesDouble > 101 && degreesDouble <= 124)
                        {
                            degrees = "ESE";
                        }
                        else if (degreesDouble > 124 && degreesDouble <= 146)
                        {
                            degrees = "SE";
                        }
                        else if (degreesDouble > 146 && degreesDouble <= 169)
                        {
                            degrees = "SSE";
                        }
                        else if (degreesDouble > 169 && degreesDouble <= 191)
                        {
                            degrees = "S";
                        }
                        else if (degreesDouble > 191 && degreesDouble <= 214)
                        {
                            degrees = "SSW";
                        }
                        else if (degreesDouble > 214 && degreesDouble <= 236)
                        {
                            degrees = "SW";
                        }
                        else if (degreesDouble > 236 && degreesDouble <= 259)
                        {
                            degrees = "WSW";
                        }
                        else if (degreesDouble > 259 && degreesDouble <= 281)
                        {
                            degrees = "W";
                        }
                        else if (degreesDouble > 281 && degreesDouble <= 304)
                        {
                            degrees = "WNW";
                        }
                        else if (degreesDouble > 304 && degreesDouble <= 326)
                        {
                            degrees = "NW";
                        }
                        else if (degreesDouble > 326 && degreesDouble <= 349)
                        {
                            degrees = "NNW";
                        }



                        // create callout
                        string title    = dataParsed[latitidueFinal, 0];
                        string location = "Location: " + dataParsed[latitidueFinal, 1] + "N " + dataParsed[latitidueFinal, 2] + "W" + "\n";
                        string date     = " Date: " + dataParsed[latitidueFinal, 3] + "/" + dataParsed[latitidueFinal, 4] + "/" + dataParsed[latitidueFinal, 5] + " " + dataParsed[latitidueFinal, 6] + ":" + dataParsed[latitidueFinal, 7] + ":00 UTC" + "\n";
                        string winds    = "";

                        description += location;
                        description += date;
                        description += winds;

                        string airTemp   = "";
                        string waterTemp = "";
                        string dewpoint  = "";

                        if (dataParsed[latitidueFinal, 10] != "MM")
                        {
                            winds        = " Winds: " + degrees + "(" + dataParsed[latitidueFinal, 8] + ") at " + dataParsed[latitidueFinal, 9] + " kt gusting to " + dataParsed[latitidueFinal, 10] + " kt" + "\n";
                            description += winds;
                        }

                        else if (dataParsed[latitidueFinal, 10] == "MM")
                        {
                            winds        = " Winds: " + degrees + "(" + dataParsed[latitidueFinal, 8] + ") at " + dataParsed[latitidueFinal, 9] + " kt \n";
                            description += winds;
                        }

                        if (dataParsed[latitidueFinal, 17] != "MM")
                        {
                            airTemp      = " Air Temperature: " + dataParsed[latitidueFinal, 17] + " F" + "\n";
                            description += airTemp;
                        }
                        if (dataParsed[latitidueFinal, 18] != "MM")
                        {
                            waterTemp    = " Water Temperature: " + dataParsed[latitidueFinal, 18] + " F" + "\n";
                            description += waterTemp;
                        }
                        if (dataParsed[latitidueFinal, 19] != "MM")
                        {
                            dewpoint     = " Dew Point: " + dataParsed[latitidueFinal, 19] + " F" + "\n";
                            description += dewpoint;
                        }


                        myCallout = new CalloutDefinition(title, description);
                        _mapView.ShowCalloutAt(e.Location, myCallout);

                        latitidueFinal = 0;
                    }
                    else
                    {
                        _mapView.DismissCallout();
                    }
                }
                catch (Exception ex)
                {
                }
            };
        }
Beispiel #26
0
        // myMapView 事件
        private async void MyMapView_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            IInputElement ie  = (IInputElement)(sender);
            MapPoint      loc = myMapView.ScreenToLocation(e.GetPosition(ie));

            switch (operation)
            {
            case OperateType.DrawPoint:     //画点
                Graphic pt = new Graphic(loc, pointSymbol);
                graphicsLayer.Graphics.Add(pt);
                break;

            case OperateType.DrawPolyline:    //画线
                pointCollection.Add(loc); if (pointCollection.Count >= 2)
                {
                    if (pointCollection.Count > 2)
                    {
                        Graphic         g  = graphicsLayer.Graphics[graphicsLayer.Graphics.Count - 1];
                        PolylineBuilder lb = new PolylineBuilder(pointCollection); g.Geometry = lb.ToGeometry();
                    }
                    else
                    {
                        Esri.ArcGISRuntime.Geometry.Polyline l = new Esri.ArcGISRuntime.Geometry.Polyline(pointCollection);
                        Graphic lg = new Graphic(l, lineSymbol);
                        graphicsLayer.Graphics.Add(lg);
                    }
                }
                break;

            case OperateType.DrawPolygon:    //画多边形
                pointCollection.Add(loc); if (pointCollection.Count >= 3)
                {
                    if (pointCollection.Count > 3)
                    {
                        Graphic        g  = graphicsLayer.Graphics[graphicsLayer.Graphics.Count - 1];
                        PolygonBuilder pb = new PolygonBuilder(pointCollection); g.Geometry = pb.ToGeometry();
                    }
                    else
                    {
                        Esri.ArcGISRuntime.Geometry.Polygon p = new Esri.ArcGISRuntime.Geometry.Polygon(pointCollection);
                        Graphic pg = new Graphic(p, fillSymbol);
                        graphicsLayer.Graphics.Add(pg);
                    }
                }
                break;

            case OperateType.None:    //缺省状态
                graphicsLayer.ClearSelection();
                IdentifyGraphicsOverlayResult result = await myMapView.IdentifyGraphicsOverlayAsync(graphicsLayer, e.GetPosition(ie), 5, false);

                //选择图形元素
                if (result.Graphics.Count < 1)
                {
                    curSelGraphic = null;
                    EditVertexMenuItem.IsEnabled   = false;
                    UneditVertexMenuItem.IsEnabled = false;
                    return;
                }
                curSelGraphic                = result.Graphics.First();
                curSelGraphic.IsSelected     = true;
                EditVertexMenuItem.IsEnabled = true;
                break;
            }
        }
Beispiel #27
0
        /// <summary>
        /// 地图点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void mapView_GeoViewTappedAsync(object sender, Esri.ArcGISRuntime.UI.Controls.GeoViewInputEventArgs e)
        {
            MapPoint mapLocation = e.Location;

            Esri.ArcGISRuntime.Geometry.Geometry myGeometry = GeometryEngine.Project(mapLocation, SpatialReferences.Wgs84);
            MapPoint projectedLocation = myGeometry as MapPoint;

            routeStops.Add(projectedLocation);

            double tolerance        = 0;
            int    maximumResults   = 1;
            bool   onlyReturnPopups = false;

            IdentifyGraphicsOverlayResult identifyResults = await mapView.IdentifyGraphicsOverlayAsync(
                PointOverlay,
                e.Position,
                tolerance,
                onlyReturnPopups,
                maximumResults);

            foreach (Graphic g in PointOverlay.Graphics)
            {
                PictureMarkerSymbol symbol = g.Symbol as PictureMarkerSymbol;
                if (symbol.Uri != IconDictionaryHelper.IconDictionary[IconDictionaryHelper.Icons.pin_blue])
                {
                    //恢复所有图标
                    PictureMarkerSymbol pictureMarkerSymbol = new PictureMarkerSymbol(IconDictionaryHelper.IconDictionary[IconDictionaryHelper.Icons.pin_blue])
                    {
                        Width   = symbol.Width,
                        Height  = symbol.Height,
                        OffsetX = symbol.OffsetX,
                        OffsetY = symbol.OffsetY
                    };
                    g.Symbol = pictureMarkerSymbol;
                }
            }

            if (identifyResults.Graphics.Count > 0)
            {
                Graphic             graphic    = identifyResults.Graphics[0];
                MapPoint            mapPoint   = graphic.Geometry as MapPoint;
                PictureMarkerSymbol iconSymbol = graphic.Symbol as PictureMarkerSymbol;
                double iconHeight = iconSymbol.Height;
                //改变选中图标
                PictureMarkerSymbol pictureMarkerSymbol = new PictureMarkerSymbol(IconDictionaryHelper.IconDictionary[IconDictionaryHelper.Icons.pin])
                {
                    Width   = iconSymbol.Width,
                    Height  = iconSymbol.Height,
                    OffsetX = iconSymbol.OffsetX,
                    OffsetY = iconSymbol.OffsetY
                };
                graphic.Symbol = pictureMarkerSymbol;
                ViewSpot viewInfo = GraphicsAttributes.ContainsKey(graphic) ? (GraphicsAttributes[graphic] as ViewSpot) : null;
                if (viewInfo != null)
                {
                    mapView.ShowCalloutAt(mapPoint, new ViewSpotCallout(viewInfo), new Point(0, iconHeight));
                    Tuple <object, int> param = new Tuple <object, int>(viewInfo, 1);
                    CommandForMainWindow.CommandsFreightStationToOverlayerCommand.Execute(param, Application.Current.MainWindow);
                }
            }
            else
            {
                mapView.DismissCallout();
            }
        }
Beispiel #28
0
        // myMapView 事件
        private async void MyMapView_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            IInputElement ie  = (IInputElement)(sender);
            MapPoint      loc = myMapView.ScreenToLocation(e.GetPosition(ie));

            switch (operation)
            {
            case OperateType.DrawPoint:     //画点
                Graphic pt = new Graphic(loc, pointSymbol);
                graphicsLayer.Graphics.Add(pt);
                break;

            case OperateType.DrawPolyline:    //画线
                pointCollection.Add(loc);
                if (pointCollection.Count >= 2)
                {
                    if (pointCollection.Count > 2)
                    {
                        Graphic         g  = graphicsLayer.Graphics[graphicsLayer.Graphics.Count - 1];
                        PolylineBuilder lb = new PolylineBuilder(pointCollection);
                        g.Geometry = lb.ToGeometry();
                    }
                    else
                    {
                        Esri.ArcGISRuntime.Geometry.Polyline l = new Esri.ArcGISRuntime.Geometry.Polyline(pointCollection);
                        Graphic lg = new Graphic(l, lineSymbol);
                        graphicsLayer.Graphics.Add(lg);
                    }
                }
                break;

            case OperateType.DrawPolygon:    //画多边形
                pointCollection.Add(loc);
                if (pointCollection.Count >= 3)
                {
                    if (pointCollection.Count > 3)
                    {
                        Graphic        g  = graphicsLayer.Graphics[graphicsLayer.Graphics.Count - 1];
                        PolygonBuilder pb = new PolygonBuilder(pointCollection);
                        g.Geometry = pb.ToGeometry();
                    }
                    else
                    {
                        Esri.ArcGISRuntime.Geometry.Polygon p = new Esri.ArcGISRuntime.Geometry.Polygon(pointCollection);
                        Graphic pg = new Graphic(p, fillSymbol);
                        graphicsLayer.Graphics.Add(pg);
                    }
                }
                break;

            case OperateType.None:    //缺省状态
                graphicsLayer.ClearSelection();
                IdentifyGraphicsOverlayResult result = await myMapView.IdentifyGraphicsOverlayAsync(graphicsLayer, e.GetPosition(ie), 5, false);

                //选择图形元素
                if (result.Graphics.Count < 1)
                {
                    curSelGraphic = null;
                    EditVertexMenuItem.IsEnabled   = false;
                    UneditVertexMenuItem.IsEnabled = false;
                    return;
                }
                curSelGraphic                = result.Graphics.First();
                curSelGraphic.IsSelected     = true;
                EditVertexMenuItem.IsEnabled = true;
                break;

            case OperateType.Cal_Clip:     //选择图形
                IdentifyGraphicsOverlayResult gResult = await myMapView.IdentifyGraphicsOverlayAsync(graphicsLayer, e.GetPosition(ie), 5, false);

                if (gResult.Graphics.Count < 1)
                {
                    return;
                }
                Graphic selGraphic = gResult.Graphics.First();
                selGraphic.IsSelected = true; listOfClipGraphics.Add(selGraphic); //记录所选图形
                if (listOfClipGraphics.Count == 2)                                //图形数目为2时,进行剪切计算
                {
                    Graphic g1 = listOfClipGraphics[0];
                    Graphic g2 = listOfClipGraphics[1];
                    if (g1.Geometry.GeometryType != GeometryType.Polygon || g2.Geometry.GeometryType != GeometryType.Polygon)     //如果所选图形不是多边形,则退出
                    {
                        MessageBox.Show("请选择两个多边形图形!");
                        listOfClipGraphics.Clear();
                        graphicsLayer.ClearSelection();
                        return;
                    }
                    Esri.ArcGISRuntime.Geometry.Geometry resultGeometry = GeometryEngine.Clip(g1.Geometry, g2.Geometry.Extent); //执行剪切操作
                    if (resultGeometry != null)                                                                                 //处理结果
                    {
                        graphicsLayer.Graphics.Remove(g1);                                                                      //从图形层中移除原图形
                        graphicsLayer.Graphics.Remove(g2);
                        Graphic clipedGraphic = new Graphic(resultGeometry, fillSymbol);                                        //利 用剪切结果构建新的图形
                        graphicsLayer.Graphics.Add(clipedGraphic); operation = OperateType.None;
                    }
                    listOfClipGraphics.Clear();     //清空图形选择集合
                    graphicsLayer.ClearSelection(); //清空图形层所选
                }
                break;

            case OperateType.Cal_Union:     // 联合
                IdentifyGraphicsOverlayResult gResultUnion = await myMapView.IdentifyGraphicsOverlayAsync(graphicsLayer, e.GetPosition(ie), 5, false);

                if (gResultUnion.Graphics.Count < 1)
                {
                    return;
                }
                Graphic selGraphicUnion = gResultUnion.Graphics.First();
                selGraphicUnion.IsSelected = true;
                listOfClipGraphics.Add(selGraphicUnion); //记录所选图形
                if (listOfClipGraphics.Count == 2)       //图形数目为2时,进行剪切计算
                {
                    Graphic g1 = listOfClipGraphics[0];
                    Graphic g2 = listOfClipGraphics[1];
                    if (g1.Geometry.GeometryType != GeometryType.Polygon || g2.Geometry.GeometryType != GeometryType.Polygon)     //如果所选图形不是多边形,则退出
                    {
                        MessageBox.Show("请选择两个多边形图形!");
                        listOfClipGraphics.Clear();
                        graphicsLayer.ClearSelection();
                        return;
                    }
                    Esri.ArcGISRuntime.Geometry.Geometry resultGeometry = GeometryEngine.Union(g1.Geometry, g2.Geometry.Extent); //执行剪切操作
                    if (resultGeometry != null)                                                                                  //处理结果
                    {
                        graphicsLayer.Graphics.Remove(g1);                                                                       //从图形层中移除原图形
                        graphicsLayer.Graphics.Remove(g2);
                        Graphic clipedGraphic = new Graphic(resultGeometry, fillSymbol);                                         //利 用剪切结果构建新的图形
                        graphicsLayer.Graphics.Add(clipedGraphic);
                        operation = OperateType.None;
                    }
                    listOfClipGraphics.Clear();     //清空图形选择集合
                    graphicsLayer.ClearSelection(); //清空图形层所选
                }
                break;

            case OperateType.Cal_Cut:     // 剪切
                IdentifyGraphicsOverlayResult gResult_Cut = await myMapView.IdentifyGraphicsOverlayAsync(graphicsLayer, e.GetPosition(ie), 5, false);

                if (gResult_Cut.Graphics.Count < 1)
                {
                    return;
                }
                Graphic selGraphic_Cut = gResult_Cut.Graphics.First();
                selGraphic_Cut.IsSelected = true;
                listOfClipGraphics.Add(selGraphic_Cut); //记录所选图形
                if (listOfClipGraphics.Count == 2)      //图形数目为1时,进行剪切计算
                {
                    Graphic g1 = listOfClipGraphics[0];
                    Graphic g2 = listOfClipGraphics[1];
                    if (g1.Geometry.GeometryType != GeometryType.Polygon || g2.Geometry.GeometryType != GeometryType.Polyline)     //如果所选图形不是多边形,则退出
                    {
                        MessageBox.Show("请先选择一个面要素后再选择一个线要素.");
                        listOfClipGraphics.Clear();
                        graphicsLayer.ClearSelection();
                        return;
                    }
                    Esri.ArcGISRuntime.Geometry.Polyline   polyLine       = (Esri.ArcGISRuntime.Geometry.Polyline)g2.Geometry;
                    Esri.ArcGISRuntime.Geometry.Geometry[] resultGeometry = GeometryEngine.Cut(g1.Geometry, polyLine); //执行剪切操作
                    if (resultGeometry != null)                                                                        //处理结果
                    {
                        graphicsLayer.Graphics.Remove(g1);
                        for (int z = 0; z < resultGeometry.Length; z++)
                        {
                            Graphic clipedGraphic = new Graphic(resultGeometry[z], fillSymbol);     //利 用剪切结果构建新的图形
                            graphicsLayer.Graphics.Add(clipedGraphic);
                        }
                        operation = OperateType.None;
                    }
                    listOfClipGraphics.Clear();     //清空图形选择集合
                    graphicsLayer.ClearSelection(); //清空图形层所选
                }
                break;

            case OperateType.Cal_Simplify:     // 拓扑纠正
                IdentifyGraphicsOverlayResult gResult_Simplify = await myMapView.IdentifyGraphicsOverlayAsync(graphicsLayer, e.GetPosition(ie), 5, false);

                if (gResult_Simplify.Graphics.Count < 1)
                {
                    return;
                }
                Graphic selGraphic_Simplify = gResult_Simplify.Graphics.First();
                selGraphic_Simplify.IsSelected = true;
                listOfClipGraphics.Add(selGraphic_Simplify); //记录所选图形
                if (listOfClipGraphics.Count == 1)           //图形数目为1时,进行剪切计算
                {
                    Graphic g1 = listOfClipGraphics[0];
                    if (g1.Geometry.GeometryType == GeometryType.Point)     //如果所选图形不是多边形,则退出
                    {
                        MessageBox.Show("请先选择一个面要素或线要素.");
                        listOfClipGraphics.Clear();
                        graphicsLayer.ClearSelection();
                        return;
                    }
                    Esri.ArcGISRuntime.Geometry.Geometry resultGeometry = GeometryEngine.Simplify(g1.Geometry); //执行剪切操作
                    if (resultGeometry != null)                                                                 //处理结果
                    {
                        graphicsLayer.Graphics.Remove(g1);                                                      //从图形层中移除原图形
                        Graphic clipedGraphic = new Graphic(resultGeometry, fillSymbol);                        //利 用剪切结果构建新的图形
                        graphicsLayer.Graphics.Add(clipedGraphic);
                        operation = OperateType.None;
                    }
                    listOfClipGraphics.Clear();     //清空图形选择集合
                    graphicsLayer.ClearSelection(); //清空图形层所选
                }
                break;

            case OperateType.Cal_Gene:     // 简化
                IdentifyGraphicsOverlayResult gResult_Gene = await myMapView.IdentifyGraphicsOverlayAsync(graphicsLayer, e.GetPosition(ie), 5, false);

                if (gResult_Gene.Graphics.Count < 1)
                {
                    return;
                }
                Graphic selGraphic_Gene = gResult_Gene.Graphics.First();
                selGraphic_Gene.IsSelected = true;
                listOfClipGraphics.Add(selGraphic_Gene); //记录所选图形
                if (listOfClipGraphics.Count == 1)       //图形数目为1时
                {
                    Graphic g1 = listOfClipGraphics[0];
                    if (g1.Geometry.GeometryType == GeometryType.Point)     //如果所选图形是点,则退出
                    {
                        MessageBox.Show("请先选择一个面要素或线要素.");
                        listOfClipGraphics.Clear();
                        graphicsLayer.ClearSelection();
                        return;
                    }
                    Esri.ArcGISRuntime.Geometry.Geometry resultGeometry = GeometryEngine.Generalize(g1.Geometry, 1000000.0, true); //执行剪切操作
                    if (resultGeometry != null)                                                                                    //处理结果
                    {
                        MessageBox.Show(resultGeometry.ToJson() + "\n" + resultGeometry.GeometryType);
                        graphicsLayer.Graphics.Remove(g1);                               //从图形层中移除原图形
                        Graphic clipedGraphic = new Graphic(resultGeometry, fillSymbol); //利 用剪切结果构建新的图形
                        graphicsLayer.Graphics.Add(clipedGraphic);
                        operation = OperateType.None;
                    }
                    listOfClipGraphics.Clear();     //清空图形选择集合
                    graphicsLayer.ClearSelection(); //清空图形层所选
                }
                break;

            case OperateType.Cal_Buff:     // 缓冲
                IdentifyGraphicsOverlayResult gResult_Buff = await myMapView.IdentifyGraphicsOverlayAsync(graphicsLayer, e.GetPosition(ie), 5, false);

                if (gResult_Buff.Graphics.Count < 1)
                {
                    return;
                }
                Graphic selGraphic_Buff = gResult_Buff.Graphics.First();
                selGraphic_Buff.IsSelected = true;
                listOfClipGraphics.Add(selGraphic_Buff); //记录所选图形
                if (listOfClipGraphics.Count == 1)       //图形数目为1时,进行剪切计算
                {
                    Graphic g1 = listOfClipGraphics[0];
                    Esri.ArcGISRuntime.Geometry.Geometry resultGeometry = GeometryEngine.Buffer(g1.Geometry, 1000000.0);                                                                                                                           //执行剪切操作
                    if (resultGeometry != null)                                                                                                                                                                                                    //处理结果
                    {
                        graphicsLayer.Graphics.Remove(g1);                                                                                                                                                                                         //从图形层中移除原图形
                        Graphic clipedGraphic = new Graphic(resultGeometry, new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, Color.FromArgb(125, 255, 250, 0), new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.FromArgb(0, 0, 0), 4.0))); //利 用剪切结果构建新的图形
                        graphicsLayer.Graphics.Add(clipedGraphic);
                        operation = OperateType.None;
                    }
                    listOfClipGraphics.Clear();     //清空图形选择集合
                    graphicsLayer.ClearSelection(); //清空图形层所选
                }
                break;

            case OperateType.Cal_Jiaodian:     // 交点
                IdentifyGraphicsOverlayResult gResult_Jiaodian = await myMapView.IdentifyGraphicsOverlayAsync(graphicsLayer, e.GetPosition(ie), 5, false);

                if (gResult_Jiaodian.Graphics.Count < 1)
                {
                    return;
                }
                Graphic selGraphic_Jiaodian = gResult_Jiaodian.Graphics.First();
                selGraphic_Jiaodian.IsSelected = true;
                listOfClipGraphics.Add(selGraphic_Jiaodian); //记录所选图形
                if (listOfClipGraphics.Count == 2)           //图形数目为1时,进行剪切计算
                {
                    Graphic g1 = listOfClipGraphics[0];
                    Graphic g2 = listOfClipGraphics[1];
                    IReadOnlyList <Geometry> resultGeometry = GeometryEngine.Intersections(g1.Geometry, g2.Geometry); //执行剪切操作
                    if (resultGeometry != null)                                                                       //处理结果
                    {
                        Graphic clipedGraphic = new Graphic(resultGeometry[0], pointSymbol);                          //利 用剪切结果构建新的图形
                        graphicsLayer.Graphics.Add(clipedGraphic);
                        operation = OperateType.None;
                    }
                    listOfClipGraphics.Clear();     //清空图形选择集合
                    graphicsLayer.ClearSelection(); //清空图形层所选
                }
                break;
            }
        }