private void winformsMap1_MapClick(object sender, MapClickWinformsMapEventArgs e) { if (tbnInformation.Checked) { SelectInformation(e.WorldLocation); } }
private void winformsMap1_MapClick(object sender, MapClickWinformsMapEventArgs e) { //Here we use a buffer of 15 in screen coordinate. This means that regardless of the zoom level, we will always find the nearest feature //within 15 pixels to where we clicked. int screenBuffer = 15; //Logic for converting screen coordinate values to world coordinate for the spatial query. Notice that the distance buffer for the spatial query //will change according to the zoom level while it remains the same for the screen buffer distance. ScreenPointF clickedPointF = new ScreenPointF(e.ScreenX, e.ScreenY); ScreenPointF bufferPointF = new ScreenPointF(clickedPointF.X + screenBuffer, clickedPointF.Y); double distanceBuffer = ExtentHelper.GetWorldDistanceBetweenTwoScreenPoints(winformsMap1.CurrentExtent, clickedPointF, bufferPointF, winformsMap1.Width, winformsMap1.Height, winformsMap1.MapUnit, DistanceUnit.Meter); ShapeFileFeatureLayer streetLayer = (ShapeFileFeatureLayer)winformsMap1.FindFeatureLayer("StreetLayer"); Collection <string> columnNames = new Collection <string>(); columnNames.Add("FENAME"); Collection <Feature> features = streetLayer.FeatureSource.GetFeaturesNearestTo(new PointShape(e.WorldX, e.WorldY), winformsMap1.MapUnit, 1, columnNames, distanceBuffer, DistanceUnit.Meter); //Adds the feature clicked on to the selected layer to be displayed as highlighed and with the name labeled. InMemoryFeatureLayer selectLayer = (InMemoryFeatureLayer)winformsMap1.FindFeatureLayer("SelectLayer"); selectLayer.InternalFeatures.Clear(); if (features.Count > 0) { selectLayer.InternalFeatures.Add(features[0]); } //Refreshes only the select layer. winformsMap1.Refresh(winformsMap1.Overlays["SelectOverlay"]); }
private void winformsMap1_MapClick(object sender, MapClickWinformsMapEventArgs e) { SimpleMarkerOverlay markerOverlay = (SimpleMarkerOverlay)winformsMap1.Overlays["MarkerOverlay"]; Marker marker = new Marker(e.WorldLocation); marker.Image = Properties.Resources.AQUA; marker.Width = 20; marker.Height = 34; marker.YOffset = -17; markerOverlay.Markers.Add(marker); winformsMap1.Refresh(); }
private void winformsMap1_MapClick(object sender, MapClickWinformsMapEventArgs e) { FeatureLayer worldLayer = winformsMap1.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) { dgridFeatures.DataSource = (DataTable)FeatureSource.ConvertToDataTable(selectedFeatures, new string[] { "CNTRY_NAME", "POP_CNTRY" }); } }
private void winformsMap1_MapClick(object sender, MapClickWinformsMapEventArgs e) { FeatureLayer worldLayer = winformsMap1.FindFeatureLayer("WorldLayer"); worldLayer.Open(); Collection <Feature> selectedFeatures = worldLayer.QueryTools.GetFeaturesContaining(e.WorldLocation, new string[1] { "CNTRY_NAME" }); worldLayer.Close(); if (selectedFeatures.Count > 0) { string text = "The country you selected is: " + selectedFeatures[0].ColumnValues["CNTRY_NAME"].Trim(); MessageBox.Show(text, "Note", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, (MessageBoxOptions)0); } }
private void winformsMap1_MapClick(object sender, MapClickWinformsMapEventArgs e) { SimpleMarkerOverlay markerOverlay = (SimpleMarkerOverlay)winformsMap1.Overlays["MarkerOverlay"]; Marker marker = new Marker(e.WorldLocation); Label content = new Label(); content.Image = Properties.Resources.AQUABLANK; content.Width = 20; content.Height = 34; content.Text = (index++).ToString(); content.Font = new Font("Arial", 14, FontStyle.Bold); content.ForeColor = Color.White; content.Margin = new Padding(0, -10, 0, 0); marker.Controls.Add(content); markerOverlay.Markers.Add(marker); winformsMap1.Refresh(); }
private void winformsMap1_MapClick(object sender, MapClickWinformsMapEventArgs e) { FeatureLayer worldLayer = winformsMap1.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); MessageBox.Show(string.Format(CultureInfo.InvariantCulture, "{0} has an area of {1:N0} square kilometers.", selectedFeatures[0].ColumnValues["CNTRY_NAME"].Trim(), area), "Area", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, (MessageBoxOptions)0); } }
private void winformsMap1_MapClick(object sender, MapClickWinformsMapEventArgs e) { FeatureLayer worldLayer = winformsMap1.FindFeatureLayer("RoadLayer"); // 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(); double length = lineShape.GetLength(GeographyUnit.DecimalDegree, DistanceUnit.Meter); MessageBox.Show(string.Format(CultureInfo.InvariantCulture, "{0} has a length of {1:F2} meters.", selectedFeatures[0].ColumnValues["FENAME"].Trim(), length), "Length", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, (MessageBoxOptions)0); } }
private void winformsMap1_MapClick(object sender, MapClickWinformsMapEventArgs e) { if (isAddingRoadblocks) { featureSource.Open(); Collection <Feature> closestFeatures = featureSource.GetFeaturesNearestTo(e.WorldLocation, winformsMap1.MapUnit, 1, ReturningColumnsType.NoColumns); if (closestFeatures.Count > 0) { PointShape position = ((LineBaseShape)closestFeatures[0].GetShape()).GetCenterPoint(); Feature feature = new Feature(position.GetWellKnownBinary(), closestFeatures[0].Id); if (feature.Id != startFeature.Id && feature.Id != endFeature.Id) { roadblocksLayer.InternalFeatures.Add(feature); } LayerOverlay overlay = (LayerOverlay)winformsMap1.Overlays["RoutingOverlay"]; winformsMap1.Refresh(overlay); } Route(); } }
private void winformsMap1_MapClick(object sender, MapClickWinformsMapEventArgs e) { // Select the nearest feature from route features LayerOverlay roadOverlay = (LayerOverlay)winformsMap1.Overlays["RoadsOverlay"]; if (isInEditMode) { featureSource.Open(); Collection <Feature> closestFeatures = featureSource.GetFeaturesNearestTo(e.WorldLocation, winformsMap1.MapUnit, 1, ReturningColumnsType.NoColumns); if (closestFeatures.Count > 0) { editFeature = closestFeatures[0]; routingSource.Open(); editRouteSegment = routingSource.GetRouteSegmentByFeatureId(editFeature.Id); RenderRouteSegmentInformation(roadOverlay); } } else if (routingSource.IsInTransaction) { EditRoutingData(e.WorldLocation, roadOverlay); } }
private void winformsMap1_MapClick(object sender, MapClickWinformsMapEventArgs e) { pointShape = e.WorldLocation; FindWithinDistanceFeatures(); }
private void winformsMap1_MapClick(object sender, MapClickWinformsMapEventArgs e) { txtXCoordinate.Text = e.WorldX.ToString("N4", CultureInfo.InvariantCulture); txtYCoordinate.Text = e.WorldY.ToString("N4", CultureInfo.InvariantCulture); }
private void winformsMap1_MapClick(object sender, MapClickWinformsMapEventArgs 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)); }