public void DoCata(object sender, EventArgs e) { ToolStripItem mnu = sender as ToolStripItem; if (mnu != null) { ExploData explo = mnu.Tag as ExploData; Brush brush1 = new SolidBrush(explo.color); Pen pen1 = new Pen(explo.color, 2); GMapOverlay overlay = _Daddy._cacheDetail._gmap.Overlays[GMapWrapper.RESERVED2]; overlay.IsVisibile = true; _Daddy.ClearOverlay_RESERVED2(); GMapMarkerCircle circle; PointLatLng center = _Daddy._cacheDetail._gmap.Position; circle = new GMapMarkerCircle( _Daddy._cacheDetail._gmap, center, (int)(explo.radius * 1000.0), pen1, brush1, true); overlay.Markers.Add(circle); _Daddy._cacheDetail._gmap.Refresh(); CustomFilterCata fltr = new CustomFilterCata(explo.radius, center); _Daddy.ExecuteCustomFilterSilent(fltr, true); _Daddy._cacheDetail._gmap.Position = center; } }
private void showAirSpave(GMapOverlay overlay, double lat, double lang, String name) { overlay.Markers.Clear(); // 展示鼠标点击点 if (overlay.Equals(portSelOverlay)) { PointLatLng point1 = new PointLatLng(lat, lang); GMapAirPort airPort = new GMapAirPort(point1, name); overlay.Markers.Add(airPort); gMapControl1.Refresh(); return; } // 根据name获取要展示的空域信息 List <Dictionary <string, object> > result = ProfileHelper.Instance.Select("SELECT * FROM AirSpace WHERE Name = \"" + name + "\""); if (result.Count > 0) { overlay.Clear(); int type = Convert.ToInt16(result[0]["Type"]); if (1 == type) { // 圆形 double t = Convert.ToDouble(result[0]["Lat"]); double g = Convert.ToDouble(result[0]["Lng"]); double radius = Convert.ToDouble(result[0]["Radius"]); PointLatLng point = new PointLatLng(t, g); GMapMarkerCircle gMapMarkerCircle = new GMapMarkerCircle(point, (int)radius); overlay.Markers.Add(gMapMarkerCircle); } if (0 == type) { // 多边形 List <PointLatLng> points = new List <PointLatLng>(); foreach (Dictionary <string, object> dictionary in result) { double t = Convert.ToDouble(dictionary["Lat"]); double g = Convert.ToDouble(dictionary["Lng"]); PointLatLng point = new PointLatLng(t, g); points.Add(point); } GMapPolygon polygon = new GMapPolygon(points, "mypolygon"); polygon.Fill = new SolidBrush(Color.FromArgb(50, Color.Red)); polygon.Stroke = new Pen(Color.Red, 1); overlay.Polygons.Add(polygon); } } gMapControl1.Refresh(); }
private void showLandStation(GMapOverlay overlay, double lat, double lang, String name, int num, double length) { overlay.Markers.Clear(); PointLatLng point1 = new PointLatLng(lat, lang); GMapLandStation landSatsion = new GMapLandStation(point1, name); overlay.Markers.Add(landSatsion); while (num > 0) { GMapMarkerCircle gMapMarkerCircle = new GMapMarkerCircle(point1, (int)length * num); overlay.Markers.Add(gMapMarkerCircle); num--; } gMapControl1.Refresh(); }
public UInt64 添加圆(M经纬度 __圆心, int __半径, Pen __边框画笔, Brush __填充笔刷, bool __允许交互, object __绑定对象 = null, string __图层名称 = null) { if (this.InvokeRequired) { var __信号量 = this.BeginInvoke(new Func <M经纬度, int, Pen, Brush, bool, object, string, UInt64>(添加圆), __圆心, __半径, __边框画笔, __填充笔刷, __允许交互, __绑定对象, __图层名称); __信号量.AsyncWaitHandle.WaitOne(); return((UInt64)this.EndInvoke(__信号量)); } var __图层 = 获取图层(__图层名称); var __覆盖范围 = new GMapMarkerCircle(GPS转换(__圆心), __边框画笔, __填充笔刷, __允许交互) { Radius = __半径, IsFilled = __填充笔刷 != null }; __图层.Markers.Add(__覆盖范围); var __标识 = _所有覆盖物[__图层].标识++; _所有覆盖物[__图层].点集[__标识] = __覆盖范围; return(__标识); }
private void FormMap_Load(object sender, EventArgs e) { menuItemSatellite.Checked = false; this.map.Manager.Mode = AccessMode.ServerOnly; this.map.MapType = MapType.GoogleMap; this.map.MaxZoom = 20; this.map.MinZoom = 1; this.map.Zoom = this.map.MinZoom + 5; // map events map.OnCurrentPositionChanged += new CurrentPositionChanged(Map_OnCurrentPositionChanged); // Overlay setup _overlay = new GMapOverlay(this.map, "_overlay"); this.map.Overlays.Add(_overlay); this.map.CurrentPosition = _startPos; _centerCross = new GMapMarkerCross(this.map.CurrentPosition); _centerCross.Pen.Color = Color.Red; _radiusCircle = new GMapMarkerCircle(_startPos); _radiusCircle.Radius = _StartRadius; _radiusCircle.Fill = false; _radiusCircle.OutlinePen.Width = 2; _radiusCircle.OutlinePen.Color = Color.Red; // Add markers _overlay.Markers.Add(_centerCross); _overlay.Markers.Add(_radiusCircle); if (_hasStartPos) { map.Zoom = 14; } }
/// <summary> /// Callback to display coordinates in the 2 TextBox /// </summary> /// <param name="e">event</param> public void BaseOnMouseClick(MouseEventArgs e) { // Pas de modification, on en profite juste pour coller les coordonnées dans les controles s'ils existent PointLatLng pt = this.FromLocalToLatLng(e.X, e.Y); if (_controlTextLatLon != null) { _controlTextLatLon.Text = pt.Lat.ToString().Replace(",", ".") + " " + pt.Lng.ToString().Replace(",", "."); // On crée un markeur this.Overlays[GMapWrapper.RESERVED2].Markers.Clear(); GMapMarker marker = new GMarkerGoogle(pt, GMarkerGoogleType.red_pushpin); this.Overlays[GMapWrapper.RESERVED2].Markers.Add(marker); if (_controlTextRadius != null) { String s = _controlTextRadius.Text; double radius; if (Double.TryParse(s, out radius)) { if (!_daddy._bUseKm) { radius = radius / _daddy._dConvKmToMi; } // On crée un cercle Color c = Color.Green; c = Color.FromArgb(60, c.R, c.G, c.B); Brush brush = new SolidBrush(c); Pen pen = new Pen(c, 2); GMapMarkerCircle circle = new GMapMarkerCircle(this, pt, (int)(radius * 1000.0), pen, brush, true); this.Overlays[GMapWrapper.RESERVED2].Markers.Add(circle); } } } base.OnMouseClick(e); }
private void MainMap_MouseDoubleClick(object sender, MouseEventArgs e) { var cc = new GMapMarkerCircle(gmap.FromLocalToLatLng(e.X, e.Y)); objects.Markers.Add(cc); }
/// <summary> /// gets rectangle with all GMapMarkerCircle objects inside /// </summary> /// <param name="overlayId">overlay id or null to check all</param> /// <returns></returns> public RectLatLng?GetRectOfAllCircles(string overlayId) { RectLatLng?ret = null; double left = double.MaxValue; double top = double.MinValue; double right = double.MinValue; double bottom = double.MaxValue; foreach (GMapOverlay o in Overlays) { if (overlayId == null || o.Id == overlayId) { if (o.IsVisibile && o.Markers.Count > 0) { foreach (GMapMarker m in o.Markers) { GMapMarkerCircle c = m as GMapMarkerCircle; if (c == null) { continue; } if (c.IsVisible) { RectLatLng r = c.GetBoundRect(); // left if (r.Left < left) { left = r.Left; } // top if (r.Top > top) { top = r.Top; } // right if (r.Right > right) { right = r.Right; } // bottom if (r.Bottom < bottom) { bottom = r.Bottom; } } } } } } if (left != double.MaxValue && right != double.MinValue && top != double.MinValue && bottom != double.MaxValue) { ret = RectLatLng.FromLTRB(left, top, right, bottom); } return(ret); }