public double getDistance(PointLatLng p1, PointLatLng p2) { GMapRoute route = new GMapRoute("getDistance"); route.Points.Add(p1); route.Points.Add(p2); double distance = route.Distance; route.Clear(); route = null; return distance; }
public GMapMarkerTarget(PointLatLng p, GMapControl map, Bitmap icon) : base(p) { Size = SizeSt; MainMap = map; this.icon = icon; }
private void addPIN(PointLatLng point) { GMapOverlay markersOverlay = new GMapOverlay(gmap, "marker"); this.marker = new GMapMarkerGoogleRed(point); markersOverlay.Markers.Add(marker); gmap.Overlays.Add(markersOverlay); marker.ToolTipText = this.article.mLink; marker.ToolTipMode = MarkerTooltipMode.Never; }
public GMapMarkerBDZ(PointLatLng p) : base(p) { Size = SizeSt = new Size(20, 20); Offset = new Point(-10, -10); Text = string.Empty; mFont = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Bold); }
public GMapMarkerImage(GMap.NET.PointLatLng p, Image image) : base(p) { Size = new System.Drawing.Size(image.Width, image.Height); Offset = new System.Drawing.Point(-Size.Width / 2, -Size.Height / 2); this.image = image; }
public FeedMarker(PointLatLng loc, Article art, GMapControl gmap) { location = loc; article = art; this.gmap = gmap; addPIN(location); }
public GMapCustomImageMarkerYellow(PointLatLng p) : base(p) { image = Image.FromFile("img/point_y.png"); Size = new System.Drawing.Size(image.Width, image.Height); Offset = new Point( - (image.Width / 2), - (image.Height / 2)); }
public GMapMarkerBYQ(PointLatLng p) : base(p) { Size=SizeSt = new Size(15, 10); Offset = new Point(-7, -5); Text = string.Empty; mFont = new Font(FontFamily.GenericSansSerif, 8, FontStyle.Bold); }
public static GMapMarker FindNearestMarker(this Collection<GMapMarker> source, PointLatLng point, Func<PointLatLng, PointLatLng, double> getDistance) { GMapMarker nearestMarker = null; double smallestDistance = double.PositiveInfinity; foreach (var marker in source) { if (marker.Position != point) { var distance = getDistance(marker.Position, point); if (distance < smallestDistance) { smallestDistance = distance; nearestMarker = marker; } } } if(double.IsPositiveInfinity(smallestDistance)) { return null; } else { return nearestMarker; } }
public GMapMarkerGzbx(PointLatLng p) : base(p) { Image = Resources.marker; ImageShadow = Resources.shadow50; Size = SizeSt = new Size(Image.Width, Image.Height); Offset = new Point(-10, -34); }
public GMapMarkerRect(PointLatLng p) : base(p) { Pen.DashStyle = DashStyle.Dot; Size = new System.Drawing.Size(50, 50); Offset = new System.Drawing.Point(-Size.Width / 2, -Size.Height / 2 - 20); }
/// <summary> /// Constructor /// </summary> /// <param name="p">The position of the marker</param> public CustomMarker(PointLatLng p, Image image) : base(p) { img = image; Size = img.Size; Offset = new System.Drawing.Point(-Size.Width / 2, -Size.Height / 2); }
private void button1_Click_1(object sender, EventArgs e) { double lat1 = Double.Parse(textBox_latitude1.Text); double lon1 = Double.Parse(textBox_longitude1.Text); double lat2 = Double.Parse(textBox_latitude2.Text); double lon2 = Double.Parse(textBox_longitude2.Text); double lat3 = Double.Parse(textBox_latitude3.Text); double lon3 = Double.Parse(textBox_longitude3.Text); double lat4 = Double.Parse(textBox_latitude4.Text); double lon4 = Double.Parse(textBox_longitude4.Text); PointLatLng p1 = new PointLatLng(lat1, lon1); PointLatLng p2 = new PointLatLng(lat2, lon2); PointLatLng p3 = new PointLatLng(lat3, lon3); PointLatLng p4 = new PointLatLng(lat4, lon4); FlightPlanner.instance.polygongridmode = true; FlightPlanner.instance.drawnpolygon.Points.Add(p1); FlightPlanner.instance.drawnpolygon.Points.Add(p2); FlightPlanner.instance.drawnpolygon.Points.Add(p3); FlightPlanner.instance.drawnpolygon.Points.Add(p4); FlightPlanner.instance.drawnpolygonsoverlay.Polygons.Add(FlightPlanner.instance.drawnpolygon); /*List<PointLatLng> points = new List<PointLatLng>(); PointLatLng p1 = new PointLatLng(lat1, lon1); PointLatLng p2 = new PointLatLng(lat2, lon2); PointLatLng p3 = new PointLatLng(lat3, lon3); PointLatLng p4 = new PointLatLng(lat4, lon4); points.Add(p1); points.Add(p2); points.Add(p3); points.Add(p4); GMap.NET.WindowsForms.GMapPolygon test = new GMap.NET.WindowsForms.GMapPolygon(points, "yolo"); test.IsVisible = true;*/ }
private Image img; /// <summary> #endregion Fields #region Constructors /// <summary> /// Constructor /// </summary> /// <param name="p">The position of the marker</param> public GMapMarkerImage(PointLatLng p, Image image) : base(p) { img = image; Size = img.Size; Offset = new System.Drawing.Point(-Size.Width, Size.Height / 7); }
public void Build_Prediction_Marker(PointLatLng Base_Position, string ACID, MySqlProvider.PredictionTableNumberType Table_Type, ref GMapOverlay Overlay) { MySqlProvider SqlProvider = new MySqlProvider(); System.Collections.Generic.List<MySqlProvider.PredictionDataSetOneRow> Record = SqlProvider.GetOneRecordPerTimeAndACID(Table_Type, SharedData.LookAheadTime, ACID, false); // If prediction data for the given parameters exists // then lets add it to the display list. if (Record.Count > 0) { GeoCordSystemDegMinSecUtilities.LatLongClass P_Pont = new GeoCordSystemDegMinSecUtilities.LatLongClass(double.Parse(Record[0].Lat), double.Parse(Record[0].Lon)); PointLatLng PredictedPoint = new PointLatLng(P_Pont.GetLatLongDecimal().LatitudeDecimal, P_Pont.GetLatLongDecimal().LongitudeDecimal); PredictionMarker PM; string label = Record[0].ACID + "\n" + Record[0].Time.ToShortTimeString(); switch (Table_Type) { case MySqlProvider.PredictionTableNumberType.One: PM = new PredictionMarker(Base_Position, Color.Magenta, PredictedPoint, label); Overlay.Markers.Add(PM); break; case MySqlProvider.PredictionTableNumberType.Two: PM = new PredictionMarker(Base_Position, Color.Blue, PredictedPoint, label); Overlay.Markers.Add(PM); break; case MySqlProvider.PredictionTableNumberType.Three: PM = new PredictionMarker(Base_Position, Color.Orange, PredictedPoint, label); Overlay.Markers.Add(PM); break; } } }
public void MapFieldBoundaries(double lat, double lng) { //--- Check if this is the First point of a new Area if (View.CreateIsNewField) { CurrentFieldPoints = new List <PointLatLng>(); View.CreateIsNewField = false; } CurrentFieldPoints.Add(new PointLatLng(lat, lng)); var closedList = CurrentFieldPoints; closedList.Add(new PointLatLng(CurrentFieldPoints[0].Lat, CurrentFieldPoints[0].Lng)); var polygon = new GMapPolygon(closedList, "New Field"); Polygons.Polygons.Add(polygon); closedList.RemoveAt(closedList.Count - 1); var pnt = new GMap.NET.PointLatLng(lat, lng); var marker = new GMap.NET.WindowsForms.Markers.GMarkerGoogle(pnt, GMap.NET.WindowsForms.Markers.GMarkerGoogleType.green_dot); PushPins.Markers.Add(marker); var grid = View.CurrentWorkspace.CurrentDefineView.GridLatLongPoints; grid.Rows.Add(grid.RowCount + 1, lat, lng); //polygons.Polygons.Add(polygon); //gmap.Overlays.Add(polygons); }
public RectLatLng(PointLatLng location, SizeLatLng size) { this.lng = location.Lng; this.lat = location.Lat; this.widthLng = size.WidthLng; this.heightLat = size.HeightLat; }
/// <summary> /// 创建线路杆塔点标记 /// </summary> /// <param name="LineCode"></param> /// <returns></returns> static public List<GMapMarkerVector> BuildLineGT(string LineCode, string LineName) { IList<PS_gt> list = Client.ClientHelper.PlatformSqlMap.GetList<PS_gt>(string.Format("where Linecode='{0}' order by gtcode", LineCode)); List<GMapMarkerVector> markers = new List<GMapMarkerVector>(); GMapMarkerVector marker = null; GMapMarkerVector preMarker = null; foreach (PS_gt gt in list) { PointF pf = new PointF((float)gt.gtLon, (float)gt.gtLat); if (box.Contains(pf)) { PointLatLng point = new PointLatLng(Convert.ToDouble(gt.gtLat), Convert.ToDouble(gt.gtLon)); if (gt.gtType.Contains("方杆")) marker = new GMapMarkerRect(point); else marker = new GMapMarkerVector(point); if (preMarker != null) { marker.ParentMarker = preMarker; preMarker.NextMarker = marker; } preMarker = marker; marker.ToolTipText = gt.gth + "\n" + LineName; marker.Tag = gt; markers.Add(marker); } } return markers; }
/// <summary> /// Creates the map marker and adds it to the map /// </summary> public void CreateMapMarker(PointLatLng point, string tooltip) { GMarkerGoogle marker = new GMarkerGoogle(point, GMarkerGoogleType.red); marker.ToolTipText = tooltip; gmap.Overlays[0].Markers.Add(marker); gmap.UpdateMarkerLocalPosition(marker); }
public CustomMarker(GMap.NET.PointLatLng p, int id, Int64 colorGround = 0xFF006400, Int64 colorId = 0xFFFFFFFF) : base(p) { brushGround = new SolidBrush(Color.FromArgb((int)((colorGround >> 24) & 0xFF), (int)((colorGround >> 16) & 0xFF), (int)((colorGround >> 8) & 0xFF), (int)(colorGround & 0xFF))); brushId = new SolidBrush(Color.FromArgb((int)(colorId >> 24), (int)((colorId >> 16) & 0xFF), (int)((colorId >> 8) & 0xFF), (int)(colorId & 0xFF))); ID = id; Size = new System.Drawing.Size(20, 20); //标记绘制区域的大小 Offset = new System.Drawing.Point(-10, -10); //标记矩形左上角与指定点的偏移 }
public GMapTextMarker(GMap.NET.PointLatLng p, string tipText) : base(p) { //Size = new System.Drawing.Size(image.Width, image.Height); //Offset = new System.Drawing.Point(-st/2, 0); TipText = tipText; }
public GMapMarkerVector(PointLatLng p) : base(p) { Size = SizeSt; Offset = new Point(-2, -2); Pen = new Pen(Color.Blue, 1); items = new List<GMapMarkerVector>(); font = new Font("宋体", 9); }
public GMapMarkerKG(PointLatLng p) : base(p) { Size = SizeSt = new Size(8, 6); Offset = new Point(-4, -3); Text = string.Empty; mFont = new Font(FontFamily.GenericSansSerif, 8, FontStyle.Bold); Pen = new Pen(Color.Red, 2); }
public void update(PointLatLng point) { if (tag.Equals("")) polygon.Points[int.Parse(host.CurentRectMarker.InnerMarker.Tag.ToString().Replace("grid", "")) - 1] = new PointLatLng(point.Lat, point.Lng); else polygon.Points[int.Parse(host.CurentRectMarker.InnerMarker.Tag.ToString().Replace(tag, "").Replace("grid", "")) - 1] = new PointLatLng(point.Lat, point.Lng); host.MainMap.UpdatePolygonLocalPosition(polygon); }
public void AddToLogCurrentInfo(PointLatLng data) { gpsLog[logCounter++] = data; if (logCounter == logSize) { logCounter = 0; logFull = true; } }
public GMapMarkerCopter(PointLatLng p, float heading, float cog, float target, byte coptertype) : base(p) { this.heading = heading; this.cog = cog; this.target = target; this.coptertype = coptertype; Size = SizeSt; }
public void ConvertCoordGroundToPixel(double GroundX, double GroundY, ref int PixelX, ref int PixelY) { GMap.NET.PointLatLng Position = new GMap.NET.PointLatLng(); Position.Lat = GroundY; Position.Lng = GroundX; GMap.NET.GPoint p = MyMainMap.FromLatLngToLocal(Position); PixelX = (int)p.X; PixelY = (int)p.Y; }
public GMapTipMarker(GMap.NET.PointLatLng p, Image image, string tipText) : base(p) { Size = new System.Drawing.Size(image.Width, image.Height); Offset = new System.Drawing.Point(-Size.Width / 2, -Size.Height / 2); this.image = image; HighlightPen = new System.Drawing.Pen(Brushes.Red, 2); TipText = tipText; }
/// <summary> /// get pixel coordinates from lat/lng /// </summary> /// <param name="p"></param> /// <param name="zoom"></param> /// <returns></returns> public Point FromLatLngToPixel(PointLatLng p, int zoom) { Point ret = Point.Empty; if(!FromLatLngToPixelCache[zoom].TryGetValue(p, out ret)) { ret = FromLatLngToPixel(p.Lat, p.Lng, zoom); FromLatLngToPixelCache[zoom].Add(p, ret); } return ret; }
public GMapMarkerRect(PointLatLng p) : base(p) { Pen.DashStyle = DashStyle.Dash; // do not forget set Size of the marker // if so, you shall have no event on it ;} Size = new System.Drawing.Size(50, 50); Offset = new System.Drawing.Point(-Size.Width/2, -Size.Height/2 - 20); }
public GMapMarkerRect(PointLatLng p) : base(p) { Pen = new Pen(Brushes.Blue, 5); // do not forget set Size of the marker // if so, you shall have no event on it ;} Size = new System.Drawing.Size(80, 80); Offset = new System.Drawing.Point(-Size.Width / 2, -Size.Height / 2); }
public static void AddDefaultGoogleMarker(this Collection<GMapMarker> source, PointLatLng? point, GMarkerGoogleType style, object tag = null) { if (point != null) { GMarkerGoogle m = new GMarkerGoogle((PointLatLng)point, style); m.ToolTip = new GMapRoundedToolTip(m); m.ToolTipMode = MarkerTooltipMode.OnMouseOver; m.Tag = tag; source.Add(m); } }
//GMapMarker createMarker(PointLatLng pos) { // GMapMarkerVector marker = new GMapMarkerVector(pos); // marker.Pen = new Pen(Color.FromArgb(144, Color.GreenYellow), 2); // marker.IsHitTestVisible = false; // marker.ToolTipMode = MarkerTooltipMode.OnMouseOver; // return marker; //} GMapMarker createMarker(PointLatLng pos) { GMapMarkerVector marker = new GMapMarkerVector(pos); marker.Pen = new Pen(Color.FromArgb(144, Color.MidnightBlue), 2); marker.IsHitTestVisible = false; marker.ToolTipMode = MarkerTooltipMode.OnMouseOver; routes.Markers.Add(marker); if (routes.Markers.Count > 1) marker.ToolTipText = routes.Routes[0].Distance + "";// rMap1.Manager.GetDistance(pos, objects.Markers[objects.Markers.Count - 1].Position) + ""; return marker; }
public GMapMarkerImage(GMap.NET.PointLatLng p, Image image) : base(p) { Size = new System.Drawing.Size(image.Width, image.Height); Offset = new System.Drawing.Point(-Size.Width / 2, -Size.Height / 2); this.image = image; Pen = null; OutPen = null; //this.ToolTipMode = MarkerTooltipMode.OnMouseOver; this.ToolTipText = string.Format("{0}\r\n{1}\r\n{2}\r\n{3}", "CQH8992", "GV:95°", "H:4686m", "S:748km/h"); this.ToolTip.Fill = new SolidBrush(Color.FromArgb(0, 0, 0, 0)); }
GMapMarker createMarker(PointLatLng pos) { GMapMarker marker = null; object newobj= Activator.CreateInstance(NewVectorType); if (newobj is GMapMarker) marker = newobj as GMapMarker; if (marker == null) { marker = new GMapMarkerVector(pos); marker.IsHitTestVisible = false; } marker.ToolTipMode = MarkerTooltipMode.OnMouseOver; return marker; }
private void example1() { GMap.NET.PointLatLng start; GMap.NET.PointLatLng end; //GMap.NET.GDirections gDirections1; GMap.NET.WindowsForms.GMapRoute gMapRoute1; GMap.NET.WindowsForms.GMapOverlay gMapOverlay1; try { // Luis hard-codes an example start- and end-point, // I think I might try to make it dynamic to help me understand it // and give me practice with it. // However at first to get the code running, I'm going to hard-code it. // start = new GMap.NET.PointLatLng(46.299106, -119.295999); end = new GMap.NET.PointLatLng(46.276860, -119.291511); var dirstatcode = GMap.NET.MapProviders.GMapProviders.GoogleMap.GetDirections(out gDirections1, start, end, false, // bool avoidHighways false, // bool avoidTolls false, // bool walking mode false, // bool sensor false // bool metric ); gMapRoute1 = new GMap.NET.WindowsForms.GMapRoute(gDirections1.Route, "foo"); // After trying this, I get an error at the aboe line, saying that gDirections1 was null. // // Try 1 // Changed MapProvider to GoogleMapProvider (was BingMapProvider). // No difference. // // Try 2 // Moved the declaration of "gDirections1" to the entire form. // No difference. gMapOverlay1 = new GMap.NET.WindowsForms.GMapOverlay(); // string param is optional gMapOverlay1.Routes.Add(gMapRoute1); //MainMap.Overlays.Add(gMapOverlay1); this.gMapControl1.Overlays.Add(gMapOverlay1); } catch (Exception ex) { MessageBox.Show("Exception happened, {0}", ex.Message); } }
public static GMap.NET.PointLatLng FindPointAtDistanceFrom(GMap.NET.PointLatLng startPoint, double initialBearingRadians, double distanceKilometres) { const double radiusEarthKilometres = 21000; var distRatio = distanceKilometres / radiusEarthKilometres; var distRatioSine = Math.Sin(distRatio); var distRatioCosine = Math.Cos(distRatio); var startLatRad = DegreesToRadians(startPoint.Lat); var startLonRad = DegreesToRadians(startPoint.Lng); var startLatCos = Math.Cos(startLatRad); var startLatSin = Math.Sin(startLatRad); var endLatRads = Math.Asin((startLatSin * distRatioCosine) + (startLatCos * distRatioSine * Math.Cos(initialBearingRadians))); var endLonRads = startLonRad + Math.Atan2( Math.Sin(initialBearingRadians) * distRatioSine * startLatCos, distRatioCosine - startLatSin * Math.Sin(endLatRads)); return(new GMap.NET.PointLatLng(RadiansToDegrees(endLatRads), RadiansToDegrees(endLonRads))); }
public GMapMarkerImage(GMap.NET.PointLatLng p, Image image) : base(p) { Size = new System.Drawing.Size(50, 50); Offset = new System.Drawing.Point(-Size.Width / 2, -Size.Height / 2); this.image = image; SelectedPen = null; AlarmPen = null; //if (!CenterPoint.IsEmpty) //{ // List<PointLatLng> pointList = new List<PointLatLng>(); // pointList.Add(CenterPoint); // pointList.Add(this.Position); // GMapRoute gmr = new GMapRoute(pointList, "tmp gmr"); // gmr.Stroke = RoutePen; // Overlay.Routes.Add(gmr); //} }
protected override void OnMouseMove(MouseEventArgs e) { if (Core.IsDragging) { if (!isDragging) { isDragging = true; Debug.WriteLine("IsDragging = " + isDragging); } if (BoundsOfMap.HasValue && !BoundsOfMap.Value.Contains(Position)) { // ... } else { Core.mouseCurrent = ApplyRotationInversion(e.X, e.Y); Core.Drag(Core.mouseCurrent); Refresh(); } } else { if (isSelected && !selectionStart.IsEmpty && (Form.ModifierKeys == Keys.Alt || Form.ModifierKeys == Keys.Shift)) { selectionEnd = FromLocalToLatLng(e.X, e.Y); { GMap.NET.PointLatLng p1 = selectionStart; GMap.NET.PointLatLng p2 = selectionEnd; double x1 = Math.Min(p1.Lng, p2.Lng); double y1 = Math.Max(p1.Lat, p2.Lat); double x2 = Math.Max(p1.Lng, p2.Lng); double y2 = Math.Min(p1.Lat, p2.Lat); SelectedArea = new RectLatLng(y1, x1, x2 - x1, y1 - y2); } } } base.OnMouseMove(e); }
private PointLatLng FindPointAtDistanceFrom(GMap.NET.PointLatLng startPoint, double initialBearingRadians, double distanceKilometres) { double radius = 6371.01; var δ = distanceKilometres / radius; // angular distance in radians var θ = DegreesToRadians(initialBearingRadians); var φ1 = DegreesToRadians(startPoint.Lat); var λ1 = DegreesToRadians(startPoint.Lng); var sinφ2 = Math.Sin(φ1) * Math.Cos(δ) + Math.Cos(φ1) * Math.Sin(δ) * Math.Cos(θ); var φ2 = Math.Asin(sinφ2); var y = Math.Sin(θ) * Math.Sin(δ) * Math.Cos(φ1); var x = Math.Cos(δ) - Math.Sin(φ1) * sinφ2; var λ2 = λ1 + Math.Atan2(y, x); var lat = RadiansToDegrees(φ2); var lon = RadiansToDegrees(λ2); return(new PointLatLng(lat, lon)); }
private void SearchLocation_old() { try { string postCode = txtAddress.Text.Trim(); if (string.IsNullOrEmpty(postCode)) { //MessageBox.Show("Please enter a PostCode"); MessageBox.Show("Please enter a Address"); return; } //postCode = General.GetPostCodeMatch(postCode); var latlng = GetDistance.PostCodeToLongLat(postCode, "GB"); if (latlng != null) { GMap.NET.PointLatLng point = new GMap.NET.PointLatLng(latlng.Value.Latitude, latlng.Value.Longitude); gMapControl1.Position = point; GMapOverlay polyOverlay = new GMapOverlay(gMapControl1, "overlayJob"); GMapMarkerCustom marker1 = new GMapMarkerCustom(new PointLatLng(Convert.ToDouble(latlng.Value.Latitude), Convert.ToDouble(latlng.Value.Longitude)), Resources.Resource1.pushpin_PassengerOnBoard); marker1.ToolTipMode = MarkerTooltipMode.Always; marker1.Tag = new PointLatLng(latlng.Value.Latitude, latlng.Value.Longitude); polyOverlay.Markers.Add(marker1); gMapControl1.Overlays.Clear(); gMapControl1.Overlays.Add(polyOverlay); gMapControl1.Zoom = 16; } } catch (Exception ex) { ENUtils.ShowMessage(ex.Message); } }
/// <summary> /// Called on POINTUPDATED_ACK, whenever a point changes /// in some other running client. Updates local points respectively /// </summary> /// <param name="packet"></param> private void OnPointUpdatedAck(PointUpdatedAck packet) { foreach (var polygon in _polygons.Polygons) { if (!(polygon.Tag is PolyZone zone)) { continue; } if (int.Parse(zone.Id) != packet.ZoneId) { continue; } if (packet.Added) { var pointLatLng = new GMap.NET.PointLatLng(packet.Lat, packet.Lng); polygon.Points.Insert(packet.Index, pointLatLng); zone.Geometry.Insert(packet.Index, pointLatLng.ToGeometry(packet.PointId)); } else if (packet.Removed) { polygon.Points.RemoveAt(packet.Index); zone.Geometry.RemoveAt(packet.Index); } else { var i = zone.Geometry.FindIndex(x => x.Id == packet.PointId); var pt = new GMap.NET.PointLatLng(packet.Lat, packet.Lng); polygon.Points[i] = pt; zone.Geometry[i] = pt.ToGeometry(packet.PointId); } UpdatePolygonLocalPosition(polygon); Refresh(); break; } }
public Map() { InitializeComponent(); DisableFocusOnMouseEnter = true; _selectedStrokeClr = new Pen(Brushes.Blue) { Width = 2 }; _selecteFillClr = new SolidBrush(Color.FromArgb(90, Color.Blue)); _isMouseDown = false; IsDrawingPolygon = false; ShowCenter = false; _readOnly = false; _pointer = new GMarkerGoogle(Position, GMarkerGoogleType.arrow) { IsHitTestVisible = false }; _topLayer.Markers.Add(_pointer); var deleteCacheDate = DateTime.Now; deleteCacheDate = deleteCacheDate.AddDays(-10); Manager.PrimaryCache.DeleteOlderThan(deleteCacheDate, null); _centerOfTheMap = new GMap.NET.PointLatLng(47.49801, 19.03991); drawPolygonCtxMenu.Renderer = _tsRenderer; polygonPointCtxMenu.Renderer = _tsRenderer; _isWaitingForResponse = false; Client.Instance.OnPointUpdatedAck += OnPointUpdatedAck; Client.Instance.OnZoneInfoUpdatedAck += OnZoneInfoUpdatedAck; }
private void DisplayLocationByLatLng() { try { GMap.NET.PointLatLng point = new GMap.NET.PointLatLng(this.DefaultLat, this.DefaultLng); gMapControl1.Position = point; GMapOverlay polyOverlay = new GMapOverlay(gMapControl1, "overlayJob"); GMapMarkerCustom marker1 = new GMapMarkerCustom(point, Resources.Resource1.pushpin_PassengerOnBoard); marker1.ToolTipMode = MarkerTooltipMode.Never; marker1.Tag = point; polyOverlay.Markers.Add(marker1); gMapControl1.Overlays.Clear(); gMapControl1.Overlays.Add(polyOverlay); gMapControl1.Zoom = 16; } catch (Exception ex) { ENUtils.ShowMessage(ex.Message); } }
public static PointLatLng Subtract(PointLatLng pt, SizeLatLng sz) { return(new PointLatLng(pt.Lat + sz.HeightLat, pt.Lng - sz.WidthLng)); }
public GMapMarkerTile(PointLatLng p, int size) : base(p) { Size = new System.Drawing.Size(size, size); }
public void Offset(PointLatLng pos) { this.Offset(pos.Lat, pos.Lng); }
/// <summary> /// Gets called when the cursor moves on the map /// </summary> /// <param name="e">Mouse event arguments</param> protected override void OnMouseMove(MouseEventArgs e) { if (!_readOnly) { if (e.Button == MouseButtons.Left) { if (Equals(_currentRectMarker, null)) { _pointer.Position = FromLocalToLatLng(e.X, e.Y); // Handles polygon dragging on the map if (CurrentPolygon != null && CurrentPolygon.IsMouseOver) { for (var i = 0; i < CurrentPolygon.Points.Count; i++) { var pnew = new GMap.NET.PointLatLng( CurrentPolygon.Points[i].Lat + _pointer.Position.Lat - _previousMouseLocation.Lat, CurrentPolygon.Points[i].Lng + _pointer.Position.Lng - _previousMouseLocation.Lng ); CurrentPolygon.Points[i] = pnew; var zone = (PolyZone)CurrentPolygon.Tag; var id = zone.Geometry[i].Id; zone.Geometry[i] = pnew.ToGeometry(id); } UpdatePolygonLocalPosition(CurrentPolygon); } } // Handles dragging a point of a polygon else if (CurrentPolygon != null) { var pnew = FromLocalToLatLng(e.X, e.Y); var pIndex = (int?)_currentRectMarker.Tag; if (pIndex.HasValue && pIndex < CurrentPolygon.Points.Count) { CurrentPolygon.Points[pIndex.Value] = pnew; var zone = (PolyZone)CurrentPolygon.Tag; // TODO: Find a workaround for waiting for a server response in this // non-asynch method. Currently it causes the gui to hang up if (_isWaitingForResponse) { while (_isWaitingForResponse) { Thread.Sleep(300); } } var id = zone.Geometry[pIndex.Value].Id; zone.Geometry[pIndex.Value] = pnew.ToGeometry(id); UpdatePolygonLocalPosition(CurrentPolygon); _pointer.Position = pnew; CurrentPolygon.PointsHasChanged(); _currentRectMarker.Position = pnew; // TODO: Remove real-time update // It is very inefficent //await Task.Run(() => { Sql.Instance.UpdatePoint(zone.Geometry[pIndex.Value]); }); } } } else if (IsDrawingPolygon) { // Handles dragging a point of a NEW polygon on the map _currentNewRectMaker.Position = FromLocalToLatLng(e.X, e.Y); _currentDrawingPolygon.Points[_currentDrawingPolygon.Points.Count - 1] = _currentNewRectMaker.Position; UpdatePolygonLocalPosition(_currentDrawingPolygon); } _previousMouseLocation = FromLocalToLatLng(e.X, e.Y); } else if (e.Button == MouseButtons.Left) { _pointer.Position = FromLocalToLatLng(e.X, e.Y); } base.OnMouseMove(e); }
public GMapMarkerRoute(GMap.NET.PointLatLng p) : base(p) { }
public bool Contains(PointLatLng pt) { return(this.Contains(pt.Lat, pt.Lng)); }
public void addCoords(GMap.NET.PointLatLng latlng) { pp = latlng; }
//------------------HARİTA KONUMUNA GÖRE TEXTBOXLARI DEĞİŞTİR--------------------- private void harita1_OnPositionChanged(GMap.NET.PointLatLng point) { enlemTextBox.Text = harita1.Position.Lat.ToString(); boylamTextBox.Text = harita1.Position.Lng.ToString(); }
/// <summary> /// Sets the pointer to a given position /// </summary> /// <param name="pos"></param> public void SetPointerPosition(GMap.NET.PointLatLng pos) { _pointer.Position = pos; }
public GPoint FromLatLngToPixel(PointLatLng p, int zoom) { return(FromLatLngToPixel(p, zoom, false)); }
/// <summary> /// Drags the center of the map to a given position /// </summary> /// <param name="pos"></param> public void SetMapPosition(GMap.NET.PointLatLng pos) { Position = pos; }
public static PointLatLng Add(PointLatLng pt, SizeLatLng sz) { return(new PointLatLng(pt.Lat - sz.HeightLat, pt.Lng + sz.WidthLng)); }
public PointLatLngAlt(GMap.NET.PointLatLng pll) { this.Lat = pll.Lat; this.Lng = pll.Lng; }
public SizeLatLng(PointLatLng pt) { this.heightLat = pt.Lat; this.widthLng = pt.Lng; }
/// <summary> /// get pixel coordinates from lat/lng /// </summary> /// <param name="p"></param> /// <param name="zoom"></param> /// <returns></returns> public GPoint FromLatLngToPixel(PointLatLng p, int zoom, bool useCache) { if(useCache) { GPoint ret = GPoint.Empty; if(!FromLatLngToPixelCache[zoom].TryGetValue(p, out ret)) { ret = FromLatLngToPixel(p.Lat, p.Lng, zoom); FromLatLngToPixelCache[zoom].Add(p, ret); // for reverse cache if(!FromPixelToLatLngCache[zoom].ContainsKey(ret)) { FromPixelToLatLngCache[zoom].Add(ret, p); } Debug.WriteLine("FromLatLngToPixelCache[" + zoom + "] added " + p + " with " + ret); } return ret; } else { return FromLatLngToPixel(p.Lat, p.Lng, zoom); } }
private PointLatLng getLatLong(PointD i_location) { PointLatLng coordinates; coordinates = new PointLatLng(i_location.X, i_location.Y); return coordinates; }