/// <summary> /// Perform the spatial query and draw the shapes on the map /// </summary> private void GetFeaturesContaining(PointShape point) { // Find the layers we will be modifying in the MapView SimpleMarkerOverlay queryFeatureMarkerOverlay = (SimpleMarkerOverlay)mapView.Overlays["Query Feature Marker Overlay"]; ShapeFileFeatureLayer zoningLayer = (ShapeFileFeatureLayer)mapView.FindFeatureLayer("Frisco Zoning"); // Clear the query point marker overlay and add a marker on the newly drawn point queryFeatureMarkerOverlay.Markers.Clear(); // Create a marker with a static marker image and add it to the map var marker = new Marker(point) { ImageSource = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Resources/AQUA.png"), YOffset = -17 };; queryFeatureMarkerOverlay.Markers.Add(marker); queryFeatureMarkerOverlay.Refresh(); // Perform the spatial query using the drawn point and highlight features that were found var queriedFeatures = PerformSpatialQuery(point, zoningLayer); HighlightQueriedFeatures(queriedFeatures); // Clear the drawn point mapView.TrackOverlay.TrackShapeLayer.InternalFeatures.Clear(); }
private void lvcChart_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e) { SimpleMarkerOverlay markerOverlay = (SimpleMarkerOverlay)wpfMap1.Overlays["MarkerOverlay"]; markerOverlay.Markers[0].Position = new Point(-179.0, -89.0); markerOverlay.Refresh(); }
private void lvcChart_DataHover(object sender, ChartPoint chartPoint) { ChartInformation instance = (ChartInformation)chartPoint.Instance; SimpleMarkerOverlay markerOverlay = (SimpleMarkerOverlay)wpfMap1.Overlays["MarkerOverlay"]; markerOverlay.Markers[0].Position = new Point(instance.Longitude, instance.Latitude); 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/AQUA.png", UriKind.RelativeOrAbsolute)); marker.Width = 20; marker.Height = 34; marker.YOffset = -17; markerOverlay.Markers.Add(marker); markerOverlay.Refresh(); }
private void AddMarkerToMap(PointShape location) { SimpleMarkerOverlay markerOverlay = (SimpleMarkerOverlay)Map1.Overlays["MarkerOverlay"]; Marker marker = new Marker(location); marker.ImageSource = new BitmapImage(new Uri("/Resources/AQUA.png", UriKind.RelativeOrAbsolute)); marker.Width = 20; marker.Height = 34; marker.YOffset = -17; marker.RenderTransform = new RotateTransform(-currentAngle, marker.Width / 2, marker.Height); markerOverlay.Markers.Add(marker); markerOverlay.Refresh(); }
/// <summary> /// Adds a marker to the simpleMarkerOverlay where the map tap event occurred. /// </summary> private void MapView_OnMapTouch(object sender, TouchMapViewEventArgs e) { SimpleMarkerOverlay simpleMarkerOverlay = (SimpleMarkerOverlay)mapView.Overlays["simpleMarkerOverlay"]; // Create a marker at the position the mouse was tapped var marker = new Marker() { Position = e.PointInWorldCoordinate, ImageSource = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Resources/AQUA.png"), YOffset = -17 }; // Add the marker to the simpleMarkerOverlay and refresh the map simpleMarkerOverlay.Markers.Add(marker); simpleMarkerOverlay.Refresh(); }
/// <summary> /// Update the UI based on the results of a Cloud Geocoding Query /// </summary> private void UpdateSearchResultsOnUI(CloudGeocodingResult searchResult) { // Clear the locations list and existing location markers on the map SimpleMarkerOverlay geocodedLocationOverlay = (SimpleMarkerOverlay)mapView.Overlays["Geocoded Locations Overlay"]; geocodedLocationOverlay.Markers.Clear(); lsbLocations.ItemsSource = null; geocodedLocationOverlay.Refresh(); // Update the UI with the number of results found and the list of locations found txtSearchResultsDescription.Text = $"Found {searchResult.Locations.Count} matching locations."; lsbLocations.ItemsSource = searchResult.Locations; if (searchResult.Locations.Count > 0) { lsbLocations.IsVisible = true; lsbLocations.SelectedItem = searchResult.Locations[0]; } }
private void GetFeaturesWithinDistance(PointShape point) { // Find the layers we will be modifying in the MapView SimpleMarkerOverlay queryFeatureMarkerOverlay = (SimpleMarkerOverlay)mapView.Overlays["Query Feature Marker Overlay"]; ShapeFileFeatureLayer zoningLayer = (ShapeFileFeatureLayer)mapView.FindFeatureLayer("Frisco Zoning"); // Clear the query point marker overlaylayer and add a marker on the newly drawn point queryFeatureMarkerOverlay.Markers.Clear(); queryFeatureMarkerOverlay.Markers.Add(CreateNewMarker(point)); queryFeatureMarkerOverlay.Refresh(); // Perform the spatial query using the drawn point and highlight features that were found var queriedFeatures = PerformSpatialQuery(point, zoningLayer); HighlightQueriedFeatures(queriedFeatures); // Disable map drawing and clear the drawn point mapView.TrackOverlay.TrackMode = TrackMode.None; mapView.TrackOverlay.TrackShapeLayer.InternalFeatures.Clear(); }
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(); }
internal static void AddMarker(PointShape point, string initText = "", object tag = null, string styleValue = "") { string markerId = (tag ?? ViewModel.CurrentAnnotationOverlay.NewFeatureName()) as string; AddMarkerOverlayIfNotExisting(GisEditor.ActiveMap); SimpleMarkerOverlay markerOverlay = CurrentMarkerOverlay; var textBox = new TextBox { MinWidth = 100, AcceptsReturn = true, AcceptsTab = true, Text = initText, Tag = styleValue }; textBox.FocusableChanged += new DependencyPropertyChangedEventHandler((ds, de) => { if ((bool)de.NewValue) { textBox.BorderBrush = new SolidColorBrush(Colors.Gray); } else { textBox.BorderBrush = new SolidColorBrush(Colors.Black); } }); TextStyle textStyle = null; if (String.IsNullOrEmpty(styleValue)) { textStyle = ViewModel.CurrentAnnotationOverlay.GetLatestStyle <TextStyle>(AnnotaionStyleType.LayerStyle); } else { textStyle = ViewModel.CurrentAnnotationOverlay.GetSpecificTextStyle(styleValue); } if (textStyle != null) { ApplyTextStyleToTextBox(textStyle, textBox); } textBox.Loaded += (s, arg) => { var box = s as TextBox; box.Focus(); if (!String.IsNullOrEmpty(box.Text)) { box.Cursor = System.Windows.Input.Cursors.SizeAll; } }; textBox.KeyDown += textBox_KeyDown; Marker marker = new AnnotationMarker(point) { Content = textBox, ImageSource = null, Tag = markerId, VerticalContentAlignment = VerticalAlignment.Top, HorizontalContentAlignment = HorizontalAlignment.Left }; marker.PositionChanged += marker_PositionChanged; if (!String.IsNullOrEmpty(initText)) { var measuredSize = new PlatformGeoCanvas().MeasureText(initText, textStyle.Font); marker.Width = measuredSize.Width; marker.Height = measuredSize.Height; textBox.Focusable = false; textBox.IsReadOnly = true; var textBoxLoseFocus = new Action <object, RoutedEventArgs>((ds, de) => { textBox.Focusable = false; textBox.IsReadOnly = true; if (String.IsNullOrEmpty(textBox.Text)) { textBox.Cursor = System.Windows.Input.Cursors.IBeam; } else { textBox.Cursor = System.Windows.Input.Cursors.SizeAll; } }); Point clickPoint = new Point(double.PositiveInfinity, double.PositiveInfinity); marker.MouseLeftButtonDown += new MouseButtonEventHandler((ds, de) => { clickPoint = de.GetPosition(GisEditor.ActiveMap); ((Marker)ds).Cursor = System.Windows.Input.Cursors.SizeAll; }); marker.MouseLeftButtonUp += new MouseButtonEventHandler((ds, de) => { ((Marker)ds).Cursor = System.Windows.Input.Cursors.Arrow; }); marker.MouseLeftButtonUp += new MouseButtonEventHandler((ds, de) => { Point tmpPoint = de.GetPosition(GisEditor.ActiveMap); if (Math.Abs(tmpPoint.X - clickPoint.X) < 1 && Math.Abs(tmpPoint.Y - clickPoint.Y) < 1) { textBox.Focusable = true; textBox.IsReadOnly = false; textBox.LostFocus -= new RoutedEventHandler(textBoxLoseFocus); textBox.LostFocus += new RoutedEventHandler(textBoxLoseFocus); textBox.Focus(); textBox.Cursor = System.Windows.Input.Cursors.IBeam; } clickPoint.X = double.PositiveInfinity; clickPoint.Y = double.PositiveInfinity; }); } marker.AdjustPosition(textStyle.PointPlacement); markerOverlay.Markers.Add(markerId, marker); markerOverlay.Refresh(); }