private async void MapTapped(object sender, GeoViewInputEventArgs e) { try { // Get the result for where the user tapped on the raster layer. IdentifyLayerResult identifyResult = await _myMapView.IdentifyLayerAsync(_rasterLayer, e.Position, 1, false, 1); // If no cell was identified, dismiss the callout. if (!identifyResult.GeoElements.Any()) { _myMapView.DismissCallout(); return; } // Create a StringBuilder to display information to the user. var stringBuilder = new StringBuilder(); // Get the identified raster cell. GeoElement cell = identifyResult.GeoElements.First(); // Loop through the attributes (key/value pairs). foreach (KeyValuePair <string, object> keyValuePair in cell.Attributes) { // Add the key/value pair to the string builder. stringBuilder.AppendLine($"{keyValuePair.Key}: {keyValuePair.Value}"); } // Get the x and y values of the cell. double x = cell.Geometry.Extent.XMin; double y = cell.Geometry.Extent.YMin; // Add the X & Y coordinates where the user clicked raster cell to the string builder. stringBuilder.AppendLine($"X: {Math.Round(x, 4)}\nY: {Math.Round(y, 4)}"); // Create a label using the string. var cellLabel = new UILabel { Text = stringBuilder.ToString(), TextAlignment = UITextAlignment.Center, AdjustsFontSizeToFitWidth = false, Font = UIFont.SystemFontOfSize(15), TextColor = UIColor.Black, Lines = 0, TranslatesAutoresizingMaskIntoConstraints = false, MinimumFontSize = 25 }; // Display the label in the map view. _myMapView.ShowCalloutAt(e.Location, cellLabel); } catch (Exception ex) { new UIAlertView(ex.GetType().Name, ex.Message, (IUIAlertViewDelegate)null, "OK", null).Show(); } }
public void OnDump() { foreach (GeoElement ge in GeoElements) { ge.PoolRecycle(); } GeoElements.Clear(); CurrentEditGeoElement = null; RefreshInfo(); }
public override void InitWithGeometry(Geometry geometry) { VertexSpace unit = new VertexSpace(x, y, z); unit.preferredSign = sign; geometry.VertexUnitSetId(unit, 0); units = new VertexUnit[] { unit }; GeoVertex geoVertex = new GeoVertex(unit); elements = new GeoElement[] { geoVertex }; }
private void ResultList_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e) { if (resultList.SelectedItem != null) { GeoElement geoElement = geohash[(resultList.SelectedItem as TreeViewItem).Uid]; foreach (string key in geoElement.Attributes.Keys.ToArray()) { dataGrid.Items.Add(new IdentifyDataGridRow() { Field = key, Value = geoElement.Attributes[key] }); } } }
public override void InitWithGeometry(Geometry geometry) { VertexUnit unit1 = geometry.VertexUnit(edge.id1); VertexUnit unit2 = geometry.VertexUnit(edge.id2); units = new VertexUnit[] { }; GeoEdge geoEdge = new GeoEdge(unit1, unit2); elements = new GeoElement[] { geoEdge }; dependencies.Add(unit1); dependencies.Add(unit2); }
private async void MapTapped(object sender, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs e) { try { // Get the result for where the user tapped on the raster layer. IdentifyLayerResult identifyResult = await MyMapView.IdentifyLayerAsync(_rasterLayer, e.Position, 1, false, 1); // If no cell was identified, dismiss the callout. if (!identifyResult.GeoElements.Any()) { MyMapView.DismissCallout(); return; } // Create a StringBuilder to display information to the user. var stringBuilder = new StringBuilder(); // Get the identified raster cell. GeoElement cell = identifyResult.GeoElements.First(); // Loop through the attributes (key/value pairs). foreach (KeyValuePair <string, object> keyValuePair in cell.Attributes) { // Add the key/value pair to the string builder. stringBuilder.AppendLine($"{keyValuePair.Key}: {keyValuePair.Value}"); } // Get the x and y values of the cell. double x = cell.Geometry.Extent.XMin; double y = cell.Geometry.Extent.YMin; // Add the X & Y coordinates where the user clicked raster cell to the string builder. stringBuilder.AppendLine($"X: {Math.Round(x, 4)}\nY: {Math.Round(y, 4)}"); // Create a callout using the string. #if __IOS__ var definition = new CalloutDefinition(string.Empty, stringBuilder.ToString().Replace("\n", " ")); #else var definition = new CalloutDefinition(string.Empty, stringBuilder.ToString()); #endif // Display the call out in the map view. MyMapView.ShowCalloutAt(e.Location, definition); } catch (Exception ex) { await Application.Current.MainPage.DisplayAlert(ex.GetType().Name, ex.Message, "OK"); } }
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); } }
public void RemoveElement(GeoElement element) { if (element is GeoVertex) { RemoveGeoVertex((GeoVertex)element); } else if (element is GeoEdge) { RemoveGeoEdge((GeoEdge)element); } else if (element is GeoFace) { RemoveGeoFace((GeoFace)element); } }
public void AddElement(GeoElement element) { if (element is GeoVertex) { AddGeoVertex((GeoVertex)element); } else if (element is GeoEdge) { AddGeoEdge((GeoEdge)element); } else if (element is GeoFace) { AddGeoFace((GeoFace)element); } }
public void RemoveElement(GeoElement geoElement) { if (geoElement is GeoVertex) { RemoveVertex((GeoVertex)geoElement); } else if (geoElement is GeoEdge) { RemoveEdge((GeoEdge)geoElement); } else if (geoElement is GeoFace) { RemoveFace((GeoFace)geoElement); } }
public void UpdateElement(GeoElement geoElement) { if (geoElement is GeoVertex) { UpdateVertex((GeoVertex)geoElement); } else if (geoElement is GeoEdge) { UpdateEdge((GeoEdge)geoElement); } else if (geoElement is GeoFace) { UpdateFace((GeoFace)geoElement); } }
public void AddElement(GeoElement geoElement) { if (geoElement is GeoVertex) { AddVertex((GeoVertex)geoElement); } else if (geoElement is GeoEdge) { AddEdge((GeoEdge)geoElement); } else if (geoElement is GeoFace) { AddFace((GeoFace)geoElement); } }
private async void MouseMoved(object sender, PointerRoutedEventArgs e) { try { // Get the curent mouse position. Point position = e.GetCurrentPoint(MyMapView).Position; // Get the result for where the user hovered on the raster layer. IdentifyLayerResult identifyResult = await MyMapView.IdentifyLayerAsync(_rasterLayer, position, 1, false, 1); // If no cell was identified, dismiss the callout. if (!identifyResult.GeoElements.Any()) { MyMapView.DismissCallout(); return; } // Create a StringBuilder to display information to the user. var stringBuilder = new StringBuilder(); // Get the identified raster cell. GeoElement cell = identifyResult.GeoElements.First(); // Loop through the attributes (key/value pairs). foreach (KeyValuePair <string, object> keyValuePair in cell.Attributes) { // Add the key/value pair to the string builder. stringBuilder.AppendLine($"{keyValuePair.Key}: {keyValuePair.Value}"); } // Get the x and y values of the cell. double x = cell.Geometry.Extent.XMin; double y = cell.Geometry.Extent.YMin; // Add the X & Y coordinates where the user clicked raster cell to the string builder. stringBuilder.AppendLine($"X: {Math.Round(x, 4)}\nY: {Math.Round(y, 4)}"); // Create a callout using the string. var definition = new CalloutDefinition(stringBuilder.ToString()); // Display the call out in the map view. MyMapView.ShowCalloutAt(MyMapView.ScreenToLocation(position), definition); } catch (Exception ex) { await new MessageDialog(ex.Message, ex.GetType().Name).ShowAsync(); } }
public override void InitWithGeometry(Geometry geometry) { try { VertexUnit unit1 = geometry.VertexUnit(edge.id1); VertexUnit unit2 = geometry.VertexUnit(edge.id2); units = new VertexUnit[] { }; GeoEdge geoEdge = new GeoEdge(unit1, unit2); elements = new GeoElement[] { geoEdge }; dependencies.Add(unit1); dependencies.Add(unit2); } catch (Exception e) { Debug.Log(e.Message); } }
private async void MapView_Tapped(object sender, GeoViewInputEventArgs e) { // Clear any existing selection. _damageLayer.ClearSelection(); _selectedFeature = null; // Reset the UI. AttachmentsListBox.IsEnabled = false; AttachmentsListBox.ItemsSource = null; AddAttachmentButton.IsEnabled = false; try { // Perform an identify to determine if a user tapped on a feature. IdentifyLayerResult identifyResult = await MyMapView.IdentifyLayerAsync(_damageLayer, e.Position, 2, false); // Do nothing if there are no results. if (!identifyResult.GeoElements.Any()) { return; } // Get the selected feature as an ArcGISFeature. It is assumed that all GeoElements in the result are of type ArcGISFeature. GeoElement tappedElement = identifyResult.GeoElements.First(); ArcGISFeature tappedFeature = (ArcGISFeature)tappedElement; // Select the feature in the UI and hold a reference to the tapped feature in a field. _damageLayer.SelectFeature(tappedFeature); _selectedFeature = tappedFeature; // Load the feature. await tappedFeature.LoadAsync(); // Get the attachments. IReadOnlyList <Attachment> attachments = await tappedFeature.GetAttachmentsAsync(); // Populate the UI with a list of attachments that have a content type of image/jpeg. AttachmentsListBox.ItemsSource = attachments.Where(attachment => attachment.ContentType == "image/jpeg"); AttachmentsListBox.IsEnabled = true; AddAttachmentButton.IsEnabled = true; } catch (Exception ex) { await new MessageDialog2(ex.ToString(), "Error loading feature").ShowAsync(); } }
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); }
private List <ElementStyle> ElementStyle(GeoElement element) { if (element is GeoVertex) { return(ConfigManager.VertexStyle); } else if (element is GeoEdge) { return(ConfigManager.EdgeStyle); } else if (element is GeoFace) { return(ConfigManager.FaceStyle); } return(null); }
public static GeoElement FromBaseObject(BaseObject baseObj) { if (baseObj == null || baseObj.NativeObject == IntPtr.Zero) { return(null); } GeoElement obj = baseObj as GeoElement; if (object.Equals(obj, null)) { obj = new GeoElement(CreatedWhenConstruct.CWC_NotToCreate); obj.BindNativeObject(baseObj.NativeObject, "CGeoElement"); obj.IncreaseCast(); } return(obj); }
private Color DefaultColor(GeoElement element) { if (element is GeoVertex) { return(StyleManager.Point); } else if (element is GeoEdge) { return(StyleManager.Line); } else if (element is GeoFace) { return(StyleManager.Plane); } return(Color.white); }
public void OnMouseLeftDown() { MouseLeftDown = true; MouseLeftDownPos = Camera.main.ScreenToWorldPoint(Input.mousePosition); lastMousePos = MouseLeftDownPos; switch (MyState) { case States.None: { break; } case States.Select: { GeoElement ge = ClickSelectGeoElement(); if (ge != null) { if (CurrentEditGeoElement == ge) { StartDragMove = true; } } break; } case States.Draw: { MyState = States.DuringDrawing; break; } case States.DuringDrawing: { break; } case States.Delete: { break; } } }
public void GeometryElementDiaplayChange(GeoElement geoElement, bool visible) { ElementBehaviour elementBehaviour = elementMap[geoElement]; elementBehaviour.SetVisible(visible); if (visible) { hideElements.Remove(geoElement); } else { hideElements.Add(geoElement); } if (OnElementDisplayChange != null) { OnElementDisplayChange(hideElements.Count); } }
public override void OnClickElement(GeoElement element) { FormElement form = null; if (element is GeoVertex) { form = geoController.VertexForm((GeoVertex)element); } else if (element is GeoEdge) { form = geoController.EdgeForm((GeoEdge)element); } else if (element is GeoFace) { form = geoController.FaceForm((GeoFace)element); } if (form != null) { inputPanel.InputFields(form.fields); } }
public override void InitWithGeometry(Geometry geometry) { int count = face.ids.Length; VertexUnit[] vertexUnits = new VertexUnit[count]; for (int i = 0; i < count; i++) { vertexUnits[i] = geometry.VertexUnit(face.ids[i]); } VertexPlaneCenter unit = new VertexPlaneCenter(vertexUnits); unit.preferredSign = sign; geometry.VertexUnitSetId(unit, 0); units = new VertexUnit[] { unit }; GeoVertex geoVertex = new GeoVertex(unit); elements = new GeoElement[] { geoVertex }; dependencies.AddRange(vertexUnits); }
public override void InitWithGeometry(Geometry geometry) { if (geometry is ResolvedBody) { resolvedBody = (ResolvedBody)geometry; } units = new VertexUnit[] { }; GeoVertex[] geoVertices = geometry.GeoVertices(); vertices = new VertexUnit[geoVertices.Length]; int[] ids = new int[geoVertices.Length]; for (int i = 0; i < geoVertices.Length; i++) { vertices[i] = geoVertices[i].VertexUnit(); ids[i] = vertices[i].id; } face = new FaceRefer(ids); elements = new GeoElement[] { }; dependencies.AddRange(units); }
private async void MapView_Tapped(object sender, GeoViewInputEventArgs e) { // Clear any existing selection. _damageLayer.ClearSelection(); try { // Perform an identify to determine if a user tapped on a feature. IdentifyLayerResult identifyResult = await _myMapView.IdentifyLayerAsync(_damageLayer, e.Position, 2, false); // Do nothing if there are no results. if (!identifyResult.GeoElements.Any()) { return; } // Get the selected feature as an ArcGISFeature. It is assumed that all GeoElements in the result are of type ArcGISFeature. GeoElement tappedElement = identifyResult.GeoElements.First(); ArcGISFeature tappedFeature = (ArcGISFeature)tappedElement; // Select the feature. _damageLayer.SelectFeature(tappedFeature); // Create the view controller. AttachmentsTableView attachmentsTableViewController = new AttachmentsTableView(tappedFeature); // Present the view controller. NavigationController.PushViewController(attachmentsTableViewController, true); // Deselect the feature. _damageLayer.ClearSelection(); } catch (Exception ex) { ShowMessage(ex.ToString(), "Error selecting feature"); } }
public void SetEdge(GeoEdge edge) { element = edge; ButtonBoard buttonBoard = InitRootButtonBoard(); List <ButtonAtRoot> buttonAtRoot = new List <ButtonAtRoot>(); buttonAtRoot.Add(ColorButton); buttonAtRoot.Add(StyleButton); buttonAtRoot.Add(DisplayButton); buttonAtRoot.Add(SignButton); if (!edge.isBased) { buttonAtRoot.Add(DeleteButton); } buttonBoard.CountOfButtons = () => buttonAtRoot.Count; buttonBoard.ButtonAtIndex = (button, i) => buttonAtRoot[i](button); buttonBoard.InitButtons(); overlay.SetActive(true); }
/// <summary> /// Shows a callout with information about the graphics/features at that location /// </summary> /// <param name="position"></param> private async void ShowCalloutTopDispatches(Point position) { // Check if a cell is already being identified if (_isIdentifying) { _nextIdentifyAction = () => ShowCalloutTopDispatches(position); return; } // Set variable to true to prevent concurrent identify calls. _isIdentifying = true; try { // Get the result for where the user hovered on the raster layer. var identifyResult = await this.MapView.IdentifyGraphicsOverlayAsync(this.Dispatches.FeatureGraphicsLayer, position, 1, false, 1); var graphic = identifyResult.Graphics.FirstOrDefault() as CustomGraphic; // If no cell was identified, dismiss the callout. if (graphic != null && graphic.ID != _previousCallout) { this.MapView.DismissCallout(); _previousCallout = -1; } else if (graphic == null) { this.MapView.DismissCallout(); _previousCallout = -1; return; } else if (graphic != null && graphic.ID == _previousCallout) { return; } _previousCallout = graphic.ID; // Create a StringBuilder to display information to the user. var stringBuilder = new StringBuilder(); // Get the identified raster cell. GeoElement cell = graphic; // Loop through the attributes (key/value pairs). foreach (KeyValuePair <string, object> keyValuePair in cell.Attributes) { // Add the key/value pair to the string builder. stringBuilder.AppendLine($"{keyValuePair.Key}: {keyValuePair.Value}"); } var mapPoint = this.MapView.ScreenToLocation(position).ToWgs84() as MapPoint; // Get the x and y values of the cell. double x = position.X; double y = position.Y; // Add the X & Y coordinates where the user clicked raster cell to the string builder. stringBuilder.AppendLine($"X: {Math.Round(mapPoint.X, 4)}\nY: {Math.Round(mapPoint.Y, 4)}"); // Create a callout using the string. var definition = new CalloutDefinition(stringBuilder.ToString()); // TODO: To show a custom view for the callout, use this.MapView.ShowCalloutAt(graphic.Geometry as MapPoint, this.MyView); // Display the call out in the map view. this.MapView.ShowCalloutAt(graphic.Geometry as MapPoint, definition); } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().ToString()); } finally { _isIdentifying = false; } // Check if there is a new position to identify. if (_nextIdentifyAction != null) { Action action = _nextIdentifyAction; // Clear the queued identify action. _nextIdentifyAction = null; // Run the next action. action(); } }
public void RemoveObserveElement(GeoElement element) { observeElements.Remove(element); }
public BaseObject Create() { GeoElement emptyInstance = new GeoElement(CreatedWhenConstruct.CWC_NotToCreate); return(emptyInstance); }
// public HashSet<Auxiliary> VertexTotalObserveAuxiliaries(VertexUnit unit) // { // HashSet<Auxiliary> obervers = new HashSet<Auxiliary>(); // List<Auxiliary> auxiliaries = VertexObservers(unit); // foreach (Auxiliary auxiliary in auxiliaries) // foreach (VertexUnit item in auxiliary.units) // obervers.UnionWith(VertexTotalObserveAuxiliaries(item)); // obervers.UnionWith(auxiliaries); // obervers.Add(vertexAuxiliaryMap[unit]); // return obervers; // } // public HashSet<Auxiliary> VertexAuxiliaries(VertexUnit unit) // { // HashSet<Auxiliary> auxiliaries = new HashSet<Auxiliary>(VertexObservers(unit)); // Auxiliary dependency; // vertexAuxiliaryMap.TryGetValue(unit, out dependency); // if (dependency != null) // auxiliaries.Add(dependency); // return auxiliaries; // } // public HashSet<Auxiliary> AuxiliaryTotalObservers(Auxiliary auxiliary) // { // List<Auxiliary> observers = AuxiliaryObservers(auxiliary); // HashSet<Auxiliary> total = new HashSet<Auxiliary>(observers); // foreach (Auxiliary item in observers) // total.UnionWith(AuxiliaryTotalObservers(item)); // total.Add(auxiliary); // return total; // } // private List<Auxiliary> AuxiliaryObservers(Auxiliary auxiliary) // { // List<Auxiliary> total = new List<Auxiliary>(); // foreach (VertexUnit unit in auxiliary.units) // { // List<Auxiliary> observers = VertexObservers(unit); // if (observers != null) // total.AddRange(observers); // } // return total; // } public Auxiliary ElementAuxiliary(GeoElement element) { return(elementAuxiliaryMap[element]); }