private void AndroidMap_MapSingleTap(object sender, Android.Views.MotionEvent e) { PointF location = new PointF(e.GetX(), e.GetY()); PointShape position = ExtentHelper.ToWorldCoordinate(androidMap.CurrentExtent, location.X, location.Y, androidMap.Width, androidMap.Height); LayerOverlay worldOverlay = (LayerOverlay)androidMap.Overlays["WorldOverlay"]; LayerOverlay highlightOverlay = (LayerOverlay)androidMap.Overlays["HighlightOverlay"]; FeatureLayer worldLayer = (FeatureLayer)worldOverlay.Layers["WorldLayer"]; InMemoryFeatureLayer highlightLayer = (InMemoryFeatureLayer)highlightOverlay.Layers["HighlightLayer"]; worldLayer.Open(); Collection <Feature> selectedFeatures = worldLayer.QueryTools.GetFeaturesContaining(position, new string[1] { "CNTRY_NAME" }); worldLayer.Close(); highlightLayer.Open(); highlightLayer.InternalFeatures.Clear(); if (selectedFeatures.Count > 0) { highlightLayer.InternalFeatures.Add(selectedFeatures[0]); } highlightLayer.Close(); highlightOverlay.Refresh(); }
private void MapViewMapSingleTap(object sender, UIGestureRecognizer e) { CGPoint location = e.LocationInView(View); PointShape position = ExtentHelper.ToWorldCoordinate(mapView.CurrentExtent, (float)location.X, (float)location.Y, (float)View.Frame.Width, (float)View.Frame.Height); routingLayer.Routes.Clear(); if (firstClick) { routingLayer.StartPoint = position; firstClick = false; } else { routingLayer.EndPoint = position; firstClick = true; } routingLayer.Routes.Clear(); if (routingLayer.StartPoint != null && routingLayer.EndPoint != null) { RoutingResult routingResult = routingEngine.GetRoute(routingLayer.StartPoint, routingLayer.EndPoint); routingLayer.Routes.Add(routingResult.Route); ShowTurnByTurnDirections(routingResult.RouteSegments, routingResult.Features); } layerOverlay.Refresh(); }
private void AndroidMap_MapSingleTap(object sender, Android.Views.MotionEvent e) { PointF location = new PointF(e.GetX(), e.GetY()); PointShape position = ExtentHelper.ToWorldCoordinate(androidMap.CurrentExtent, location.X, location.Y, androidMap.Width, androidMap.Height); LayerOverlay worldOverlay = (LayerOverlay)androidMap.Overlays["WorldOverlay"]; FeatureLayer worldLayer = (FeatureLayer)worldOverlay.Layers["WorldLayer"]; LayerOverlay highlightOverlay = (LayerOverlay)androidMap.Overlays["HighlightOverlay"]; InMemoryFeatureLayer highlightLayer = (InMemoryFeatureLayer)highlightOverlay.Layers["HighlightLayer"]; worldLayer.Open(); Collection <Feature> selectedFeatures = worldLayer.QueryTools.GetFeaturesContaining(position, new string[1] { "CNTRY_NAME" }); worldLayer.Close(); highlightLayer.Open(); highlightLayer.InternalFeatures.Clear(); if (selectedFeatures.Count > 0) { AreaBaseShape areaShape = (AreaBaseShape)selectedFeatures[0].GetShape(); double area = areaShape.GetArea(GeographyUnit.DecimalDegree, AreaUnit.SquareKilometers); messageTextView.Text = string.Format(CultureInfo.InvariantCulture, "{0} has an area of {1:N0} square kilometers.", selectedFeatures[0].ColumnValues["CNTRY_NAME"].Trim(), area); highlightLayer.InternalFeatures.Add(selectedFeatures[0]); } highlightLayer.Close(); highlightOverlay.Refresh(); }
private void AndroidMapMapSingleTap(object sender, Android.Views.MotionEvent e) { PointF location = new PointF(e.GetX(), e.GetY()); PointShape position = ExtentHelper.ToWorldCoordinate(androidMap.CurrentExtent, location.X, location.Y, androidMap.Width, androidMap.Height); LayerOverlay overlay = androidMap.Overlays["RoadOverlay"] as LayerOverlay; FeatureLayer roadLayer = overlay.Layers["TXlkaA40"] as FeatureLayer; LayerOverlay highlightOverlay = androidMap.Overlays["HighlightOverlay"] as LayerOverlay; InMemoryFeatureLayer highlightLayer = (InMemoryFeatureLayer)highlightOverlay.Layers["HighlightLayer"]; roadLayer.Open(); Collection <Feature> selectedFeatures = roadLayer.QueryTools.GetFeaturesNearestTo(position, GeographyUnit.DecimalDegree, 1, new string[1] { "fename" }); roadLayer.Close(); 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); messageLabel.Text = lengthMessage; highlightOverlay.Refresh(); } }
private void AndroidMap_MapSingleTap(object sender, MotionEvent e) { LayerOverlay worldOverlay = (LayerOverlay)androidMap.Overlays["WorldOverlay"]; FeatureLayer worldLayer = (FeatureLayer)worldOverlay.Layers["WorldLayer"]; LayerOverlay highlightOverlay = (LayerOverlay)androidMap.Overlays["HighlightOverlay"]; InMemoryFeatureLayer highlightLayer = (InMemoryFeatureLayer)highlightOverlay.Layers["HighlightLayer"]; PointF location = new PointF(e.GetX(), e.GetY()); var worldLocation = ExtentHelper.ToWorldCoordinate(androidMap.CurrentExtent, location.X, location.Y, androidMap.Width, androidMap.Height); worldLayer.Open(); Collection <Feature> selectedFeatures = worldLayer.QueryTools.GetFeaturesContaining(worldLocation, ReturningColumnsType.NoColumns); worldLayer.Close(); highlightLayer.Open(); highlightLayer.InternalFeatures.Clear(); if (selectedFeatures.Count > 0) { androidMap.ZoomTo(selectedFeatures[0].GetBoundingBox()); highlightLayer.InternalFeatures.Add(selectedFeatures[0]); } highlightLayer.Close(); highlightOverlay.Refresh(); }
private void winformsMap1_MouseDown(object sender, MouseEventArgs e) { InMemoryFeatureLayer mouseMoveLayer = (InMemoryFeatureLayer)((LayerOverlay)winformsMap1.Overlays["MouseMoveOverlay"]).Layers["MouseMoveLayer"]; if (mouseMoveLayer.InternalFeatures.Count > 0 && string.IsNullOrEmpty(currentStopId)) { isPointSelected = true; InMemoryFeatureLayer stopLayer = (InMemoryFeatureLayer)((LayerOverlay)winformsMap1.Overlays["StopOverlay"]).Layers["StopLayer"]; PointShape currentShape = ExtentHelper.ToWorldCoordinate(winformsMap1.CurrentExtent, ((MouseEventArgs)e).X, ((MouseEventArgs)e).Y, winformsMap1.Width, winformsMap1.Height); FeatureLayer austinstreetsLayer = winformsMap1.FindFeatureLayer("AustinstreetsLayer"); austinstreetsLayer.Open(); Collection <Feature> tempFeatures = austinstreetsLayer.QueryTools.GetFeaturesNearestTo(currentShape, GeographyUnit.DecimalDegree, 1, new string[] { }); Feature stopRoad = tempFeatures[0]; austinstreetsLayer.Close(); currentStopId = stopRoad.Id; Feature stopPoint = new Feature(stopRoad.GetShape().GetCenterPoint().GetWellKnownBinary(), stopRoad.Id); Feature lastFeature = stopLayer.InternalFeatures[stopLayer.InternalFeatures.Count - 1]; //winformsMap1.Overlays["StopOverlay"].Lock.EnterWriteLock(); //try //{ stopLayer.InternalFeatures.RemoveAt(stopLayer.InternalFeatures.Count - 1); stopLayer.InternalFeatures.Add(currentStopId, stopPoint); stopLayer.InternalFeatures.Add(lastFeature.Id, lastFeature); //} //finally //{ // winformsMap1.Overlays["StopOverlay"].Lock.ExitWriteLock(); //} winformsMap1.Overlays["StopOverlay"].Lock.IsDirty = true; } }
private void MapControl_MouseMove(object sender, MouseEventArgs e) { PointShape mouseLocation = ExtentHelper.ToWorldCoordinate(map.CurrentExtent, new ScreenPointF(e.X, e.Y), map.Width, map.Height); lblFooterLocationX.Text = string.Format(CultureInfo.InvariantCulture, "X:{0:N2}", mouseLocation.X); lblFooterLocationY.Text = string.Format(CultureInfo.InvariantCulture, "Y:{0:N2}", mouseLocation.Y); }
private void WpfMap_MouseMove(object sender, MouseEventArgs e) { toolTip.IsOpen = false; mapModel.HighlightOverlay.HighlightFeature = null; if (!mapModel.HighlightOverlay.IsPanningMap) { Point screenLocation = e.GetPosition(mapModel.MapControl); PointShape worldLoction = ExtentHelper.ToWorldCoordinate(mapModel.MapControl.CurrentExtent, new ScreenPointF((float)screenLocation.X, (float)screenLocation.Y), (float)mapModel.MapControl.ActualWidth, (float)mapModel.MapControl.ActualHeight); // Here we get tootip for the highlighted feature. if (worldLoction.X > -180 && worldLoction.X < 180 && worldLoction.Y > -90 && worldLoction.Y < 90) { mapModel.DefaultFeatureLayer.Open(); List <string> columnNames = mapModel.DefaultFeatureLayer.FeatureSource.GetColumns().Select(x => x.ColumnName).ToList(); Collection <Feature> nearestFeatures = mapModel.DefaultFeatureLayer.QueryTools.GetFeaturesNearestTo(worldLoction, mapModel.MapControl.MapUnit, 1, columnNames, 1, DistanceUnit.Meter); if (nearestFeatures.Count > 0) { var highlightedFeature = nearestFeatures[0]; mapModel.HighlightOverlay.HighlightFeature = highlightedFeature; mapModel.HighlightOverlay.Refresh(); var content = GetToolTip(highlightedFeature); toolTip.Content = content; toolTip.IsOpen = true; } } } mapModel.HighlightOverlay.Refresh(); }
private void wpfMap1_MouseMove(object sender, MouseEventArgs e) { //Gets the PointShape in world coordinates from screen coordinates. Point point = e.MouseDevice.GetPosition(null); ScreenPointF screenPointF = new ScreenPointF((float)point.X, (float)point.Y); PointShape pointShape = ExtentHelper.ToWorldCoordinate(wpfMap1.CurrentExtent, screenPointF, (float)wpfMap1.ActualWidth, (float)wpfMap1.ActualHeight); //Uses the WrapDatelineProjection to get the proper decimal degree value on the virtual maps to the right and left of the central map. 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; wrapDatelineProjection.Open(); Vertex projVertex = wrapDatelineProjection.ConvertToExternalProjection(pointShape.X, pointShape.Y); wrapDatelineProjection.Close(); try { //Shows the real coordinates. textBox1.Text = "real X: " + string.Format("{0}", System.Math.Round(pointShape.X)) + " real Y: " + string.Format("{0}", System.Math.Round(pointShape.Y)); //Shows the Long Lat after the WrapDatelineProjection textBox3.Text = "Long.: " + System.Math.Round(projVertex.X) + " Lat.: " + System.Math.Round(projVertex.Y); } catch { } }
private void WpfMap_MouseMove(object sender, System.Windows.Input.MouseEventArgs e) { Point currentPoint = e.GetPosition(WpfMap); PointShape worldPoint = ExtentHelper.ToWorldCoordinate(WpfMap.CurrentExtent, new ScreenPointF((float)currentPoint.X, (float)currentPoint.Y), (float)WpfMap.ActualWidth, (float)WpfMap.ActualHeight); CurrentX.Text = worldPoint.X.ToString("f6", CultureInfo.InvariantCulture); CurrentY.Text = worldPoint.Y.ToString("f6", CultureInfo.InvariantCulture); }
private void AndroidMap_MapSingleTap(object sender, MotionEvent e) { PointF location = new PointF(e.GetX(), e.GetY()); PointShape worldPosition = ExtentHelper.ToWorldCoordinate(androidMap.CurrentExtent, location.X, location.Y, androidMap.Width, androidMap.Height); screenPositionLable.Text = string.Format("Screen Position:({0:N4},{1:N4})", location.X, location.Y); worldPositionLable.Text = string.Format("World Position: ({0:N4},{1:N4})", worldPosition.X, worldPosition.Y); }
private RectangleShape ToWorldCoordinate(GeoCanvas canvas, DrawingRectangleF drawingRectangle) { PointShape upperLeftPoint = ExtentHelper.ToWorldCoordinate(canvas.CurrentWorldExtent, drawingRectangle.CenterX - drawingRectangle.Width / 2, drawingRectangle.CenterY - drawingRectangle.Height / 2, canvas.Width, canvas.Height); PointShape lowerRightPoint = ExtentHelper.ToWorldCoordinate(canvas.CurrentWorldExtent, drawingRectangle.CenterX + drawingRectangle.Width / 2, drawingRectangle.CenterY + drawingRectangle.Height / 2, canvas.Width, canvas.Height); RectangleShape worldRectangle = new RectangleShape(upperLeftPoint, lowerRightPoint); return(worldRectangle); }
private void WpfMap_MouseMove(object sender, System.Windows.Input.MouseEventArgs e) { Point point = e.MouseDevice.GetPosition(null); ScreenPointF screenPointF = new ScreenPointF((float)point.X, (float)point.Y); PointShape pointShape = ExtentHelper.ToWorldCoordinate(WpfMap.CurrentExtent, screenPointF, (float)WpfMap.ActualWidth, (float)WpfMap.ActualHeight); textBox1.Text = $"X: {pointShape.X} Y: {pointShape.Y}"; }
private void AppendCoordinates(IEnumerable <ScreenPointF> screenPoints, float xOffset, float yOffset, StringBuilder contentStringBuilder) { contentStringBuilder.AppendLine(@"<coordinates>"); foreach (ScreenPointF screenPoint in screenPoints) { PointShape pointShape = ExtentHelper.ToWorldCoordinate(virtualWorldExtent, screenPoint.X + xOffset, screenPoint.Y + yOffset, virtualMapWidth, virtualMapHeight); contentStringBuilder.AppendFormat(" {0},{1} ", pointShape.X, pointShape.Y); } contentStringBuilder.AppendLine(@"</coordinates>"); }
private void wpfMap1_MouseMove(object sender, MouseEventArgs e) { //Gets the PointShape in world coordinates from screen coordinates. Point point = e.MouseDevice.GetPosition(null); ScreenPointF screenPointF = new ScreenPointF((float)point.X, (float)point.Y); PointShape pointShape = ExtentHelper.ToWorldCoordinate(wpfMap1.CurrentExtent, screenPointF, (float)wpfMap1.Width, (float)wpfMap1.Height); textBox1.Text = "X: " + Math.Round(pointShape.X) + " Y: " + Math.Round(pointShape.Y); }
private void winformsMap1_MouseMove(object sender, MouseEventArgs e) { //Displays the X and Y in screen coordinates. statusStrip1.Items["toolStripStatusLabelScreen"].Text = "X:" + e.X + " Y:" + e.Y; //Gets the PointShape in world coordinates from screen coordinates. PointShape pointShape = ExtentHelper.ToWorldCoordinate(winformsMap1.CurrentExtent, new ScreenPointF(e.X, e.Y), winformsMap1.Width, winformsMap1.Height); //Displays world coordinates. statusStrip1.Items["toolStripStatusLabelWorld"].Text = "(world) X:" + Math.Round(pointShape.X, 4) + " Y:" + Math.Round(pointShape.Y, 4); }
private void AndroidMap_MapSingleTap(object sender, MotionEvent e) { Marker marker = new Marker(this); PointF location = new PointF(e.GetX(), e.GetY()); marker.Position = ExtentHelper.ToWorldCoordinate(androidMap.CurrentExtent, location.X, location.Y, (float)androidMap.Width, (float)androidMap.Height); marker.SetImageBitmap(BitmapFactory.DecodeResource(Resources, Resource.Drawable.Pin)); marker.YOffset = -(int)(22 * Resources.DisplayMetrics.Density); markerOverlay.Markers.Add(marker); markerOverlay.Refresh(); }
//In the MouseDoubleClick event, we allow adding a new draggable icon by left double clicking on the map and //removing an icon by right double clicking. private void winformsMap1_MouseDoubleClick(object sender, MouseEventArgs e) { winformsMap1.EditOverlay.EditShapesLayer.Open(); PointShape clickedPointShape = ExtentHelper.ToWorldCoordinate(winformsMap1.CurrentExtent, e.X, e.Y, winformsMap1.Width, winformsMap1.Height); //For removing the icon clicked on. if (e.Button == MouseButtons.Right) { Collection <Feature> clickedFeatures = winformsMap1.EditOverlay.EditShapesLayer.QueryTools.GetFeaturesNearestTo(clickedPointShape, GeographyUnit.DecimalDegree, 1, ReturningColumnsType.AllColumns); winformsMap1.EditOverlay.EditShapesLayer.Close(); if (clickedFeatures.Count > 0) { //Gets the dimension of the icon and checks if the clicked point is inside it. ValueStyle valueStyle = (ValueStyle)winformsMap1.EditOverlay.EditShapesLayer.ZoomLevelSet.ZoomLevel01.CustomStyles[0]; //we loop thru the different ValueItem to get the appropriate icon according to the "Type". GeoImage geoImage = null; string text = clickedFeatures[0].ColumnValues["Type"].Trim(); foreach (ValueItem valueItem in valueStyle.ValueItems) { if (text == valueItem.Value) { geoImage = (GeoImage)valueStyle.ValueItems[0].DefaultPointStyle.Image; break; } } //We check to see if we clicked inside the icon itself. ScreenPointF screenPointF = ExtentHelper.ToScreenCoordinate(winformsMap1.CurrentExtent, clickedFeatures[0], winformsMap1.Width, winformsMap1.Height); RectangleF rectangleF = new RectangleF(screenPointF.X - (geoImage.GetWidth() / 2), screenPointF.Y - (geoImage.GetHeight() / 2), geoImage.GetWidth(), geoImage.GetHeight()); bool IsInside = rectangleF.Contains(new PointF(e.X, e.Y)); //If inside, removes the feature from the EditShapesLayer of the EditOverlay. if (IsInside == true) { winformsMap1.EditOverlay.EditShapesLayer.InternalFeatures.Remove(clickedFeatures[0]); winformsMap1.Refresh(winformsMap1.EditOverlay); } } } //Adding a new icon. else if (e.Button == MouseButtons.Left) { Feature carFeature = new Feature(clickedPointShape); carFeature.ColumnValues["Type"] = "Unknown"; //We use DateTime.Now.Ticks to be sure to use a unique key each time we add a new feature. winformsMap1.EditOverlay.EditShapesLayer.InternalFeatures.Add(DateTime.Now.Ticks.ToString(), carFeature); //We call CalculateAllControlPoints to update the control points with the new feature to be able to drag the newly added feature. winformsMap1.EditOverlay.CalculateAllControlPoints(); winformsMap1.Refresh(winformsMap1.EditOverlay); } }
private void ShowCoordinate(MouseEventArgs e) { PointShape WorldPointR = ExtentHelper.ToWorldCoordinate(winformsMap1.CurrentExtent, e.X, e.Y, winformsMap1.Width, winformsMap1.Height); statusStrip.Items[1].Text = string.Format(CultureInfo.InvariantCulture, "X: {0:F4} Y: {1:F4}", WorldPointR.X, WorldPointR.Y); statusStrip.Items[2].Text = string.Format(CultureInfo.InvariantCulture, "X: {0} Y: {1}", e.X, e.Y); if (winformsMap1.MapUnit == GeographyUnit.DecimalDegree && ((WorldPointR.X > -180 && WorldPointR.X < 180 && WorldPointR.Y > -90 && WorldPointR.Y < 90))) { statusStrip.Items[0].Text = DecimalDegreesHelper.GetDegreesMinutesSecondsStringFromDecimalDegreePoint(WorldPointR); return; } statusStrip.Items[0].Text = ""; }
private void Map_MouseMove(object sender, MouseEventArgs e) { PointShape mouseLocation = ExtentHelper.ToWorldCoordinate(map.CurrentExtent, new ScreenPointF(e.X, e.Y), map.Width, map.Height); lblLocationX.Text = string.Format(CultureInfo.InvariantCulture, "X:{0:N6}", mouseLocation.X); lblLocationY.Text = string.Format(CultureInfo.InvariantCulture, "Y:{0:N6}", mouseLocation.Y); stpFooter.Refresh(); if (!currentFeatureLayer.IsOpen) { return; } HighlightOverlay USDemographicOverlay = (HighlightOverlay)map.Overlays["HighlightOverlayKey"]; USDemographicOverlay.UpdateHighlightFeature(currentFeatureLayer, mouseLocation); // Here we get tootip for the highlighted feature. bool mapNeedsUpdate = USDemographicOverlay.HighlightFeature != null && (PreviousHighlightFeature == null || (PreviousHighlightFeature != null && PreviousHighlightFeature.Id != USDemographicOverlay.HighlightFeature.Id)); if (mapNeedsUpdate) { toolTip1.Hide(map); toolTip1.Dispose(); string resultText = string.Empty; foreach (string item in currentStyleBuilder.SelectedColumns) { string columnName = TextFormatter.GetFormatedString(item, double.Parse(USDemographicOverlay.HighlightFeature.ColumnValues[item])); resultText = string.Format("{0}{1}\n", resultText, columnName); } toolTip1 = new ToolTip(); toolTip1.InitialDelay = 1000; toolTip1.SetToolTip(map, resultText); map.Refresh(USDemographicOverlay); } else if (USDemographicOverlay.HighlightFeature == null) { toolTip1.Hide(map); toolTip1.Dispose(); } PreviousHighlightFeature = USDemographicOverlay.HighlightFeature; }
private void AppendCoordinates(IEnumerable <ScreenPointF> screenPoints, float xOffset, float yOffset, StringBuilder contentStringBuilder) { contentStringBuilder.AppendLine(@"<coordinates>"); List <ScreenPointF> points = screenPoints.ToList(); //in order to create a KML file that's NOT too big, we simplify and add less points. int simplificationLevel = points.Count / 1000; simplificationLevel = (simplificationLevel == 0 ? 1 : simplificationLevel); int i = 0; while (i < points.Count()) { PointShape pointShape = ExtentHelper.ToWorldCoordinate(_virtualWorldExtent, points[i].X + xOffset, points[i].Y + yOffset, VirtualMapWidth, VirtualMapHeight); contentStringBuilder.AppendFormat(" {0},{1},{2} ", pointShape.X, pointShape.Y, 500); i += simplificationLevel; } contentStringBuilder.AppendLine(@"</coordinates>"); }
private void winformsMap1_MouseMove(object sender, MouseEventArgs e) { //Displays the X and Y in screen coordinates. statusStrip1.Items["toolStripStatusLabelScreen"].Text = "X:" + e.X + " Y:" + e.Y; //Gets the PointShape in world coordinates from screen coordinates. PointShape pointShape = ExtentHelper.ToWorldCoordinate(winformsMap1.CurrentExtent, new ScreenPointF(e.X, e.Y), winformsMap1.Width, winformsMap1.Height); Proj4Projection proj4 = new Proj4Projection(); proj4.InternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString(); proj4.ExternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326); proj4.Open(); PointShape projPointShape = (PointShape)proj4.ConvertToExternalProjection(pointShape); proj4.Close(); //Displays world coordinates in decimal degrees from the OSM Mercator projection statusStrip1.Items["toolStripStatusLabelWorld"].Text = "(world) X:" + Math.Round(projPointShape.X, 4) + " Y:" + Math.Round(projPointShape.Y, 4); }
private void ConvertTextToAnnotation(string valueStyleMatchColumnName, TextStyle textStyle, Feature feature, string annotationText) { PlatformGeoCanvas canvas = new PlatformGeoCanvas { CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighSpeed, DrawingQuality = DrawingQuality.HighSpeed, SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighSpeed }; double width = GisEditor.ActiveMap.ActualWidth; double height = GisEditor.ActiveMap.ActualHeight; Bitmap nativeImage = new Bitmap((int)width, (int)height); canvas.BeginDrawing(nativeImage, GisEditor.ActiveMap.CurrentExtent, GisEditor.ActiveMap.MapUnit); DrawingRectangleF rectangle = canvas.MeasureText(annotationText, textStyle.Font); Type type = textStyle.GetType(); MethodInfo method = type.GetMethod("GetLabelingCandidates", BindingFlags.Instance | BindingFlags.NonPublic); if (method != null) { Collection <LabelingCandidate> candidates = method.Invoke(textStyle, new object[] { feature, canvas }) as Collection <LabelingCandidate>; if (candidates != null) { foreach (var candidate in candidates) { foreach (var labelInfo in candidate.LabelInformation) { ScreenPointF point = new ScreenPointF((float)labelInfo.PositionInScreenCoordinates.X + rectangle.Width / 2 + 3, (float)labelInfo.PositionInScreenCoordinates.Y - rectangle.Height / 2); PointShape pointShape = ExtentHelper.ToWorldCoordinate(GisEditor.ActiveMap.CurrentExtent, point, (float)width, (float)height); Feature pointFeature = new Feature(pointShape); pointFeature.Id = pointShape.Id; pointFeature.ColumnValues[AnnotationTrackInteractiveOverlay.valueStyleMatchColumnName] = valueStyleMatchColumnName; pointFeature.ColumnValues[AnnotationTrackInteractiveOverlay.AnnotationTextColumnName] = annotationText; CurrentAnnotationOverlay.TrackShapeLayer.InternalFeatures[pointShape.Id] = pointFeature; } } } } }
private void winformsMap1_MouseMove(object sender, MouseEventArgs e) { if (isDrawing) { LayerOverlay lineOverlay = (LayerOverlay)winformsMap1.Overlays["LineOverlay"]; InMemoryFeatureLayer shapeLayer = (InMemoryFeatureLayer)lineOverlay.Layers["Shape"]; InMemoryFeatureLayer shadowLayer = (InMemoryFeatureLayer)lineOverlay.Layers["Shadow"]; try { shapeLayer.InternalFeatures.Clear(); shadowLayer.InternalFeatures.Clear(); Point screenPointEnd = e.Location; RectangleShape extent = winformsMap1.CurrentExtent; ScreenPointF currentPoint = new ScreenPointF(screenPointEnd.X, screenPointEnd.Y); PointShape endPoint = ExtentHelper.ToWorldCoordinate(extent, currentPoint, winformsMap1.Width, winformsMap1.Height); shapeLayer.InternalFeatures.Add(new Feature(startPoint)); shapeLayer.InternalFeatures.Add(new Feature(endPoint)); MultilineShape line = startPoint.GetShortestLineTo(endPoint, GeographyUnit.DecimalDegree); if (line != null) { shapeLayer.InternalFeatures.Add(new Feature(line)); LineShape shadow = new LineShape(new Collection <Vertex>() { new Vertex(startPoint.X, startPoint.Y), new Vertex(endPoint.X, endPoint.Y) }); shadowLayer.InternalFeatures.Add(new Feature(shadow)); } label2.Text = startPoint.GetDistanceTo(endPoint, GeographyUnit.DecimalDegree, DistanceUnit.Kilometer).ToString("N2") + " km."; winformsMap1.Refresh(); } catch { return; } } }
//Displays the world coordinates for the mouse pointer in decimal degrees and Degrees Minutes Seconds form. private void winformsMap1_MouseMove(object sender, MouseEventArgs e) { PointShape worldPointShape = ExtentHelper.ToWorldCoordinate(winformsMap1.CurrentExtent, new ScreenPointF(e.X, e.Y), winformsMap1.Width, winformsMap1.Height); try { lblLongitudeDMS.Text = DecimalDegreesHelper.GetDegreesMinutesSecondsStringFromDecimalDegree(worldPointShape.X); lblLatitudeDMS.Text = DecimalDegreesHelper.GetDegreesMinutesSecondsStringFromDecimalDegree(worldPointShape.Y); lblLongitude.Text = System.Convert.ToString(worldPointShape.X); lblLatitude.Text = System.Convert.ToString(worldPointShape.Y); } catch { lblLongitudeDMS.Text = "N/A"; lblLatitudeDMS.Text = "N/A"; lblLongitude.Text = "N/A"; lblLatitude.Text = "N/A"; } finally { } }
private void winformsMap1_MouseClick(object sender, MouseEventArgs e) { LayerOverlay lineOverlay = (LayerOverlay)winformsMap1.Overlays["LineOverlay"]; InMemoryFeatureLayer shapeLayer = (InMemoryFeatureLayer)lineOverlay.Layers["Shape"]; InMemoryFeatureLayer shadowLayer = (InMemoryFeatureLayer)lineOverlay.Layers["Shadow"]; if (isDrawing) { isDrawing = false; } else { Point screenPointStart = e.Location; RectangleShape extent = winformsMap1.CurrentExtent; ScreenPointF currentPoint = new ScreenPointF(screenPointStart.X, screenPointStart.Y); startPoint = ExtentHelper.ToWorldCoordinate(extent, currentPoint, winformsMap1.Width, winformsMap1.Height); label2.Text = ""; shapeLayer.InternalFeatures.Clear(); shadowLayer.InternalFeatures.Clear(); shapeLayer.InternalFeatures.Add(new Feature(startPoint)); isDrawing = true; } }
protected override void DrawSampleCore(GeoCanvas canvas, DrawingRectangleF drawingExtent) { base.DrawSampleCore(canvas, drawingExtent); PointShape upperLeftPoint = ExtentHelper.ToWorldCoordinate(canvas.CurrentWorldExtent, drawingExtent.CenterX - drawingExtent.Width / 2, drawingExtent.CenterY - drawingExtent.Height / 2, canvas.Width, canvas.Height); PointShape lowerRightPoint = ExtentHelper.ToWorldCoordinate(canvas.CurrentWorldExtent, drawingExtent.CenterX + drawingExtent.Width / 2, drawingExtent.CenterY + drawingExtent.Height / 2, canvas.Width, canvas.Height); RectangleShape rectangle = new RectangleShape(upperLeftPoint, lowerRightPoint); rectangle.ScaleDown(10); // Here draw the points on Legend Image Random random = new Random(DateTime.Now.Millisecond); Collection <BaseShape> drawingPoints = new Collection <BaseShape>(); for (int i = 0; i < DrawingPointsNumber; i++) { double x = rectangle.LowerLeftPoint.X + random.NextDouble() * (rectangle.Width); double y = rectangle.LowerLeftPoint.Y + random.NextDouble() * (rectangle.Height); drawingPoints.Add(new PointShape(x, y)); } TextStyle textStyle = new TextStyle(DrawingPointsNumber.ToString(), new GeoFont("Arial", 20, DrawingFontStyles.Bold), new GeoSolidBrush(GeoColor.FromArgb(180, GeoColor.FromHtml("#d3d3d3")))); textStyle.DrawSample(canvas, drawingExtent); CustomPointStyle.Draw(drawingPoints, canvas, new Collection <SimpleCandidate>(), new Collection <SimpleCandidate>()); }
private void wpfMap1_MouseMove(object sender, MouseEventArgs e) { //Logic for Highlighting mousePosition = wpfMap1.ToWorldCoordinate(e.GetPosition(wpfMap1)); if (highlightTimer != null) { highlightTimer.Stop(); } highlightTimer = new DispatcherTimer(); highlightTimer.Interval = new TimeSpan(1000000); highlightTimer.Tick += new System.EventHandler(timer_Tick); highlightTimer.Start(); //Gets the PointShape in world coordinates from screen coordinates. Point point = e.MouseDevice.GetPosition(null); ScreenPointF screenPointF = new ScreenPointF((float)point.X, (float)point.Y); PointShape pointShape = ExtentHelper.ToWorldCoordinate(wpfMap1.CurrentExtent, screenPointF, (float)wpfMap1.Width, (float)wpfMap1.Height); textBox1.Text = $"X: {pointShape.X} Y: {pointShape.Y}"; }
private void winformsMap1_MouseMove(object sender, MouseEventArgs e) { InMemoryFeatureLayer inMemoryLayer = (InMemoryFeatureLayer)((LayerOverlay)winformsMap1.Overlays["RoutingOverlay"]).Layers["RoutingLayer"]; InMemoryFeatureLayer mouseMoveLayer = (InMemoryFeatureLayer)((LayerOverlay)winformsMap1.Overlays["MouseMoveOverlay"]).Layers["MouseMoveLayer"]; //winformsMap1.Overlays["MouseMoveOverlay"].Lock.EnterWriteLock(); //try //{ mouseMoveLayer.InternalFeatures.Clear(); //} //finally //{ // winformsMap1.Overlays["MouseMoveOverlay"].Lock.ExitWriteLock(); //} winformsMap1.Overlays["MouseMoveOverlay"].Lock.IsDirty = true; if (isPointSelected) { timer.Stop(); InMemoryFeatureLayer stopLayer = (InMemoryFeatureLayer)((LayerOverlay)winformsMap1.Overlays["StopOverlay"]).Layers["StopLayer"]; PointShape currentShape = ExtentHelper.ToWorldCoordinate(winformsMap1.CurrentExtent, ((MouseEventArgs)e).X, ((MouseEventArgs)e).Y, winformsMap1.Width, winformsMap1.Height); // Find the routeSegment which is nearest to the current mouse position FeatureLayer austinstreetsLayer = winformsMap1.FindFeatureLayer("AustinstreetsLayer"); austinstreetsLayer.Open(); Collection <Feature> tempFeatures = austinstreetsLayer.QueryTools.GetFeaturesNearestTo(currentShape, GeographyUnit.DecimalDegree, 1, new string[] { }); Feature stopRoad = tempFeatures[0]; austinstreetsLayer.Close(); Feature stopPoint = new Feature(stopRoad.GetShape().GetCenterPoint().GetWellKnownBinary(), stopRoad.Id); //winformsMap1.Overlays["StopOverlay"].Lock.EnterWriteLock(); //try //{ stopLayer.InternalFeatures[currentStopId] = stopPoint; //} //finally //{ // winformsMap1.Overlays["StopOverlay"].Lock.ExitWriteLock(); //} winformsMap1.Overlays["StopOverlay"].Lock.IsDirty = true; } else { if (string.IsNullOrEmpty(currentStopId)) { PointShape targetPointShape = ExtentHelper.ToWorldCoordinate(winformsMap1.CurrentExtent, e.X, e.Y, winformsMap1.Width, winformsMap1.Height); double searchingTolerance = GetControlPointOffsetRadius(winformsMap1.Width, winformsMap1.CurrentExtent.Width, 10); RectangleShape searchingArea = new RectangleShape(targetPointShape.X - searchingTolerance, targetPointShape.Y + searchingTolerance, targetPointShape.X + searchingTolerance, targetPointShape.Y - searchingTolerance); inMemoryLayer.Open(); Collection <Feature> features = inMemoryLayer.FeatureSource.GetAllFeatures(ReturningColumnsType.NoColumns); inMemoryLayer.Close(); foreach (Feature item in features) { Collection <LineShape> lines = ConvertLineBaseShapeToLines((LineBaseShape)item.GetShape()); Feature feature = GetPointFromLines(lines, targetPointShape, searchingArea); if (!string.IsNullOrEmpty(feature.Id)) { //winformsMap1.Overlays["MouseMoveOverlay"].Lock.EnterWriteLock(); //try //{ mouseMoveLayer.InternalFeatures.Add(feature); //} //finally //{ // winformsMap1.Overlays["MouseMoveOverlay"].Lock.ExitWriteLock(); //} winformsMap1.Overlays["MouseMoveOverlay"].Lock.IsDirty = true; winformsMap1.Refresh(); break; } } } } winformsMap1.Refresh(); timer.Start(); }
private void AndroidMap_MapDoubleTap(object sender, Android.Views.MotionEvent e) { androidMap.TrackOverlay.TrackShapeLayer.InternalFeatures.Clear(); // necessary to reset the search selection androidMap.EditOverlay.EditShapesLayer.InternalFeatures.Clear(); // necessary to reset the search selection PointF location = new PointF(e.GetX(), e.GetY()); PointShape position = ExtentHelper.ToWorldCoordinate(androidMap.CurrentExtent, location.X, location.Y, androidMap.Width, androidMap.Height); var inputDialog = new AlertDialog.Builder(this); inputDialog.SetTitle("Choose Action"); inputDialog.SetPositiveButton( "Get LR No.", (see, ess) => { try { LayerOverlay highlightOverlay = (LayerOverlay)androidMap.Overlays["cadastral"]; FeatureLayer highlightLayer = (FeatureLayer)highlightOverlay.Layers["Cadastral"]; highlightLayer.Open(); Collection <Feature> selectedFeatures = highlightLayer.QueryTools.GetFeaturesContaining(position, new string[1] { "Plotno_1" }); highlightLayer.Close(); if (selectedFeatures.Count > 0) { string p = null; foreach (var v in selectedFeatures) { p = v.ColumnValues["Plotno_1"].ToString(); } var uri = Android.Net.Uri.Parse("http://40.68.99.44/GeoManagerField/pages/valuationform.aspx?lrno=" + p); var intent = new Intent(Intent.ActionView, uri); StartActivity(intent); } } catch (Exception ex) { // do nothing } }); inputDialog.SetNegativeButton("Get Building No.", (afk, kfa) => { try { LayerOverlay highlightOverlay = (LayerOverlay)androidMap.Overlays["building"]; FeatureLayer highlightLayer = (FeatureLayer)highlightOverlay.Layers["Building"]; highlightLayer.Open(); Collection <Feature> selectedFeatures = highlightLayer.QueryTools.GetFeaturesContaining(position, new string[1] { "BLD_NO" }); highlightLayer.Close(); if (selectedFeatures.Count > 0) { string p = null; foreach (var v in selectedFeatures) { p = v.ColumnValues["BLD_NO"].ToString(); } var uri = Android.Net.Uri.Parse("http://40.68.99.44/GeoManagerField/pages/buildingform.aspx?bldno=" + p); var intent = new Intent(Intent.ActionView, uri); StartActivity(intent); } } catch (Exception ex) { //do nothing } }); inputDialog.Show(); }