private async void MapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs e) { // get the tap location in screen units var tapScreenPoint = e.Position; var pixelTolerance = 20; var returnPopupsOnly = false; var maxLayerResults = 12; // identify all layers in the MapView, passing the tap point, tolerance, types to return, and max results IReadOnlyList <IdentifyLayerResult> idLayerResults = await mapView.IdentifyLayersAsync(tapScreenPoint, pixelTolerance, returnPopupsOnly, maxLayerResults); // iterate the results for each layer foreach (IdentifyLayerResult idResults in idLayerResults) { // get the layer identified and cast it to FeatureLayer FeatureLayer idLayer = idResults.LayerContent as FeatureLayer; // iterate each identified GeoElement in the results for this layer foreach (GeoElement idElement in idResults.GeoElements) { // cast the result GeoElement to Feature Feature idFeature = idElement as Feature; // select this feature in the feature layer idLayer.SelectFeature(idFeature); } } }
private async void MyMapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs e) { // Indicate that the geoprocessing is running SetBusy(); // Clear previous user click location and the viewshed geoprocessing task results _inputOverlay.Graphics.Clear(); _resultOverlay.Graphics.Clear(); // Get the tapped point MapPoint geometry = e.Location; // Create a marker graphic where the user clicked on the map and add it to the existing graphics overlay Graphic myInputGraphic = new Graphic(geometry); _inputOverlay.Graphics.Add(myInputGraphic); // Normalize the geometry if wrap-around is enabled // This is necessary because of how wrapped-around map coordinates are handled by Runtime // Without this step, the task may fail because wrapped-around coordinates are out of bounds. if (MyMapView.IsWrapAroundEnabled) { geometry = (MapPoint)GeometryEngine.NormalizeCentralMeridian(geometry); } try { // Execute the geoprocessing task using the user click location await CalculateViewshed(geometry); } catch (Exception ex) { await((Page)Parent).DisplayAlert("Error", ex.ToString(), "OK"); } }
private async void MapViewTapped(object sender, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs e) { try { // Get the feature layer from the map. FeatureLayer incidentLayer = MyMapView.Map.OperationalLayers.First() as FeatureLayer; // Identify the tapped on feature. IdentifyLayerResult result = await MyMapView.IdentifyLayerAsync(incidentLayer, e.Position, 12, true); if (result?.Popups?.FirstOrDefault() is Popup popup) { // Remove the instructions label. InstructionsLabel.IsVisible = false; MyPopupViewer.IsVisible = true; // Create a new popup manager for the popup. MyPopupViewer.PopupManager = new PopupManager(popup); QueryParameters queryParams = new QueryParameters { // Set the geometry to selection envelope for selection by geometry. Geometry = new Envelope((MapPoint)popup.GeoElement.Geometry, 6, 6) }; // Select the features based on query parameters defined above. await incidentLayer.SelectFeaturesAsync(queryParams, SelectionMode.New); } } catch (Exception ex) { Debug.Print(ex.Message); } }
/// <summary> /// Action effectuée au clic sur la carte /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void MyView_GeoViewTapped(object sender, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs e) { // au clic, on va aller faire un identify sur la couche. IdentifyLayerResult identifyResult = await myView.IdentifyLayerAsync(stationnements, e.Position, 5); // on clear la sélection existante stationnements.ClearSelection(); // on cache le formulaire attributaire AttributesForm.IsVisible = false; // Si on récupère un objet (ou plusieurs) if (identifyResult.GeoElements.Count > 0) { // on affiche le formulaire AttributesForm.IsVisible = true; // on récupère le premier résultat Feature feature = identifyResult.GeoElements[0] as Feature; // on sélectionne l'objet sur la carte stationnements.SelectFeature(feature); // Mise à jour de l'IHM // implémentation simple attributeTitle.Title = "Stationnement : " + feature.Attributes["LibVoie"].ToString(); LibVoie.Detail = feature.Attributes["LibVoie"].ToString(); Abonnement.Detail = feature.Attributes["Abonnement"].ToString(); QUARTIER.Detail = feature.Attributes["QUARTIER"].ToString(); SECTEUR.Detail = feature.Attributes["SECTEUR"].ToString(); ZONE_.Detail = feature.Attributes["ZONE_"].ToString(); } }
/// <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, 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"]; // Use the metro area for the Callout Detail String calloutDetail = address.Attributes["MetroArea"].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 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 void MyMapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs e) { try { // Create a map point (in the WebMercator projected coordinate system) from the GUI screen coordinate. MapPoint userTappedMapPoint = MyMapView.ScreenToLocation(e.Position); // Add the map point to the list that will be used by the GeometryEngine.ConvexHull operation. _inputPointCollection.Add(userTappedMapPoint); // Create a simple marker symbol to display where the user tapped/clicked on the map. The marker symbol // will be a solid, red circle. SimpleMarkerSymbol userTappedSimpleMarkerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, Colors.Red, 10); // Create a new graphic for the spot where the user clicked on the map using the simple marker symbol. Graphic userTappedGraphic = new Graphic(userTappedMapPoint, userTappedSimpleMarkerSymbol); // Set the Z index for the user tapped graphic so that it appears above the convex hull graphic(s) added later. userTappedGraphic.ZIndex = 1; // Add the user tapped/clicked map point graphic to the graphic overlay. _graphicsOverlay.Graphics.Add(userTappedGraphic); } catch (System.Exception ex) { // Display an error message if there is a problem adding user tapped graphics. DisplayAlert("Error", "Can't add user tapped graphic: " + ex.Message, "OK"); } }
private async void MyMapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs e) { try { // Perform the identify operation IdentifyLayerResult myIdentifyResult = await MyMapView.IdentifyLayerAsync(_wmsLayer, e.Position, 20, false); // Return if there's nothing to show if (myIdentifyResult.GeoElements.Count < 1) { return; } // Retrieve the identified feature, which is always a WmsFeature for WMS layers WmsFeature identifiedFeature = (WmsFeature)myIdentifyResult.GeoElements[0]; // Retrieve the WmsFeature's HTML content string htmlContent = identifiedFeature.Attributes["HTML"].ToString(); // Note that the service returns a boilerplate HTML result if there is no feature found. // This test should work for most arcGIS-based WMS services, but results may vary. if (!htmlContent.Contains("OBJECTID")) { // Return without showing the result return; } // Show a page with the HTML content await Navigation.PushAsync(new WmsIdentifyResultDisplayPage(htmlContent)); } catch (Exception ex) { await((Page)Parent).DisplayAlert("Error", ex.ToString(), "OK"); } }
private void MapViewTapped(object sender, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs geoViewInputEventArgs) { // Get the tapped location MapPoint tappedLocation = geoViewInputEventArgs.Location; // Show the tapped location _tappedLocationGraphic.Geometry = tappedLocation; // Get the nearest vertex in the polygon ProximityResult nearestVertexResult = GeometryEngine.NearestVertex(_polygonGraphic.Geometry, tappedLocation); // Get the nearest coordinate in the polygon ProximityResult nearestCoordinateResult = GeometryEngine.NearestCoordinate(_polygonGraphic.Geometry, tappedLocation); // Get the distance to the nearest vertex in the polygon int distanceVertex = (int)(nearestVertexResult.Distance / 1000); // Get the distance to the nearest coordinate in the polygon int distanceCoordinate = (int)(nearestCoordinateResult.Distance / 1000); // Show the nearest vertex in blue _nearestVertexGraphic.Geometry = nearestVertexResult.Coordinate; // Show the nearest coordinate in red _nearestCoordinateGraphic.Geometry = nearestCoordinateResult.Coordinate; // Show the distances in the UI ResultsLabel.Text = $"Vertex dist: {distanceVertex} km, Point dist: {distanceCoordinate} km"; }
/// <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, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs e) { try { // 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); } catch (Exception ex) { await Application.Current.MainPage.DisplayAlert("Error", ex.ToString(), "OK"); } }
/// <summary> /// Shows a callout for any tapped graphics /// </summary> 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); // 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"] as String; // Get the address; manually added to the point's attributes in UpdateSearch String address = matchingGraphic.Attributes["Match_Address"] as String; // Define the callout CalloutDefinition calloutBody = new CalloutDefinition(title, address); // Show the callout on the map at the tapped location MyMapView.ShowCalloutAt(e.Location, calloutBody); }
private async void SceneViewTapped(object sender, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs e) { // Get the scene layer from the scene (first and only operational layer). ArcGISSceneLayer sceneLayer = (ArcGISSceneLayer)MySceneView.Scene.OperationalLayers.First(); // Clear any existing selection. sceneLayer.ClearSelection(); try { // Identify the layer at the tap point. // Use a 10-pixel tolerance around the point and return a maximum of one feature. Point tapPoint = new Point(e.Position.X, e.Position.Y); IdentifyLayerResult result = await MySceneView.IdentifyLayerAsync(sceneLayer, tapPoint, 10, false, 1); // Get the GeoElements that were identified (will be 0 or 1 element). IReadOnlyList <GeoElement> geoElements = result.GeoElements; // If a GeoElement was identified, select it in the scene. if (geoElements.Any()) { GeoElement geoElement = geoElements.FirstOrDefault(); if (geoElement != null) { // Select the feature to highlight it in the scene view. sceneLayer.SelectFeature((Feature)geoElement); } } } catch (Exception ex) { await Application.Current.MainPage.DisplayAlert("Error", ex.ToString(), "OK"); } }
private async void MyMapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs e) { // Clear any existing popups. MyMapView.DismissCallout(); try { // Perform identify on the KML layer and get the results. IdentifyLayerResult identifyResult = await MyMapView.IdentifyLayerAsync(_forecastLayer, e.Position, 2, false); // Return if there are no results that are KML placemarks. if (!identifyResult.GeoElements.OfType <KmlGeoElement>().Any()) { return; } // Get the first identified feature that is a KML placemark KmlNode firstIdentifiedPlacemark = identifyResult.GeoElements.OfType <KmlGeoElement>().First().KmlNode; // Show a page with the HTML content await Navigation.PushAsync(new KmlIdentifyResultDisplayPage(firstIdentifiedPlacemark.BalloonContent)); } catch (Exception ex) { await Application.Current.MainPage.DisplayAlert("Error", ex.ToString(), "OK"); } }
private void MyMapViewOnGeoViewTapped(object sender, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs geoViewInputEventArgs) { // Get the tapped point, projected to WGS84. MapPoint destination = (MapPoint)GeometryEngine.Project(geoViewInputEventArgs.Location, SpatialReferences.Wgs84); // Update the destination graphic. _endLocationGraphic.Geometry = destination; // Get the points that define the route polyline. PointCollection polylinePoints = new PointCollection(SpatialReferences.Wgs84) { (MapPoint)_startLocationGraphic.Geometry, destination }; // Create the polyline for the two points. Polyline routeLine = new Polyline(polylinePoints); // Densify the polyline to show the geodesic curve. Geometry pathGeometry = GeometryEngine.DensifyGeodetic(routeLine, 1, LinearUnits.Kilometers, GeodeticCurveType.Geodesic); // Apply the curved line to the path graphic. _pathGraphic.Geometry = pathGeometry; // Calculate and show the distance. double distance = GeometryEngine.LengthGeodetic(pathGeometry, LinearUnits.Kilometers, GeodeticCurveType.Geodesic); ResultsLabel.Text = $"{(int)distance} kilometers"; }
private async void MapView_Tapped(object sender, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs e) { try { // Create the feature. ArcGISFeature feature = (ArcGISFeature)_damageFeatureTable.CreateFeature(); // Get the normalized geometry for the tapped location and use it as the feature's geometry. MapPoint tappedPoint = (MapPoint)GeometryEngine.NormalizeCentralMeridian(e.Location); feature.Geometry = tappedPoint; // Set feature attributes. feature.SetAttributeValue("typdamage", "Minor"); feature.SetAttributeValue("primcause", "Earthquake"); // Add the feature to the table. await _damageFeatureTable.AddFeatureAsync(feature); // Apply the edits to the service. await _damageFeatureTable.ApplyEditsAsync(); // Update the feature to get the updated objectid - a temporary ID is used before the feature is added. feature.Refresh(); // Confirm feature addition. await((Page)Parent).DisplayAlert("Success!", $"Created feature {feature.Attributes["objectid"]}", "OK"); } catch (Exception ex) { await((Page)Parent).DisplayAlert("Error adding feature", ex.ToString(), "OK"); } }
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"); } }
private void SceneViewTapped(object sender, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs e) { // Ignore if tapped out of bounds (e.g. the sky). if (e.Location == null) { return; } // When the view is tapped, define the observer or target location with the tap point as appropriate if (_observerLocation == null) { // Define the observer location (plus an offset for observer height) and set the target to the same point _observerLocation = new MapPoint(e.Location.X, e.Location.Y, e.Location.Z + _zOffset); _lineOfSightAnalysis.ObserverLocation = _observerLocation; _lineOfSightAnalysis.TargetLocation = _observerLocation; // Clear the target location (if any) so the next click will define the target _targetLocation = null; } else if (_targetLocation == null) { // Define the target _targetLocation = new MapPoint(e.Location.X, e.Location.Y, e.Location.Z + _zOffset); _lineOfSightAnalysis.TargetLocation = _targetLocation; // Clear the observer location so it can be defined again _observerLocation = null; } }
private void ARGeoViewTapped(object sender, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs e) { // If the tapped position is valid, display the scene. if (MyARSceneView.SetInitialTransformation(e.Position)) { DisplayScene(); } }
private async void OnMapViewTapped(object sender, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs e) { try { Console.WriteLine("タップしました"); // 2回目以降の検索時でフィーチャが選択されている場合は、選択を解除 if (myFeatures != null && myFeatures.Count() != 0) { myFeatureLayer.UnselectFeatures(myFeatures); } // グラフィック オーバレイに追加したグラフィックを削除 myGraphicsOverlay.Graphics.Clear(); // タップした地点から1000メートルのバッファーの円を作成し、グラフィックとして表示する var buffer = GeometryEngine.Buffer(e.Location, 1000); var outLineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.DashDot, System.Drawing.Color.Yellow, 5); var fillSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.Null, System.Drawing.Color.White, outLineSymbol); var graphic = new Graphic(buffer, null, fillSymbol); myGraphicsOverlay.Graphics.Add(graphic); // フィーチャの検索用のパラメーターを作成 var queryParams = new QueryParameters(); // 検索範囲を作成したバファーの円に指定 queryParams.Geometry = buffer; // 検索範囲とフィーチャの空間的な関係性を指定(バファーの円の中にフィーチャが含まれる) queryParams.SpatialRelationship = SpatialRelationship.Contains; // フィーチャの検索を実行 FeatureQueryResult queryResult = await myFeatureLayer.FeatureTable.QueryFeaturesAsync(queryParams); var alertString = ""; // 検索結果のフィーチャのリストを取得 myFeatures = queryResult.ToList(); // 検索結果のフィーチャを選択(ハイライト表示) myFeatureLayer.SelectFeatures(myFeatures); for (int i = 0; i < myFeatures.Count; ++i) { Feature feature = myFeatures[i]; // フィーチャの"Name"フィールドの属性値を取得 var nameStr = feature.GetAttributeValue("物件名"); alertString = alertString + Environment.NewLine + nameStr; Console.WriteLine(nameStr); } // 取得した属性値をアラート表示 await DisplayAlert("検索結果", alertString, "OK"); } catch (Exception ex) { await DisplayAlert("検索のエラー", ex.ToString(), "OK"); } }
//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); }); } }
private async void OnMapViewTapped(object sender, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs e) { try { IdentifyLayerResult idResult = await MyMapView.IdentifyLayerAsync(relauteFeatureLayer, e.Position, 5, false); ArcGISFeature serviceRequestFeature = idResult.GeoElements.FirstOrDefault() as ArcGISFeature; if (serviceRequestFeature == null) { return; } ArcGISFeatureTable serviceRequestTable = serviceRequestFeature.FeatureTable as ArcGISFeatureTable; IReadOnlyList <ArcGISFeatureTable> relatedTables = serviceRequestTable.GetRelatedTables(); if (relatedTables.Count > 0) { // Get the comments from the relationship results ArcGISFeatureTable relatedComments = relatedTables.FirstOrDefault(); await relatedComments.LoadAsync(); if (relatedComments.LoadStatus == LoadStatus.Loaded) { ArcGISFeature newComment = relatedComments.CreateFeature() as ArcGISFeature; newComment.Attributes["鷗_FLN_TEXT_須"] = "Please show up on time!"; // Relate the selected service request to the new comment serviceRequestFeature.RelateFeature(newComment); /* * var getUpdatedFeature = await relatedComments.GetUpdatedFeaturesAsync(); * ArcGISFeature test = (ArcGISFeature)getUpdatedFeature.FirstOrDefault(); * * await test.LoadAsync(); * test.Attributes["鷗_FLN_TEXT_須"] = "鷗_JPSTRING_須 | 神谷"; * * await relatedComments.UpdateFeatureAsync(test); * serviceRequestFeature.RelateFeature(test); * * ArcGISFeature newComment = relatedComments.CreateFeature() as ArcGISFeature; */ //serviceRequestFeature.RelateFeature(f); } } } catch (Exception ex) { await DisplayAlert("検索のエラー", ex.ToString(), "OK"); } }
private void MyMapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs e) { // Clear any prior incident and routes from the graphics. _incidentGraphicsOverlay.Graphics.Clear(); // Get the tapped point. _incidentPoint = e.Location; // Populate the facility parameters than solve using the task. PopulateParametersAndSolveRouteAsync(); }
private void DoubleTap_ToPlace(object sender, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs e) { if (arSceneView.SetInitialTransformation(e.Position)) { if (arSceneView.Scene == null) { arSceneView.RenderPlanes = false; Status.Text = string.Empty; InitializeScene(); } } }
private void MySceneViewOnGeoViewTapped(object sender, GeoViewInputEventArgs viewInputEventArgs) { // Update the viewshed location. _viewshed.Location = viewInputEventArgs.Location; // Move the location off of the ground. _viewshed.Location = new MapPoint(_viewshed.Location.X, _viewshed.Location.Y, _viewshed.Location.Z + 10.0); // Update the viewpoint symbol. _viewpointOverlay.Graphics.Clear(); _viewpointOverlay.Graphics.Add(new Graphic(_viewshed.Location, _viewpointSymbol)); }
private async void MapView_Tapped(object sender, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs e) { // Handle routing. try { await ProcessRouteRequest(e.Location); } catch (Exception exception) { Console.WriteLine(exception); await Application.Current.MainPage.DisplayAlert("Error", "Couldn't geocode or route.", "OK"); } }
private async void MyMapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs e) { try { // Perform the identify operation IdentifyLayerResult myIdentifyResult = await MyMapView.IdentifyLayerAsync(_wmsLayer, e.Position, 20, false); // Return if there's nothing to show if (myIdentifyResult.SublayerResults[1].GeoElements.Count < 1) { return; } // Retrieve the identified feature, which is always a WmsFeature for WMS layers //WmsFeature identifiedFeature = (WmsFeature)myIdentifyResult.SublayerResults[0].GeoElements[0].Attributes.Values; var identifiedFeature = myIdentifyResult.SublayerResults .Select(x => x.GeoElements.Where(y => y.Attributes.Values.Contains("РГО")).FirstOrDefault().Attributes); var identifiedFeature2 = myIdentifyResult.SublayerResults[1].GeoElements.Where(x => x.Attributes.Count == 17).FirstOrDefault().Attributes; var identifiedFeature3 = myIdentifyResult.SublayerResults.Select(x => x.GeoElements.Where(y => y.Attributes.Count == 17).FirstOrDefault().Attributes); var coordinateX = identifiedFeature2.Where(x => x.Key == "x").FirstOrDefault().Value.ToString(); var coordinateY = identifiedFeature2.Where(x => x.Key == "y").FirstOrDefault().Value.ToString(); var pointNumber = identifiedFeature2.Where(x => x.Key == "geoptnum").FirstOrDefault().Value.ToString(); var clickedPoint = new Point(); clickedPoint.CoordinateX = coordinateX; clickedPoint.CoordinateY = coordinateY; clickedPoint.Number = pointNumber; var StakeOutViewModel = new StakeOutViewModel(clickedPoint); await Navigation.PushAsync(new StakeOutPage(StakeOutViewModel)); // Retrieve the WmsFeature's HTML content // string htmlContent = identifiedFeature/*.Attributes["HTML"].ToString()*/; // Note that the service returns a boilerplate HTML result if there is no feature found. // This test should work for most arcGIS-based WMS services, but results may vary. //if (!htmlContent.Contains("OBJECTID")) { // Return without showing the result //await Navigation.PushAsync(new WmsIdentifyResultDisplayPage(htmlContent) } // Show a page with the HTML content // await Navigation.PushAsync(new WmsIdentifyResultDisplayPage(htmlContent)); } catch (Exception ex) { //await Application.Current.MainPage.DisplayAlert("Error", ex.ToString(), "OK"); } }
private void MyMapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs e) { try { // Create a map point (in the WebMercator projected coordinate system) from the GUI screen coordinate. MapPoint userTappedMapPoint = MyMapView.ScreenToLocation(e.Position); // Get the buffer size from the textbox. double bufferInMiles = System.Convert.ToDouble(BufferDistanceMilesEntry.Text); // Create a variable to be the buffer size in meters. There are 1609.34 meters in one mile. double bufferInMeters = bufferInMiles * 1609.34; // Get a buffered polygon from the GeometryEngine Buffer operation centered on the map point. // Note: The input distance to the Buffer operation is in meters. This matches the backdrop // basemap units which is also meters. Geometry bufferGeometry = GeometryEngine.Buffer(userTappedMapPoint, bufferInMeters); // Create the outline (a simple line symbol) for the buffered polygon. It will be a solid, thick, green line. SimpleLineSymbol bufferSimpleLineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Colors.Green, 5); // Create the color that will be used for the fill of the buffered polygon. It will be a semi-transparent, green color. Colors2 bufferFillColor = Colors2.FromArgb(125, 0, 255, 0); // Create simple fill symbol for the buffered polygon. It will be solid, semi-transparent, green fill with a solid, // thick, green outline. SimpleFillSymbol bufferSimpleFillSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, bufferFillColor, bufferSimpleLineSymbol); // Create a new graphic for the buffered polygon using the defined simple fill symbol. Graphic bufferGraphic = new Graphic(bufferGeometry, bufferSimpleFillSymbol); // Add the buffered polygon graphic to the graphic overlay. _graphicsOverlay.Graphics.Add(bufferGraphic); // Create a simple marker symbol to display where the user tapped/clicked on the map. The marker symbol will be a // solid, red circle. SimpleMarkerSymbol userTappedSimpleMarkerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, Colors.Red, 5); // Create a new graphic for the spot where the user clicked on the map using the simple marker symbol. Graphic userTappedGraphic = new Graphic(userTappedMapPoint, userTappedSimpleMarkerSymbol); // Add the user tapped/clicked map point graphic to the graphic overlay. _graphicsOverlay.Graphics.Add(userTappedGraphic); } catch (System.Exception ex) { // Display an error message if there is a problem generating the buffer polygon. DisplayAlert("Error", "Geometry Engine Failed: " + ex.Message, "OK"); } }
private void MapView_Tapped(object sender, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs e) { // Select the feature if none selected, move the feature otherwise. if (_selectedFeature == null) { // Select the feature. TrySelectFeature(e); } else { // Move the feature. MoveSelectedFeature(e); } }
private async void MyMapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs e) { this.MyMapView.GraphicsOverlays[0].Graphics.Clear(); QueryParameters queryParameters = new QueryParameters(); queryParameters.Geometry = e.Location; string sum = string.Empty; List <CalloutDefinition> calloutDefinitions = new List <CalloutDefinition>(); //List<Feature> features = new List<Feature>(); StringBuilder stringBuilder = new StringBuilder(); this.ViewModel.Fields.Clear(); foreach (var table in this.ViewModel.ServiceFeatureTables) { FeatureTable arcGISFeatureTable = table as FeatureTable; FeatureLayer layer = table.Layer as FeatureLayer; layer.ClearSelection(); if (this.ViewModel.EsriMap.OperationalLayers.Contains(layer)) { string[] outputFields = { "*" }; FeatureQueryResult fqr = await table.QueryFeaturesAsync(queryParameters, QueryFeatureFields.LoadAll); Feature feature = fqr.FirstOrDefault(); if (feature != null) { stringBuilder.Append(feature.Attributes.First().Value + Environment.NewLine); //features.Add(feature); layer.SelectFeature(feature); StringBuilder sb = new StringBuilder(); FeatureTableWrapper wrapper = new FeatureTableWrapper(); wrapper.TableName = layer.FeatureTable.TableName; wrapper.KeyValues = new Dictionary <string, string>(); foreach (var att in feature.Attributes) { if (!wrapper.KeyValues.ContainsKey(att.Key)) { wrapper.KeyValues.Add(att.Key, att.Value.ToString()); } } this.ViewModel.Fields.Add(wrapper); } } } this.MyMapView.GraphicsOverlays[0].Graphics.Add(new Esri.ArcGISRuntime.UI.Graphic(e.Location)); CalloutDefinition callout = new CalloutDefinition(this.ViewModel.GeoviProject.Name, stringBuilder.ToString()); Point point = new Point(e.Location.X, e.Location.Y); this.MyMapView.ShowCalloutAt(e.Location, callout); }
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); } }