void Map1_MapClick(object sender, MapClickWpfMapEventArgs e) { if (tapRadioButton.IsChecked.GetValueOrDefault()) { AddMarkerToMap(e.WorldLocation); } }
private void wpfMap1_MapClick(object sender, MapClickWpfMapEventArgs e) { FeatureLayer worldLayer = wpfMap1.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)wpfMap1.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(); } }
void wpfMap1_MapClick(object sender, MapClickWpfMapEventArgs e) { FeatureLayer worldLayer = wpfMap1.FindFeatureLayer("RoadLayer"); InMemoryFeatureLayer highlightLayer = (InMemoryFeatureLayer)wpfMap1.FindFeatureLayer("HighlightLayer"); Overlay highlightOverlay = wpfMap1.Overlays["HighlightOverlay"]; // Find the road the user clicked on. worldLayer.Open(); Collection<Feature> selectedFeatures = worldLayer.QueryTools.GetFeaturesNearestTo(e.WorldLocation, GeographyUnit.DecimalDegree, 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(); double length = lineShape.GetLength(GeographyUnit.DecimalDegree, DistanceUnit.Meter); 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)wpfMap1.Overlays["PopupOverlay"]; popupOverlay.Popups.Clear(); popupOverlay.Popups.Add(popup); highlightOverlay.Refresh(); popupOverlay.Refresh(); } }
private void wpfMap_MapClick(object sender, MapClickWpfMapEventArgs e) { if (e.MouseButton == MapMouseButton.Right) { // Set the searchPoint value to coordinat textbox. txtCoordinate.Text = string.Format("{0},{1}", e.WorldY.ToString("0.000000"), e.WorldX.ToString("0.000000")); SearchPlaceAndNearbys(); } }
private void wpfMap1_MapClick(object sender, MapClickWpfMapEventArgs e) { SimpleMarkerOverlay markerOverlay = (SimpleMarkerOverlay)wpfMap1.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 SelectLinePoint_MapClick(object sender, MapClickWpfMapEventArgs e) { if (gradeLine.Vertices.Count > 0) { gradeLine.Vertices.Add(new Vertex(e.WorldLocation.X, e.WorldLocation.Y)); slider.Value = 15; } else { startMarker.Position = new Point(e.WorldLocation.X, e.WorldLocation.Y); gradeLine.Vertices.Add(new Vertex(e.WorldLocation.X, e.WorldLocation.Y)); wpfMap1.Overlays["markOverlay"].Refresh(); CreateChartByPoint(new PointShape(new Vertex(e.WorldLocation.X, e.WorldLocation.Y))); slider.Value = 1; } }
private void wpfMap1_MapClick(object sender, MapClickWpfMapEventArgs e) { SimpleMarkerOverlay markerOverlay = (SimpleMarkerOverlay)wpfMap1.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 WpfMap1_MapClick(object sender, MapClickWpfMapEventArgs e) { if (e.MouseButton == MapMouseButton.Left) { RectangleShape clickedArea = MapSuiteSampleHelper.GetBufferedRectangle(e.WorldLocation, mapControl.CurrentResolution); PopupOverlay.Popups.Clear(); foreach (InMemoryFeatureLayer vehicleLayer in TraceOverlay.Layers.OfType <InMemoryFeatureLayer>()) { vehicleLayer.Open(); Collection <Feature> resultFeatures = vehicleLayer.QueryTools.GetFeaturesIntersecting(clickedArea, ReturningColumnsType.AllColumns); if (resultFeatures.Count > 0) { Popup popup = new Popup(e.WorldLocation); PopupUserControl popupUserControl = new PopupUserControl(resultFeatures[0]); popupUserControl.PopupOverlay = PopupOverlay; popup.Content = popupUserControl; PopupOverlay.Popups.Add(popup); PopupOverlay.Refresh(); break; } } } }
private void wpfMap1_MapClick(object sender, MapClickWpfMapEventArgs e) { LayerOverlay worldOverlay = (LayerOverlay)wpfMap1.Overlays["WorldOverlay"]; FeatureLayer worldLayer = (FeatureLayer)worldOverlay.Layers["WorldLayer"]; LayerOverlay highlightOverlay = (LayerOverlay)wpfMap1.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 wpfMap1_MapClick(object sender, MapClickWpfMapEventArgs e) { FeatureLayer worldLayer = wpfMap1.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) { AreaBaseShape areaShape = (AreaBaseShape)selectedFeatures[0].GetShape(); 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)wpfMap1.Overlays["PopupOverlay"]; popupOverlay.Popups.Clear(); popupOverlay.Popups.Add(popup); popupOverlay.Refresh(); } }
private void wpfMap1_MapClick(object sender, MapClickWpfMapEventArgs e) { try { //Uses the WrapDatelineProjection to create the target pointshape for GetFeatureNearestTo spatial query function. WrapDatelineProjection wrapDatelineProjection = new WrapDatelineProjection(); //Sets the HalfExtentWidth of the wrapdateline overlay we want to apply the projection on. //Here it is 180 because, the full extent width is 360. wrapDatelineProjection.HalfExtentWidth = wpfMap1.Overlays["WMK"].GetBoundingBox().Width / 2;//180; //Gets the valid world coordinate regardless to where the user click on the map wrapDatelineProjection.Open(); Vertex projVertex = wrapDatelineProjection.ConvertToExternalProjection(e.WorldX, e.WorldY); wrapDatelineProjection.Close(); //Here we just use the feature source of the shapefile because we don't display it, we just use it for doing the spatial query. ShapeFileFeatureSource shapeFileFeatureSource = new ShapeFileFeatureSource(@"../../data/countries02.shp"); shapeFileFeatureSource.Open(); //Uses the projected X and Y values for the Spatial Query. Collection <Feature> features = shapeFileFeatureSource.GetFeaturesNearestTo(new PointShape(projVertex), wpfMap1.MapUnit, 1, ReturningColumnsType.NoColumns); shapeFileFeatureSource.Close(); LayerOverlay dynamicOverlay = (LayerOverlay)wpfMap1.Overlays["DynamicOverlay"]; InMemoryFeatureLayer inMemoryFeatureLayer = (InMemoryFeatureLayer)dynamicOverlay.Layers["SelectLayer"]; //Clears the InMemoryFeatureLayer and add the feature as the result of the spatial query. inMemoryFeatureLayer.Open(); inMemoryFeatureLayer.InternalFeatures.Clear(); inMemoryFeatureLayer.InternalFeatures.Add(features[0]); inMemoryFeatureLayer.Close(); //Refreshes only the overlay with the updated InMemoryFeatureLayer. wpfMap1.Refresh(dynamicOverlay); } catch { } }
//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, MapClickWpfMapEventArgs e) { if (isIdentify) { ThinkGeo.MapSuite.Shapes.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.NauticalChartsPathFilename, featureInfos); } } else { if (map.Overlays.Contains(highlightOverlayName)) { map.Overlays.Remove(highlightOverlayName); } map.Refresh(); } } }
private void wpfMap1_MapClick(object sender, MapClickWpfMapEventArgs e) { pointShape = e.WorldLocation; FindWithinDistanceFeatures(); }
private void wpfMap1_MapClick(object sender, MapClickWpfMapEventArgs e) { screenPosition.Text = "(" + e.ScreenX + ", " + e.ScreenY + ")"; worldPosition.Text = string.Format(CultureInfo.InvariantCulture, "({0}, {1})", e.WorldX.ToString("N4", CultureInfo.InvariantCulture), e.WorldY.ToString("N4", CultureInfo.InvariantCulture)); }
private void WpfMap1_MapClick(object sender, MapClickWpfMapEventArgs e) { if (e.MouseButton == MapMouseButton.Left) { RectangleShape clickedArea = MapSuiteSampleHelper.GetBufferedRectangle(e.WorldLocation, mapControl.CurrentResolution); PopupOverlay.Popups.Clear(); foreach (InMemoryFeatureLayer vehicleLayer in TraceOverlay.Layers.OfType<InMemoryFeatureLayer>()) { vehicleLayer.Open(); Collection<Feature> resultFeatures = vehicleLayer.QueryTools.GetFeaturesIntersecting(clickedArea, ReturningColumnsType.AllColumns); if (resultFeatures.Count > 0) { Popup popup = new Popup(e.WorldLocation); PopupUserControl popupUserControl = new PopupUserControl(resultFeatures[0]); popupUserControl.PopupOverlay = PopupOverlay; popup.Content = popupUserControl; PopupOverlay.Popups.Add(popup); PopupOverlay.Refresh(); break; } } } }
private void wpfMap1_MapClick(object sender, MapClickWpfMapEventArgs e) { TBLonLat.Text = string.Format(CultureInfo.InvariantCulture, "X={0}, Y={1}", e.WorldX.ToString("N4", CultureInfo.InvariantCulture), e.WorldY.ToString("N4", CultureInfo.InvariantCulture)); }