private void mapView_MapClick(object sender, MapClickMapViewEventArgs e) { FeatureLayer worldLayer = mapView.FindFeatureLayer("WorldLayer"); worldLayer.Open(); Collection <Feature> selectedFeatures = worldLayer.QueryTools.GetFeaturesContaining(e.WorldLocation, new string[2] { "CNTRY_NAME", "POP_CNTRY" }); worldLayer.Close(); if (selectedFeatures.Count > 0) { StringBuilder info = new StringBuilder(); info.AppendLine(String.Format(CultureInfo.InvariantCulture, "CNTRY_NAME:\t{0}", selectedFeatures[0].ColumnValues["CNTRY_NAME"])); info.AppendLine(String.Format(CultureInfo.InvariantCulture, "POP_CNTRY:\t{0}", double.Parse(selectedFeatures[0].ColumnValues["POP_CNTRY"]).ToString("n0"))); TBInfo.Text = info.ToString(); PopupOverlay popupOverlay = (PopupOverlay)mapView.Overlays["PopupOverlay"]; Popup popup = new Popup(e.WorldLocation); popup.Content = info.ToString(); popup.FontSize = 10d; popup.FontFamily = new System.Windows.Media.FontFamily("Verdana"); popupOverlay.Popups.Clear(); popupOverlay.Popups.Add(popup); popupOverlay.Refresh(); } }
private void mapView_MapClick(object sender, MapClickMapViewEventArgs e) { LayerOverlay layerOverlay = (LayerOverlay)mapView.Overlays["layerOverlay"]; ShapeFileFeatureLayer friscoParks = (ShapeFileFeatureLayer)layerOverlay.Layers["friscoParks"]; InMemoryFeatureLayer stadiumLayer = (InMemoryFeatureLayer)layerOverlay.Layers["stadiumLayer"]; InMemoryFeatureLayer shortestLineLayer = (InMemoryFeatureLayer)layerOverlay.Layers["shortestLineLayer"]; // Query the friscoParks layer to get the first feature closest to the map click event var park = friscoParks.QueryTools.GetFeaturesNearestTo(e.WorldLocation, GeographyUnit.Meter, 1, ReturningColumnsType.NoColumns).First(); // Get the stadium feature from the stadiumLayer var stadium = stadiumLayer.InternalFeatures[0]; // Get the shortest line from the selected park to the stadium var shortestLine = park.GetShape().GetShortestLineTo(stadium, GeographyUnit.Meter); // Show the shortestLine on the map shortestLineLayer.InternalFeatures.Clear(); shortestLineLayer.InternalFeatures.Add(new Feature(shortestLine)); layerOverlay.Refresh(); // Get the area of the first feature var length = shortestLine.GetLength(GeographyUnit.Meter, DistanceUnit.Kilometer); // Display the shortestLine's length in the distanceResult TextBox distanceResult.Text = $"{length:f3} km"; }
private void mapView_MapClick(object sender, MapClickMapViewEventArgs e) { LayerOverlay worldOverlay = (LayerOverlay)mapView.Overlays["WorldOverlay"]; FeatureLayer worldLayer = (FeatureLayer)worldOverlay.Layers["WorldLayer"]; LayerOverlay highlightOverlay = (LayerOverlay)mapView.Overlays["HighlightOverlay"]; InMemoryFeatureLayer highlightLayer = (InMemoryFeatureLayer)highlightOverlay.Layers["HighlightLayer"]; worldLayer.Open(); Collection <Feature> selectedFeatures = worldLayer.QueryTools.GetFeaturesContaining(e.WorldLocation, new string[1] { "CNTRY_NAME" }); worldLayer.Close(); highlightLayer.Open(); highlightLayer.InternalFeatures.Clear(); if (selectedFeatures.Count > 0) { highlightLayer.InternalFeatures.Add(selectedFeatures[0]); } highlightLayer.Close(); // Call Refresh method to refresh the highlightOverlay only highlightOverlay.Refresh(); }
private void mapView_MapClick(object sender, MapClickMapViewEventArgs e) { FeatureLayer worldLayer = mapView.FindFeatureLayer("WorldLayer"); // Find the country the user clicked on. worldLayer.Open(); Collection <Feature> selectedFeatures = worldLayer.QueryTools.GetFeaturesContaining(e.WorldLocation, new string[1] { "CNTRY_NAME" }); worldLayer.Close(); // Determine the area of the country. if (selectedFeatures.Count > 0) { ProjectionConverter project = new ProjectionConverter(3857, 4326); project.Open(); AreaBaseShape areaShape = (AreaBaseShape)project.ConvertToExternalProjection(selectedFeatures[0].GetShape()); project.Close(); double area = areaShape.GetArea(GeographyUnit.DecimalDegree, AreaUnit.SquareKilometers); string areaMessage = string.Format(CultureInfo.InvariantCulture, "{0} has an area of \r{1:N0} square kilometers.", selectedFeatures[0].ColumnValues["CNTRY_NAME"].Trim(), area); Popup popup = new Popup(e.WorldLocation); popup.Content = areaMessage; PopupOverlay popupOverlay = (PopupOverlay)mapView.Overlays["PopupOverlay"]; popupOverlay.Popups.Clear(); popupOverlay.Popups.Add(popup); popupOverlay.Refresh(); } }
private void Map1_MapClick(object sender, MapClickMapViewEventArgs e) { // Here we loop through all of the PrinterLayers to find the one the user right mouse clicked on. // Then we show the right click menu to give the user some options if (e.MouseButton == MapMouseButton.Right) { ((MenuItem)Map1.ContextMenu.Items[0]).IsEnabled = false; ((MenuItem)Map1.ContextMenu.Items[1]).IsEnabled = false; PrinterInteractiveOverlay printerOverlay = (PrinterInteractiveOverlay)Map1.InteractiveOverlays["PrintPreviewOverlay"]; for (int i = printerOverlay.PrinterLayers.Count - 1; i >= 0; i--) { if (printerOverlay.PrinterLayers[i].GetType() != typeof(PagePrinterLayer)) { RectangleShape boundingBox = printerOverlay.PrinterLayers[i].GetPosition(); if (boundingBox.Contains(e.WorldLocation)) { ((MenuItem)Map1.ContextMenu.Items[0]).Tag = printerOverlay.PrinterLayers[i]; ((MenuItem)Map1.ContextMenu.Items[0]).IsEnabled = true; ((MenuItem)Map1.ContextMenu.Items[1]).Tag = printerOverlay.PrinterLayers[i]; ((MenuItem)Map1.ContextMenu.Items[1]).IsEnabled = true; break; } } } } }
private void mapView_MapClick(object sender, MapClickMapViewEventArgs e) { ProjectionConverter project = new ProjectionConverter(3857, 4326); project.Open(); var worldPointInDecimalDegree = project.ConvertToExternalProjection(e.WorldX, e.WorldY); TBLonLat.Text = string.Format(CultureInfo.InvariantCulture, "X={0}, Y={1}", worldPointInDecimalDegree.X.ToString("N4", CultureInfo.InvariantCulture), worldPointInDecimalDegree.Y.ToString("N4", CultureInfo.InvariantCulture)); project.Close(); }
private void mapView_MapClick(object sender, MapClickMapViewEventArgs e) { // Get the selected feature based on the map click location Collection <Feature> selectedFeatures = GetFeaturesFromLocation(e.WorldLocation); // If a feature was selected, get the data from it and display it if (selectedFeatures != null) { DisplayFeatureInfo(selectedFeatures); } }
/// <summary> /// Map event that fires whenever the user clicks on the map. Gets the closest feature from the click event and calculates the center point /// </summary> private void mapView_MapClick(object sender, MapClickMapViewEventArgs e) { LayerOverlay layerOverlay = (LayerOverlay)mapView.Overlays["layerOverlay"]; ShapeFileFeatureLayer censusHousing = (ShapeFileFeatureLayer)layerOverlay.Layers["censusHousing"]; // Query the censusHousing layer to get the first feature closest to the map click event var feature = censusHousing.QueryTools.GetFeaturesNearestTo(e.WorldLocation, GeographyUnit.Meter, 1, ReturningColumnsType.NoColumns).First(); CalculateCenterPoint(feature); }
private void mapView_MapClick(object sender, MapClickMapViewEventArgs e) { screenPosition.Text = "(" + e.ScreenX + ", " + e.ScreenY + ")"; ProjectionConverter project = new ProjectionConverter(3857, 4326); project.Open(); var worldPointInDecimalDegree = project.ConvertToExternalProjection(e.WorldX, e.WorldY); worldPosition.Text = string.Format(CultureInfo.InvariantCulture, "({0}, {1})", worldPointInDecimalDegree.X.ToString("N4", CultureInfo.InvariantCulture), worldPointInDecimalDegree.Y.ToString("N4", CultureInfo.InvariantCulture)); project.Close(); }
private void mapView_MapClick(object sender, MapClickMapViewEventArgs e) { SimpleMarkerOverlay markerOverlay = (SimpleMarkerOverlay)mapView.Overlays["MarkerOverlay"]; Marker marker = new Marker(e.WorldLocation); marker.ImageSource = new BitmapImage(new Uri("/Resources/AQUA.png", UriKind.RelativeOrAbsolute)); marker.Width = 20; marker.Height = 34; marker.YOffset = -17; markerOverlay.Markers.Add(marker); markerOverlay.Refresh(); }
private void mapView_MapClick(object sender, MapClickMapViewEventArgs e) { SimpleMarkerOverlay markerOverlay = (SimpleMarkerOverlay)mapView.Overlays["MarkerOverlay"]; Marker marker = new Marker(e.WorldLocation); marker.ImageSource = new BitmapImage(new Uri("/Resources/AQUABLANK.png", UriKind.RelativeOrAbsolute)); marker.Width = 20; marker.Height = 34; marker.YOffset = -17; TextBlock content = new TextBlock(); content.Text = (index++).ToString(); content.FontSize = 14; content.FontWeight = FontWeights.Bold; content.Foreground = new SolidColorBrush(Colors.White); content.Margin = new Thickness(0, -10, 0, 0); marker.Content = content; markerOverlay.Markers.Add(marker); markerOverlay.Refresh(); }
private void mapView_MapClick(object sender, MapClickMapViewEventArgs e) { LayerOverlay layerOverlay = (LayerOverlay)mapView.Overlays["layerOverlay"]; ShapeFileFeatureLayer friscoTrails = (ShapeFileFeatureLayer)layerOverlay.Layers["friscoTrails"]; InMemoryFeatureLayer selectedLineLayer = (InMemoryFeatureLayer)layerOverlay.Layers["selectedLineLayer"]; // Query the friscoTrails layer to get the first feature closest to the map click event var feature = friscoTrails.QueryTools.GetFeaturesNearestTo(e.WorldLocation, GeographyUnit.Meter, 1, ReturningColumnsType.NoColumns).First(); // Show the selected feature on the map selectedLineLayer.InternalFeatures.Clear(); selectedLineLayer.InternalFeatures.Add(feature); layerOverlay.Refresh(); // Get the length of the first feature var length = ((LineBaseShape)feature.GetShape()).GetLength(GeographyUnit.Meter, DistanceUnit.Kilometer); // Display the selectedLine's length in the lengthResult TextBox lengthResult.Text = $"{length:f3} km"; }
private void mapView_MapClick(object sender, MapClickMapViewEventArgs e) { LayerOverlay layerOverlay = (LayerOverlay)mapView.Overlays["layerOverlay"]; ShapeFileFeatureLayer friscoParks = (ShapeFileFeatureLayer)layerOverlay.Layers["friscoParks"]; InMemoryFeatureLayer selectedAreaLayer = (InMemoryFeatureLayer)layerOverlay.Layers["selectedAreaLayer"]; // Query the friscoParks layer to get the first feature closest to the map click event var feature = friscoParks.QueryTools.GetFeaturesNearestTo(e.WorldLocation, GeographyUnit.Meter, 1, ReturningColumnsType.NoColumns).First(); // Show the selected feature on the map selectedAreaLayer.InternalFeatures.Clear(); selectedAreaLayer.InternalFeatures.Add(feature); layerOverlay.Refresh(); // Get the area of the first feature var area = ((AreaBaseShape)feature.GetShape()).GetArea(GeographyUnit.Meter, AreaUnit.SquareKilometers); // Display the selectedArea's area in the areaResult TextBox areaResult.Text = $"{area:f3} sq km"; }
private void mapView_MapClick(object sender, MapClickMapViewEventArgs e) { FeatureLayer worldLayer = mapView.FindFeatureLayer("RoadLayer"); InMemoryFeatureLayer highlightLayer = (InMemoryFeatureLayer)mapView.FindFeatureLayer("HighlightLayer"); Overlay highlightOverlay = mapView.Overlays["HighlightOverlay"]; // Find the road the user clicked on. worldLayer.Open(); Collection <Feature> selectedFeatures = worldLayer.QueryTools.GetFeaturesNearestTo(e.WorldLocation, GeographyUnit.Meter, 1, new string[1] { "FENAME" }); worldLayer.Close(); //Determine the length of the road. if (selectedFeatures.Count > 0) { LineBaseShape lineShape = (LineBaseShape)selectedFeatures[0].GetShape(); highlightLayer.Open(); highlightLayer.InternalFeatures.Clear(); highlightLayer.InternalFeatures.Add(new Feature(lineShape)); highlightLayer.Close(); ProjectionConverter project = new ProjectionConverter(3857, 4326); project.Open(); double length = ((LineBaseShape)project.ConvertToExternalProjection(lineShape)).GetLength(GeographyUnit.DecimalDegree, DistanceUnit.Meter); project.Close(); string lengthMessage = string.Format(CultureInfo.InvariantCulture, "{0} has a length of {1:F2} meters.", selectedFeatures[0].ColumnValues["FENAME"].Trim(), length); Popup popup = new Popup(e.WorldLocation); popup.Content = lengthMessage; PopupOverlay popupOverlay = (PopupOverlay)mapView.Overlays["PopupOverlay"]; popupOverlay.Popups.Clear(); popupOverlay.Popups.Add(popup); highlightOverlay.Refresh(); popupOverlay.Refresh(); } }
private void mapView_MapClick(object sender, MapClickMapViewEventArgs e) { pointShape = e.WorldLocation; FindWithinDistanceFeatures(); }
//private void SetupAnimationForOverlay(LayerOverlay overlay) //{ // overlay.Drawing -= overlay_Drawing; // overlay.Drawing += overlay_Drawing; // overlay.Drawn -= overlay_Drawn; // overlay.Drawn += overlay_Drawn; //} private void WpfMap_MapClick(object sender, MapClickMapViewEventArgs e) { if (isIdentify) { PointShape point = e.WorldLocation; if (!map.Overlays.Contains(chartsOverlayName)) { return; } LayerOverlay overlay = map.Overlays[chartsOverlayName] as LayerOverlay; var features = new Collection <Feature>(); NauticalChartsFeatureLayer hydrographyFeatureLayer = null; foreach (var item in overlay.Layers) { NauticalChartsFeatureLayer itemLayer = item as NauticalChartsFeatureLayer; itemLayer.Open(); features = itemLayer.QueryTools.GetFeaturesIntersecting(point.GetBoundingBox(), ReturningColumnsType.AllColumns); if (features.Count > 0) { hydrographyFeatureLayer = itemLayer; break; } } if (features.Count > 0) { List <FeatureInfo> selectedFeatures = new List <FeatureInfo>(); foreach (var item in features) { double area = double.MaxValue; PolygonShape areaShape = item.GetShape() as PolygonShape; if (areaShape != null) { area = areaShape.GetArea(map.MapUnit, AreaUnit.SquareMeters); } selectedFeatures.Add(new FeatureInfo(item, hydrographyFeatureLayer.Name, area)); } if (map.Overlays.Contains(highlightOverlayName)) { map.Overlays.Remove(highlightOverlayName); } IEnumerable <FeatureInfo> featureInfos = selectedFeatures.OrderBy(p => p.Area); SelectedFeatureInfo = featureInfos.FirstOrDefault(); NauticalChartsFeatureSource featureSource = hydrographyFeatureLayer.FeatureSource as NauticalChartsFeatureSource; if (featureSource != null) { ChartSelectedItem = new ChartSelectedItem(featureSource.FilePath, featureInfos); } } else { if (map.Overlays.Contains(highlightOverlayName)) { map.Overlays.Remove(highlightOverlayName); } map.Refresh(); } } }