//Button// private void button1_Click(object sender, EventArgs e) { if (txtLocationLandmark.Text == "Select Location on Map") { MessageBox.Show("Please Select Location on Map", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (cmbTypeLandmark.Text == "Please Select Type of Landmark") { MessageBox.Show("Please Select Type of Landmark", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else if (txtLabelLandmark.Text == "Short Name") { txtLabelLandmark.Text = ""; } var marker = new GmapMarkerWithLabel(PositionConverter.ParsePointFromString(txtLocationLandmark.Text), null, markerLandmark.icon, 20); GMapOverlay overlay = mainForm.GetInstance().GetOverlay("markersP"); MarkerLandmarkDetail detail = new MarkerLandmarkDetail(marker, cmbTypeLandmark.SelectedIndex, PositionConverter.ParsePointFromString(txtLocationLandmark.Text), txtNameLandmark.Text, txtLabelLandmark.Text); dicMarker.Add(marker, detail); marker.ToolTipText = "\n" + detail.Location.Lat.ToString() + " / " + detail.Location.Lng.ToString() + "\n" + detail.Label; marker.ToolTipMode = MarkerTooltipMode.OnMouseOver; overlay.Markers.Add(marker); mainForm.GetInstance().GetmainMap().Overlays.Add(overlay); txtLabelLandmark.Text = "Short Name"; txtLabelLandmark.ForeColor = Color.Gray; txtNameLandmark.Text = "Landmark Name"; txtNameLandmark.ForeColor = Color.Gray; cmbTypeLandmark.Text = "Please Select Type of Landmark"; cmbTypeLandmark.ForeColor = Color.Gray; }
public GMapPolygon CreatePolygon(string name, List <PointLatLng> points, int property) { AdjustPoints(points); GMapPolygon polygon = new GMapPolygon(points, name); polygon.Fill = new SolidBrush(Color.FromArgb(30, Color.DarkGray)); polygon.Stroke = new Pen(Color.Red, 2); if (property == 1) { polygon.Stroke.DashStyle = DashStyle.Dot; } polygon.IsHitTestVisible = true; Bitmap pic = (Bitmap)Image.FromFile("Img/point/em.png"); PointLatLng center = GetZoneCenter(points); mainForm main = mainForm.GetInstance(); GMapControl map = main.GetmainMap(); double zoom = map.Zoom; double pr = ((zoom - 5) * 10) / 100; if (pr == 0) { pr = 1; } var labelMarker = new GmapMarkerWithLabel(center, name, pic, (int)(20 * pr)); labelMarker.Offset = new System.Drawing.Point(((-labelMarker.Size.Width / 2) + 25), (-labelMarker.Size.Height / 2)); GMapOverlay overlay = Main.GetOverlay("polygons"); overlay.Polygons.Add(polygon); overlay.Markers.Add(labelMarker); polygon.Tag = labelMarker; return(polygon); }
public static void Layout(GMapControl map) { foreach (KeyValuePair <string, List <CustomPolygon> > polygonlist in polygonsDictionary) { var polygonslist = new GMapOverlay(polygonlist.Key); foreach (CustomPolygon polygon in polygonsDictionary[polygonlist.Key]) { polygon.Stroke = new Pen(Color.Black, 1); if (!statesMood.ContainsKey(polygonlist.Key)) { polygon.Fill = new SolidBrush(Color.Gray); } else { double b = statesMood[polygonlist.Key]; int red = 0, blue = 0, green = 0; if (statesMood[polygonlist.Key] > 0) { red = 55 + Convert.ToInt32(statesMood[polygonlist.Key] * 5); green = Math.Abs(55 - Convert.ToInt32(statesMood[polygonlist.Key] * 5)); if (red > 255) { red = 255; } } else if (statesMood[polygonlist.Key] < 0) { blue = 55 + Convert.ToInt32(Math.Abs(statesMood[polygonlist.Key]) * 5); if (blue > 255) { blue = 255; } } else { red = 255; blue = 255; green = 255; } polygon.Fill = new SolidBrush(Color.FromArgb(red, green, blue)); } polygonslist.Polygons.Add(polygon); } map.Overlays.Add(polygonslist); } foreach (KeyValuePair <string, List <CustomPolygon> > polygonlist in polygonsDictionary) { PointLatLng centre = new PointLatLng(); int max = 0, i = 0, b = 0; foreach (CustomPolygon polygon in polygonsDictionary[polygonlist.Key]) { if (polygon.PointAmount > max) { max = polygon.PointAmount; b = i; } i++; } centre = polygonsDictionary[polygonlist.Key][b].Centre; var markerOverlay = new GMapOverlay("markers"); var labelMarker = new GmapMarkerWithLabel(new PointLatLng(centre.Lat, centre.Lng), polygonlist.Key, GMarkerGoogleType.blue); markerOverlay.Markers.Add(labelMarker); map.Overlays.Add(markerOverlay); } }