本文整理汇总了C#中MapViewInputEventArgs类的典型用法代码示例。如果您正苦于以下问题:C# MapViewInputEventArgs类的具体用法?C# MapViewInputEventArgs怎么用?C# MapViewInputEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MapViewInputEventArgs类属于命名空间,在下文中一共展示了MapViewInputEventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MyMapView_MapViewTapped
// Identify features at the click point
private async void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e)
{
try
{
progress.Visibility = Visibility.Visible;
resultsGrid.DataContext = null;
GraphicsOverlay graphicsOverlay = MyMapView.GraphicsOverlays["graphicsOverlay"];
graphicsOverlay.Graphics.Clear();
graphicsOverlay.Graphics.Add(new Graphic(e.Location));
IdentifyParameters identifyParams = new IdentifyParameters(e.Location, MyMapView.Extent, 2, (int)MyMapView.ActualHeight, (int)MyMapView.ActualWidth)
{
LayerOption = LayerOption.Visible,
SpatialReference = MyMapView.SpatialReference,
};
IdentifyTask identifyTask = new IdentifyTask(
new Uri("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer"));
var result = await identifyTask.ExecuteAsync(identifyParams);
resultsGrid.DataContext = result.Results;
if (result != null && result.Results != null && result.Results.Count > 0)
titleComboBox.SelectedIndex = 0;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Identify Sample");
}
finally
{
progress.Visibility = Visibility.Collapsed;
}
}
示例2: mapView1_Tap
// Perform identify when the map is tapped
private async void mapView1_Tap(object sender, MapViewInputEventArgs e)
{
if (m_mapView == null)
m_mapView = (MapView)sender;
// Clear any previously displayed results
clearResults();
// Get the point that was tapped and show it on the map
GraphicsLayer identifyPointLayer = m_mapView.Map.Layers["IdentifyPointLayer"] as GraphicsLayer;
identifyPointLayer.Graphics.Add(new Graphic() { Geometry = e.Location });
// Show activity
progress.Visibility = Visibility.Visible;
// Perform the identify operation
List<DataItem> results = await doIdentifyAsync(e.Location);
// Hide the activity indicator
progress.Visibility = Visibility.Collapsed;
// Show the results
ResultsListPicker.ItemsSource = results;
if (results.Count > 0)
{
ResultsListPicker.Visibility = Visibility.Visible;
ShowAttributesButton.Visibility = Visibility.Visible;
}
}
示例3: MyMapView_MapViewTapped
// Select a set of wells near the click point
private async void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e)
{
try
{
_wellsOverlay.Graphics.Clear();
wellsGrid.ItemsSource = relationshipsGrid.ItemsSource = null;
QueryTask queryTask =
new QueryTask(new Uri("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Petroleum/KSPetro/MapServer/0"));
// Get current viewpoints extent from the MapView
var currentViewpoint = MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry);
var viewpointExtent = currentViewpoint.TargetGeometry.Extent;
Query query = new Query("1=1")
{
Geometry = Expand(viewpointExtent, e.Location, 0.01),
ReturnGeometry = true,
OutSpatialReference = MyMapView.SpatialReference,
OutFields = OutFields.All
};
var result = await queryTask.ExecuteAsync(query);
if (result.FeatureSet.Features != null && result.FeatureSet.Features.Count > 0)
{
_wellsOverlay.Graphics.AddRange(result.FeatureSet.Features.OfType<Graphic>());
wellsGrid.ItemsSource = result.FeatureSet.Features;
resultsPanel.Visibility = Visibility.Visible;
}
}
catch (Exception ex)
{
var _x = new MessageDialog(ex.Message, "Sample Error").ShowAsync();
}
}
示例4: MyMapView_MapViewTapped
// Use geoprocessor to call drive times gp service and display results
private async void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e)
{
try
{
progress.Visibility = Visibility.Visible;
_inputOverlay.Graphics.Clear();
_inputOverlay.Graphics.Add(new Graphic(e.Location));
var parameter = new GPInputParameter();
parameter.GPParameters.Add(new GPFeatureRecordSetLayer("Input_Location", e.Location));
parameter.GPParameters.Add(new GPString("Drive_Times", "1 2 3"));
var result = await _gpTask.ExecuteAsync(parameter);
var features = result.OutParameters.OfType<GPFeatureRecordSetLayer>().First().FeatureSet.Features;
_resultsOverlay.Graphics.Clear();
_resultsOverlay.Graphics.AddRange(features.Select((fs, idx) => new Graphic(fs.Geometry, _bufferSymbols[idx])));
}
catch (Exception ex)
{
var _x = new MessageDialog(ex.Message, "Sample Error").ShowAsync();
}
finally
{
progress.Visibility = Visibility.Collapsed;
}
}
示例5: mapView1_MapViewTapped
void mapView1_MapViewTapped(object sender, MapViewInputEventArgs e)
{
graphicsLayer.Graphics.Clear();
try
{
var pointGeom = e.Location;
var bufferGeom = GeometryEngine.Buffer(pointGeom, 5 * milesToMetersConversion);
//show geometries on map
if (graphicsLayer != null)
{
var pointGraphic = new Graphic { Geometry = pointGeom, Symbol = pms };
graphicsLayer.Graphics.Add(pointGraphic);
var bufferGraphic = new Graphic { Geometry = bufferGeom, Symbol = sfs };
graphicsLayer.Graphics.Add(bufferGraphic);
}
}
catch (Exception ex)
{
var dlg = new MessageDialog(ex.Message, "Geometry Engine Failed!");
var _ = dlg.ShowAsync();
}
}
示例6: MyMapView_MapViewTapped
// Get user Stop points
private void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e)
{
if (!_isMapReady)
return;
try
{
e.Handled = true;
if (_directionsOverlay.Graphics.Count() > 0)
{
panelResults.Visibility = Visibility.Collapsed;
_stopsOverlay.Graphics.Clear();
_routesOverlay.Graphics.Clear();
_directionsOverlay.GraphicsSource = null;
}
_stopsOverlay.Graphics.Add(new Graphic(e.Location));
}
catch (System.Exception ex)
{
var _x = new MessageDialog(ex.Message, "Sample Error").ShowAsync();
}
}
示例7: mapView_MapViewTapped
private async void mapView_MapViewTapped(object sender, MapViewInputEventArgs e)
{
try
{
incidentOverlay.Visibility = Visibility.Collapsed;
incidentOverlay.DataContext = null;
var identifyTask = new IdentifyTask(new Uri(_trafficLayer.ServiceUri));
IdentifyParameter identifyParams = new IdentifyParameter(e.Location, mapView.Extent, 5, (int)mapView.ActualHeight, (int)mapView.ActualWidth)
{
LayerIDs = new int[] { 2, 3, 4 },
LayerOption = LayerOption.Top,
SpatialReference = mapView.SpatialReference,
};
var result = await identifyTask.ExecuteAsync(identifyParams);
if (result != null && result.Results != null && result.Results.Count > 0)
{
incidentOverlay.DataContext = result.Results.First();
incidentOverlay.Visibility = Visibility.Visible;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Identify Error");
}
}
示例8: MyMapView_MapViewTapped
/// <summary>
/// Selects feature for editing.
/// </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["Incidents"] as FeatureLayer;
layer.ClearSelection();
SetGeometryEditor();
string message = null;
try
{
// Performs hit test on layer to select feature.
var features = await layer.HitTestAsync(MyMapView, e.Position);
if (features == null || !features.Any())
return;
var featureID = features.FirstOrDefault();
layer.SelectFeatures(new long[] { featureID });
var feature = await layer.FeatureTable.QueryAsync(featureID);
SetGeometryEditor(feature);
}
catch (Exception ex)
{
message = ex.Message;
}
if (!string.IsNullOrWhiteSpace(message))
MessageBox.Show(message);
}
开发者ID:jordanparfitt,项目名称:arcgis-runtime-samples-dotnet,代码行数:30,代码来源:FeatureLayerEditGeometry.xaml.cs
示例9: mapView_MapViewTapped
// Select a set of wells near the click point
private async void mapView_MapViewTapped(object sender, MapViewInputEventArgs e)
{
try
{
_wellsLayer.Graphics.Clear();
wellsGrid.ItemsSource = relationshipsGrid.ItemsSource = null;
QueryTask queryTask =
new QueryTask(new Uri("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Petroleum/KSPetro/MapServer/0"));
Query query = new Query("1=1")
{
Geometry = Expand(mapView.Extent, e.Location, 0.01),
ReturnGeometry = true,
OutSpatialReference = mapView.SpatialReference,
OutFields = OutFields.All
};
var result = await queryTask.ExecuteAsync(query);
if (result.FeatureSet.Features != null && result.FeatureSet.Features.Count > 0)
{
_wellsLayer.Graphics.AddRange(result.FeatureSet.Features);
wellsGrid.ItemsSource = result.FeatureSet.Features;
resultsPanel.Visibility = Visibility.Visible;
}
}
catch (Exception ex)
{
var _ = new MessageDialog(ex.Message, "Sample Error").ShowAsync();
}
}
示例10: mapView_MapViewTapped
// Get user Stop points
private void mapView_MapViewTapped(object sender, MapViewInputEventArgs e)
{
if (!_isMapReady)
return;
try
{
e.Handled = true;
if (directionsLayer.Graphics.Count() > 0)
{
panelResults.Visibility = Visibility.Collapsed;
stopsLayer.Graphics.Clear();
routesLayer.Graphics.Clear();
directionsLayer.GraphicsSource = null;
}
stopsLayer.Graphics.Add(new Graphic(e.Location));
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "Sample Error");
}
}
示例11: mapView1_Tap
// On tap, either get related records for the tapped well or find nearby wells if no well was tapped
private async void mapView1_Tap(object sender, MapViewInputEventArgs e)
{
// Show busy UI
BusyVisibility = Visibility.Visible;
// Get the map
if (m_mapView == null)
m_mapView = (MapView)sender;
// Create graphic and add to tap points
var g = new Graphic() { Geometry = e.Location };
TapPoints.Add(g);
// Buffer graphic by 100 meters, create graphic with buffer, add to buffers
var buffer = GeometryEngine.Buffer(g.Geometry, 100);
Buffers.Add(new Graphic() { Geometry = buffer });
// Find intersecting parcels and show them on the map
var result = await doQuery(buffer);
if (result != null && result.FeatureSet != null && result.FeatureSet.Features.Count > 0)
{
// Instead of adding parcels one-by-one, update the Parcels collection all at once to
// allow the map to render the new features in one rendering pass.
Parcels = new ObservableCollection<Graphic>(Parcels.Union(result.FeatureSet.Features));
}
// Hide busy UI
BusyVisibility = Visibility.Collapsed;
}
示例12: mapView_MapViewTapped
private void mapView_MapViewTapped(object sender, MapViewInputEventArgs e)
{
try
{
graphicsLayer.Graphics.Clear();
// Convert screen point to map point
var point = e.Location;
var buffer = GeometryEngine.Buffer(point, 5 * MILES_TO_METERS);
//show geometries on map
if (graphicsLayer != null)
{
var pointGraphic = new Graphic { Geometry = point, Symbol = _pinSymbol };
graphicsLayer.Graphics.Add(pointGraphic);
var bufferGraphic = new Graphic { Geometry = buffer, Symbol = _bufferSymbol };
graphicsLayer.Graphics.Add(bufferGraphic);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Geometry Engine Failed!");
}
}
示例13: MyMapView_MapViewTapped
private async void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e)
{
try
{
_trafficOverlay.Visibility = Visibility.Collapsed;
_trafficOverlay.DataContext = null;
var identifyTask = new IdentifyTask(new Uri(_trafficLayer.ServiceUri));
// Get current viewpoints extent from the MapView
var currentViewpoint = MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry);
var viewpointExtent = currentViewpoint.TargetGeometry.Extent;
IdentifyParameters identifyParams = new IdentifyParameters(e.Location, viewpointExtent, 5, (int)MyMapView.ActualHeight, (int)MyMapView.ActualWidth)
{
LayerIDs = new int[] { 2, 3, 4 },
LayerOption = LayerOption.Top,
SpatialReference = MyMapView.SpatialReference,
};
var result = await identifyTask.ExecuteAsync(identifyParams);
if (result != null && result.Results != null && result.Results.Count > 0)
{
_trafficOverlay.DataContext = result.Results.First();
_trafficOverlay.Visibility = Visibility.Visible;
}
}
catch (Exception ex)
{
var _x = new MessageDialog(ex.Message, "Sample Error").ShowAsync();
}
}
示例14: mapView1_Tap
private void mapView1_Tap(object sender, MapViewInputEventArgs e)
{
// Create graphic
Graphic g = new Graphic() { Geometry = e.Location };
// Get layer and add point to it
mapview1.Map.Layers.OfType<GraphicsLayer>().First().Graphics.Add(g);
}
示例15: MyMapView_MapViewTapped
// Use geoprocessor to call drive times gp service and display results
private async void MyMapView_MapViewTapped(object sender, MapViewInputEventArgs e)
{
try
{
progress.Visibility = Visibility.Visible;
// If the _gpTask has completed successfully (or before it is run the first time), the _cancellationTokenSource is set to null.
// If it has not completed and the map is clicked/tapped again, set the _cancellationTokenSource to cancel the initial task.
if (_cancellationTokenSource != null)
{
_cancellationTokenSource.Cancel(); // Cancel previous operation
}
_cancellationTokenSource = new CancellationTokenSource();
_inputOverlay.Graphics.Clear();
_resultsOverlay.Graphics.Clear();
_inputOverlay.Graphics.Add(new Graphic(e.Location));
var parameter = new GPInputParameter();
parameter.GPParameters.Add(new GPFeatureRecordSetLayer("Input_Location", e.Location));
parameter.GPParameters.Add(new GPString("Drive_Times", "1 2 3"));
var result = await _gpTask.ExecuteAsync(parameter, _cancellationTokenSource.Token);
_cancellationTokenSource = null; // null out to show there are no pending operations
if (result != null)
{
var features = result.OutParameters.OfType<GPFeatureRecordSetLayer>().First().FeatureSet.Features;
_resultsOverlay.Graphics.AddRange(features.Select((fs, idx) => new Graphic(fs.Geometry, _bufferSymbols[idx])));
}
}
catch (OperationCanceledException)
{
// Catch this exception because it is expected (when task cancellation is successful).
// Catching it here prevents the message from being propagated to a MessageBox.
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Sample Error");
}
finally
{
progress.Visibility = Visibility.Collapsed;
}
}