/// <summary> /// Shows a callout for any tapped graphics. /// </summary> private async void MyMapView_GeoViewTapped(object sender, GeoViewInputEventArgs e) { // Search for the graphics underneath the user's tap. IReadOnlyList <IdentifyGraphicsOverlayResult> results = await MyMapView.IdentifyGraphicsOverlaysAsync(e.Position, 12, false); // Clear callouts and return if there was no result. if (results.Count < 1 || results.First().Graphics.Count < 1) { MyMapView.DismissCallout(); return; } // Get the first graphic from the first result. Graphic matchingGraphic = results.First().Graphics.First(); // Get the title; manually added to the point's attributes in UpdateSearch. string title = matchingGraphic.Attributes["Match_Title"].ToString(); // Get the address; manually added to the point's attributes in UpdateSearch. string address = matchingGraphic.Attributes["Match_Address"].ToString(); // Define the callout. CalloutDefinition calloutBody = new CalloutDefinition(title, address); // Show the callout on the map at the tapped location. MyMapView.ShowCalloutAt(e.Location, calloutBody); }
/// <summary> /// Handle tap event on the map; displays callouts showing the address for a tapped search result /// </summary> private async void MyMapView_GeoViewTapped(object sender, GeoViewInputEventArgs e) { // Search for the graphics underneath the user's tap IReadOnlyList <IdentifyGraphicsOverlayResult> results = await MyMapView.IdentifyGraphicsOverlaysAsync(e.Position, 12, false); // Return gracefully if there was no result if (results.Count < 1 || results.First().Graphics.Count < 1) { return; } // Reverse geocode to get addresses IReadOnlyList <GeocodeResult> addresses = await _geocoder.ReverseGeocodeAsync(e.Location); // Get the first result GeocodeResult address = addresses.First(); // Use the city and region for the Callout Title string calloutTitle = address.Attributes["City"] + ", " + address.Attributes["Region"]; // Use the metro area for the Callout Detail string calloutDetail = address.Attributes["MetroArea"].ToString(); // Define the callout CalloutDefinition calloutBody = new CalloutDefinition(calloutTitle, calloutDetail); // Show the callout on the map at the tapped location MyMapView.ShowCalloutAt(e.Location, calloutBody); }
private async void MyMapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs e) { // Search for the graphics underneath the user's tap IReadOnlyList <IdentifyGraphicsOverlayResult> results = await MyMapView.IdentifyGraphicsOverlaysAsync(e.Position, 12, false); // Return gracefully if there was no result //if (results.Count < 1 || results.First().Graphics.Count < 1) { return; } // Reverse geocode to get addresses IReadOnlyList <GeocodeResult> addresses = await _geocoder.ReverseGeocodeAsync(e.Location); // Get the first result GeocodeResult address = addresses.First(); // Use the city and region for the Callout Title //String calloutTitle = address.Attributes["City"] + ", " + address.Attributes["Region"]; String calloutTitle = "日本住所"; // Use the metro area for the Callout Detail String calloutDetail = address.Attributes["Address"].ToString(); // Use the MapView to convert from the on-screen location to the on-map location MapPoint point = MyMapView.ScreenToLocation(e.Position); // Define the callout CalloutDefinition calloutBody = new CalloutDefinition(calloutTitle, calloutDetail); // Show the callout on the map at the tapped location MyMapView.ShowCalloutAt(point, calloutBody); }
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 MapViewTapped_Mouse_Point(object sender, GeoViewInputEventArgs geoViewInputEventArgs) { // MyMapView_MouseMove(sender, geoViewInputEventArgs); // IdentifyGraphicsOverlayResult result = null; // Graphic _identifiedGraphic = null; _sketchOverlay.Graphics.Clear(); try { var pixelTolerance = 1; var returnPopupsOnly = false; var maxResults = 100; System.Windows.Point tapScreenPoint = geoViewInputEventArgs.Position; MapPoint mapPoint = geoViewInputEventArgs.Location; var es = Mapcoordinates_Change(mapPoint); Graphic _pointgraph = point_graphic_creation(es); Graphic _identifiedGraphic = null; IReadOnlyList <IdentifyGraphicsOverlayResult> idGraphicOverlayResults = await MyMapView.IdentifyGraphicsOverlaysAsync(tapScreenPoint, pixelTolerance, returnPopupsOnly, maxResults); if (idGraphicOverlayResults.Count == 1) { foreach (IdentifyGraphicsOverlayResult idGraphicResult in idGraphicOverlayResults) { // iterate all graphics in the overlay and select them foreach (Graphic g in idGraphicResult.Graphics) { var ter = g.Symbol.ToString(); if (ter != "Esri.ArcGISRuntime.Symbology.TextSymbol") { if (g.IsSelected == true) { g.IsSelected = false; } else { g.IsSelected = true; } } else { var ter1 = g.Geometry; // return; } } } } else { // iterate each graphics overlay foreach (IdentifyGraphicsOverlayResult idGraphicResult in idGraphicOverlayResults) { // iterate all graphics in the overlay and select them foreach (Graphic g in idGraphicResult.Graphics) { var ter = g.Symbol.ToString(); if (ter != "Esri.ArcGISRuntime.Symbology.TextSymbol") { if (g.IsSelected == true) { g.IsSelected = false; } else { g.IsSelected = true; } } else { var ter1 = g.Geometry; // return; } } } // Graphic _graphic = result.Graphics.Last(); } } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error"); } }