void MyMapView_MouseDown(object sender, MouseButtonEventArgs e) { ProjectLocation loc = ProjectListLB.SelectedItem as ProjectLocation; if (loc == null) { return; } int step = StepLB.SelectedIndex; if (step != 1) { return; } Point screenPoint = e.GetPosition(MyMapView); MapPoint coord = MyMapView.ScreenToLocation(screenPoint); _gLayer.Graphics.Clear(); loc.X = coord.X; loc.Y = coord.Y; AddProjectLocationOnMap(loc); }
private async void MyMapView_MouseMove(object sender, System.Windows.Input.MouseEventArgs e) { if (MyMapView != null) { Point screenPoint = e.GetPosition(MyMapView); MapPoint mapPoint = MyMapView.ScreenToLocation(screenPoint); if (mapPoint != null) { // point = GetDesiredElevationLocation(); double result = await sceneSurface.GetElevationAsync(mapPoint); if (MyMapView.IsWrapAroundEnabled) { mapPoint = GeometryEngine.Project(mapPoint, SpatialReferences.Wgs84) as MapPoint; textBox.Text = String.Format("x: {0}, y: {1} | Lat:{2},Lon:{3} | Scale:{4} | Elevation : {5} m", screenPoint.X, screenPoint.Y, Math.Round(mapPoint.Y, 6), Math.Round(mapPoint.X, 6), MyMapView.MapScale, result); } } else { return; } } }
/// <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(); // 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 AddStop(Point tappedPosition) { try { // Get the location on the map. MapPoint tappedLocation = MyMapView.ScreenToLocation(tappedPosition); // Name the stop by its number. string stopName = $"{_stopsOverlay.Graphics.Count + 1}"; // Create a pushpin marker for the stop. PictureMarkerSymbol pushpinMarker = await GetPictureMarker(); // Create the text symbol for labeling the stop. TextSymbol stopSymbol = new TextSymbol(stopName, Color.White, 15, HorizontalAlignment.Center, VerticalAlignment.Middle); stopSymbol.OffsetY = 15; // Create a combined symbol with the pushpin and the label. CompositeSymbol combinedSymbol = new CompositeSymbol(new MarkerSymbol[] { pushpinMarker, stopSymbol }); // Create the graphic from the geometry and the symbology. Graphic newStopGraphic = new Graphic(tappedLocation, combinedSymbol); // Add the stop to the overlay. _stopsOverlay.Graphics.Add(newStopGraphic); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e); ShowMessage("Couldn't add stop", "Couldn't add stop. See debug output for details."); } }
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 void MyMapView_MouseMove(object sender, MouseEventArgs e) { try { // Convert screen point to map point var point = MyMapView.ScreenToLocation(e.GetPosition(MyMapView)); if (point == null) { return; } var buffer = GeometryEngine.GeodesicBuffer( GeometryEngine.NormalizeCentralMeridian(point), //Normalize in case we we're too far west/east of the world bounds 500, LinearUnits.Miles); Graphic bufferGraphic = null; if (_graphicsOverlay.Graphics.Count == 0) { bufferGraphic = new Graphic { Geometry = buffer, Symbol = _bufferSymbol }; _graphicsOverlay.Graphics.Add(bufferGraphic); } else { bufferGraphic = _graphicsOverlay.Graphics[0]; } bufferGraphic.Geometry = buffer; } catch (Exception ex) { MessageBox.Show(ex.Message, "Geometry Engine Failed!"); } }
private void MyMapViewOnGeoViewTapped(object sender, GeoViewInputEventArgs geoViewInputEventArgs) { if (MyMapView != null) { Point screenPoint = geoViewInputEventArgs.Position; MapPoint mapPoint = MyMapView.ScreenToLocation(screenPoint); if (mapPoint != null) { //// point = GetDesiredElevationLocation(); //double result = await Dted1Surface.GetElevationAsync(mapPoint); if (MyMapView.IsWrapAroundEnabled) { mapPoint = GeometryEngine.Project(mapPoint, new SpatialReference(3168)) as MapPoint; } } else { return; } // Get the tapped point, projected to WGS84. MapPoint destination = (MapPoint)GeometryEngine.Project(geoViewInputEventArgs.Location, new SpatialReference(3168)); //// Calculate and show the distance. //double distance = GeometryEngine.LengthGeodetic(pathGeometry, LinearUnits.Kilometers, GeodeticCurveType.Geodesic); graphic1.Geometry = destination; } //} //private void CalculatePointDistance() //{ // SpatialReference equidistantSpatialRef = SpatialReference.Create(3168); // // Project the points from geographic to the projected coordinate system. // MapPoint mapPointProjected1 = GeometryEngine.Project(mapPoint1, equidistantSpatialRef) as MapPoint; // MapPoint mapPointProjected2 = GeometryEngine.Project(mapPoint2, equidistantSpatialRef) as MapPoint; // double planarDistanceMeters = GeometryEngine.Distance(mapPointProjected1, mapPointProjected2); // //textBox.Text = string.Format("{0} Meters", planarDistanceMeters); //} }
private async void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e) { // Convert screen point to map point var mapPoint = MyMapView.ScreenToLocation(e.Position); var layer = MyMapView.Map.Layers["InputLayer"] as GraphicsLayer; layer.Graphics.Clear(); layer.Graphics.Add(new Graphic() { Geometry = mapPoint }); string error = null; Geoprocessor task = new Geoprocessor(new Uri("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Network/ESRI_DriveTime_US/GPServer/CreateDriveTimePolygons")); var parameter = new GPInputParameter(); parameter.GPParameters.Add(new GPFeatureRecordSetLayer("Input_Location", mapPoint)); parameter.GPParameters.Add(new GPString("Drive_Times", "1 2 3")); try { var result = await task.ExecuteAsync(parameter); var r = MyMapView.Map.Layers["ResultLayer"] as GraphicsLayer; r.Graphics.Clear(); foreach (GPParameter gpParameter in result.OutParameters) { if (gpParameter is GPFeatureRecordSetLayer) { GPFeatureRecordSetLayer gpLayer = gpParameter as GPFeatureRecordSetLayer; List <Esri.ArcGISRuntime.Symbology.Symbol> bufferSymbols = new List <Esri.ArcGISRuntime.Symbology.Symbol>( new Esri.ArcGISRuntime.Symbology.Symbol[] { LayoutRoot.Resources["FillSymbol1"] as Esri.ArcGISRuntime.Symbology.Symbol, LayoutRoot.Resources["FillSymbol2"] as Esri.ArcGISRuntime.Symbology.Symbol, LayoutRoot.Resources["FillSymbol3"] as Esri.ArcGISRuntime.Symbology.Symbol }); int count = 0; foreach (Graphic graphic in gpLayer.FeatureSet.Features) { graphic.Symbol = bufferSymbols[count]; graphic.Attributes.Add("Info", String.Format("{0} minute buffer ", 3 - count)); r.Graphics.Add(graphic); count++; } } } } catch (Exception ex) { error = "Geoprocessor service failed: " + ex.Message; } if (error != null) { await new MessageDialog(error).ShowAsync(); } }
/// <summary> /// Identifies feature to highlight. /// </summary> private async void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e) { // Ignore tap events while in edit mode so we do not interfere with edit geometry. var inEditMode = EditButton.IsEnabled; if (inEditMode) { return; } // Get current viewpoints extent from the MapView var currentViewpoint = MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry); var viewpointExtent = currentViewpoint.TargetGeometry.Extent; var layer = MyMapView.Map.Layers["RecreationalArea"] as ArcGISDynamicMapServiceLayer; var task = new IdentifyTask(new Uri(layer.ServiceUri)); var mapPoint = MyMapView.ScreenToLocation(e.Position); var parameter = new IdentifyParameters(mapPoint, viewpointExtent, 2, (int)MyMapView.ActualHeight, (int)MyMapView.ActualWidth); // Clears map of any highlights. var overlay = MyMapView.GraphicsOverlays["Highlighter"] as GraphicsOverlay; overlay.Graphics.Clear(); SetGeometryEditor(); string message = null; try { // Performs an identify and adds feature result as selected into overlay. var result = await task.ExecuteAsync(parameter); if (result == null || result.Results == null || result.Results.Count < 1) { return; } var graphic = (Graphic)result.Results[0].Feature; graphic.IsSelected = true; overlay.Graphics.Add(graphic); // Prepares geometry editor. var featureID = Convert.ToInt64(graphic.Attributes["Objectid"], CultureInfo.InvariantCulture); SetGeometryEditor(featureID); } catch (Exception ex) { message = ex.Message; } if (!string.IsNullOrWhiteSpace(message)) { await new MessageDialog(message).ShowAsync(); } }
/// <summary> /// Identifies graphic to highlight and query its related records. /// </summary> private async void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e) { var layer = MyMapView.Map.Layers["ServiceRequests"] as ArcGISDynamicMapServiceLayer; var task = new IdentifyTask(new Uri(layer.ServiceUri)); var mapPoint = MyMapView.ScreenToLocation(e.Position); // Get current viewpoints extent from the MapView var currentViewpoint = MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry); var viewpointExtent = currentViewpoint.TargetGeometry.Extent; var parameter = new IdentifyParameters(mapPoint, viewpointExtent, 5, (int)MyMapView.ActualHeight, (int)MyMapView.ActualWidth); // Clears map of any highlights. var overlay = MyMapView.GraphicsOverlays["Highlighter"] as GraphicsOverlay; overlay.Graphics.Clear(); SetRelatedRecordEditor(); string message = null; try { // Performs an identify and adds graphic result into overlay. var result = await task.ExecuteAsync(parameter); if (result == null || result.Results == null || result.Results.Count < 1) { return; } var graphic = (Graphic)result.Results[0].Feature; overlay.Graphics.Add(graphic); // Prepares related records editor. var featureID = Convert.ToInt64(graphic.Attributes["OBJECTID"], CultureInfo.InvariantCulture); string requestID = null; if (graphic.Attributes["Service Request ID"] != null) { requestID = Convert.ToString(graphic.Attributes["Service Request ID"], CultureInfo.InvariantCulture); } SetRelatedRecordEditor(featureID, requestID); await QueryRelatedRecordsAsync(); } catch (Exception ex) { message = ex.Message; } if (!string.IsNullOrWhiteSpace(message)) { MessageBox.Show(message); } }
private async void MyMapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.UI.Controls.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(BufferDistanceMilesTextBox.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, Windows.UI.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. Windows.UI.Color bufferFillColor = Windows.UI.Color.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, Windows.UI.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. MessageDialog theMessageDialog = new MessageDialog("Geometry Engine Failed: " + ex.Message); await theMessageDialog.ShowAsync(); } }
/// <summary> /// Identifies feature to highlight. /// </summary> private async void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e) { var layer = MyMapView.Map.Layers["PoolPermit"] as ArcGISDynamicMapServiceLayer; var task = new IdentifyTask(new Uri(layer.ServiceUri)); var mapPoint = MyMapView.ScreenToLocation(e.Position); // Get current viewpoints extent from the MapView var currentViewpoint = MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry); var viewpointExtent = currentViewpoint.TargetGeometry.Extent; var parameter = new IdentifyParameters(mapPoint, viewpointExtent, 2, (int)MyMapView.ActualHeight, (int)MyMapView.ActualWidth); // Clears map of any highlights. var overlay = MyMapView.GraphicsOverlays["Highlighter"] as GraphicsOverlay; overlay.Graphics.Clear(); SetAttributeEditor(); string message = null; try { // Performs an identify and adds feature result as selected into overlay. var result = await task.ExecuteAsync(parameter); if (result == null || result.Results == null || result.Results.Count < 1) { return; } var graphic = (Graphic)result.Results[0].Feature; graphic.IsSelected = true; overlay.Graphics.Add(graphic); // Prepares attribute editor. var featureID = Convert.ToInt64(graphic.Attributes["OBJECTID"], CultureInfo.InvariantCulture); var hasPool = Convert.ToString(graphic.Attributes["Has_Pool"], CultureInfo.InvariantCulture); if (choices == null) { choices = await GetChoicesAsync(); } SetAttributeEditor(featureID, hasPool); } catch (Exception ex) { message = ex.Message; } if (!string.IsNullOrWhiteSpace(message)) { await new MessageDialog(message).ShowAsync(); } }
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(); } }
/// <summary> /// Identifies feature to highlight. /// </summary> private async void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e) { // Ignore tap events while in edit mode so we do not interfere with edit geometry. if (MyMapView.Editor.IsActive) { return; } var layer = MyMapView.Map.Layers["WildFire"] as ArcGISDynamicMapServiceLayer; var task = new IdentifyTask(new Uri(layer.ServiceUri)); var mapPoint = MyMapView.ScreenToLocation(e.Position); var parameter = new IdentifyParameters(mapPoint, MyMapView.Extent, 2, (int)MyMapView.ActualHeight, (int)MyMapView.ActualWidth); // Clears map of any highlights. var overlay = MyMapView.GraphicsOverlays["Highlighter"] as GraphicsOverlay; overlay.Graphics.Clear(); SetGeometryEditor(); string message = null; try { // Performs an identify and adds feature result as selected into overlay. var result = await task.ExecuteAsync(parameter); if (result == null || result.Results == null || result.Results.Count < 1) { return; } var graphic = (Graphic)result.Results[0].Feature; graphic.IsSelected = true; overlay.Graphics.Add(graphic); // Prepares geometry editor. var featureID = Convert.ToInt64(graphic.Attributes["OBJECTID"], CultureInfo.InvariantCulture); SetGeometryEditor(featureID); } catch (Exception ex) { message = ex.Message; } if (!string.IsNullOrWhiteSpace(message)) { MessageBox.Show(message); } }
private MapPoint[] GenerateRandomPoints(int numberOfPoints) { List <MapPoint> mapPoints = new List <MapPoint>(); int xmax = (int)MyMapView.ActualWidth; int ymax = (int)MyMapView.ActualHeight; Random random = new Random(); for (int i = 0; i < numberOfPoints; i++) { mapPoints.Add(MyMapView.ScreenToLocation(new Point(random.Next(0, xmax), random.Next(0, ymax)))); } return(mapPoints.ToArray()); }
public async Task CreatePictureBorder(GraphicsOverlay overlay, Uri _uri) { var resourceStream = GetStreamFromUrl(_uri.ToString()); CreateBitMap_FromUri(_uri); ImageWorks = new ImageWork(MainViewModel.SelectedPlace_Bitmap, MainViewModel.Scale, Math.Abs(MainViewModel._BorderValue)); byte[] border_Img = await ImageWorks.CreateImg(); PictureMarkerSymbol pinSymbol = new PictureMarkerSymbol(new RuntimeImage(border_Img)); pinSymbol.Width = MainViewModel.MyWindow.GridMap.ActualWidth; pinSymbol.Height = MainViewModel.MyWindow.GridMap.ActualHeight; MapPoint pinPoint = MyMapView.ScreenToLocation(ImageWorks.CenterPlace); Graphic pinGraphic = new Graphic(pinPoint, pinSymbol); overlay.Graphics.Add(pinGraphic); overlay.Graphics[1].ZIndex = 1; overlay.Opacity = 0.5; }
MapPoint screenPoint2MapPoint(Point screenPoint) { MapPoint mapPoint = MyMapView.ScreenToLocation(screenPoint); if (mapPoint == null) { return(null); } if (MyMapView.WrapAround) { mapPoint = GeometryEngine.NormalizeCentralMeridian(mapPoint) as MapPoint; } if (_srEMap != null) { // transform the map point to user defined spatial reference coordinate system Esri.ArcGISRuntime.Geometry.Geometry g = GeometryEngine.Project(mapPoint, _srEMap); mapPoint = g as MapPoint; } return(mapPoint); }
private void MyMapView_PointerMoved(object sender, PointerRoutedEventArgs e) { if (MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry) == null) { return; } var pointerPoint = e.GetCurrentPoint(MyMapView); var position = pointerPoint.Position; MapPoint location = null; if (!pointerPoint.IsInContact) { location = MyMapView.ScreenToLocation(position); } UpdateDisplayPoints(position, location); }
private void MyMapView_MouseMove(object sender, MouseEventArgs e) { if (MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry) == null) { return; } System.Windows.Point screenPoint = e.GetPosition(MyMapView); ScreenCoordsTextBlock.Text = string.Format("Screen Coords: X = {0}, Y = {1}", screenPoint.X, screenPoint.Y); MapPoint mapPoint = MyMapView.ScreenToLocation(screenPoint); if (MyMapView.WrapAround) { mapPoint = GeometryEngine.NormalizeCentralMeridian(mapPoint) as MapPoint; } MapCoordsTextBlock.Text = string.Format("Map Coords: X = {0}, Y = {1}", Math.Round(mapPoint.X, 4), Math.Round(mapPoint.Y, 4)); }
private async void MyMapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.UI.Controls.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 (in miles) from the text box. double bufferDistanceInMiles = System.Convert.ToDouble(BufferDistanceMilesTextBox.Text); // Create a variable to be the buffer size in meters. There are 1609.34 meters in one mile. double bufferDistanceInMeters = bufferDistanceInMiles * 1609.34; // Add the map point to the list that will be used by the GeometryEngine.Buffer operation. _bufferPointsList.Add(userTappedMapPoint); // Add the buffer distance to the list that will be used by the GeometryEngine.Buffer operation. _bufferDistancesList.Add(bufferDistanceInMeters); // 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, Windows.UI.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); // Specify a ZIndex value on the user input map point graphic to assist with the drawing order of mixed geometry types // being added to a single GraphicCollection. The lower the ZIndex value, the lower in the visual stack the graphic is // drawn. Typically, Polygons would have the lowest ZIndex value (ex: 0), then Polylines (ex: 1), and finally MapPoints (ex: 2). userTappedGraphic.ZIndex = 2; // Add the user tapped/clicked map point graphic to the graphic overlay. _graphicsOverlay.Graphics.Add(userTappedGraphic); } catch (System.Exception ex) { // Display an error message. MessageDialog theMessageDialog = new MessageDialog("Error creating list of map points for buffer: " + ex.Message); await theMessageDialog.ShowAsync(); } }
private List <Place> ReseachImage() { List <Place> ls = new List <Place>(); DatePoint BlackPoint = ImageWorks.FindBlackPoint(GrayImagePKKwithBorder); while (BlackPoint._x != -1) { var location = MyMapView.ScreenToLocation(new Point(BlackPoint._x, BlackPoint._y)); var coord = CoordinateFormatter.ToLatitudeLongitude(location, LatitudeLongitudeFormat.DecimalDegrees, 6); var _placeCoord = GetPlaceProp.GetPlaceCoordMethod(coord.Substring(0, 9), coord.Substring(12, 9)); int cnt = _placeCoord.Features[0].Attrs.Cn.Count(c => c == ':'); if (_placeCoord.Features[0].Attrs.Address != null) { var place1 = GetPlaceProp.Get_Place(_placeCoord.Features[0].Attrs.Id); ls.Add(place1); } LineFill(BlackPoint._x, BlackPoint._y); BlackPoint = ImageWorks.FindBlackPoint(GrayImagePKKwithBorder); } ls = ls.GroupBy(s => s.Feature.Attrs.Cn).Select(g => g.First()).ToList(); return(ls); }
private void MapView_PointerMoved(object sender, PointerRoutedEventArgs e) { if (_selectedStopGraphic != null) { // Get the position of the mouse relative to the map view. var hoverPoint = e.GetCurrentPoint(MyMapView); // Get the physical map location corresponding to the mouse position. MapPoint hoverLocation = MyMapView.ScreenToLocation(hoverPoint.Position); // Return if the location is outside the routable area. if (!GeometryEngine.Contains(_routableArea, hoverLocation)) { return; } // Update the location of the stop graphic. _selectedStopGraphic.Geometry = hoverLocation; // Update the route with the temporary stop. UpdateRoute((TravelMode)TravelModesCombo.SelectedItem ?? _availableTravelModes.First()); } }
private async void IdentifyCell(Point position) { // Check if a cell is already being identified if (_isIdentifying) { _nextIdentifyAction = () => IdentifyCell(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. 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) { 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(); } }