public void BuildgMap() { /* * switch (index) * { * case 0: * _mapcontrol.MapProvider = global::GMap.NET.MapProviders.BingSatelliteMapProvider.Instance; * break; * case 1: * _mapcontrol.MapProvider = global::GMap.NET.MapProviders.GoogleMapProvider.Instance; * break; * case 2: * _mapcontrol.MapProvider = global::GMap.NET.MapProviders.GoogleTerrainMapProvider.Instance; * break; * case 3: * _mapcontrol.MapProvider = global::GMap.NET.MapProviders.GoogleHybridMapProvider.Instance; * break; * case 4: * _mapcontrol.MapProvider = global::GMap.NET.MapProviders.ArcGIS_Topo_US_2D_MapProvider.Instance; * break; * case 5: * _mapcontrol.MapProvider = global::GMap.NET.MapProviders.GoogleSatelliteMapProvider.Instance; * break; * } * * * * global::GMap.NET.GMaps.Instance.Mode = global::GMap.NET.AccessMode.ServerOnly; */ _markers.Clear(); _mapcontrol.Overlays.Clear(); //_mapcontrol.ShowCenter = false; _overmarkers = new GMapOverlay("markers"); _overroutes = new GMapOverlay("routes"); _overpolys = new GMapOverlay("polygons"); _mapcontrol.Overlays.Add(_overmarkers); _mapcontrol.Overlays.Add(_overroutes); _mapcontrol.Overlays.Add(_overpolys); _drone_image_notselected = (Bitmap)Image.FromFile("drone.png", true); _drone_image_selected = (Bitmap)Image.FromFile("drone_selected.png", true); // Map POI int poicount = _wpg.POICount(); for (int i = 0; i < poicount; i++) { GMapMarker marker; POIPoints pnt = _wpg.POIPointAt(i); string poiname = pnt.name; if (i == 0) { _mapcontrol.Position = new global::GMap.NET.PointLatLng(pnt.lat, pnt.lon); } if (pnt.selected) { marker = new GMarkerGoogle(new PointLatLng(pnt.lat, pnt.lon), _poi_selected_image); } else { marker = new GMarkerGoogle(new PointLatLng(pnt.lat, pnt.lon), _poi_image); } // GMarkerGoogleType.blue_pushpin); //marker.Size = new Size(32, 32); marker.Offset = new Point(-16, -16); marker.ToolTipText = poiname; marker.Tag = poiname; marker.IsVisible = pnt.visible; marker.IsHitTestVisible = true; _overmarkers.Markers.Add(marker); } // Map Path int pathcount = _wpg.PathCount(); for (int i = 0; i < pathcount; i++) { Path path = _wpg.PathAt(i); string name = path.name; bool visible = path.visible; LinkedList <WayPoints> wplist = path.waypoints; int wpcount = wplist.Count; List <PointLatLng> points = new List <PointLatLng>(); int count = 0; foreach (WayPoints wp in wplist) { bool selected = wp.selected; points.Add(new PointLatLng(wp.lat, wp.lon)); GMapMarker marker; if (selected) { _drone_image = _drone_image_selected; _drone_image = RotateImage(_drone_image_selected, wp.head); marker = new GMarkerGoogle(new PointLatLng(wp.lat, wp.lon), _drone_image); //GMarkerGoogleType.red_pushpin); } else { _drone_image = _drone_image_notselected; _drone_image = RotateImage(_drone_image_notselected, wp.head); marker = new GMarkerGoogle(new PointLatLng(wp.lat, wp.lon), _drone_image); //GMarkerGoogleType.blue_pushpin); } //marker.Size = new Size(64,64); marker.Position = new PointLatLng(wp.lat, wp.lon); marker.Offset = new Point(-16, -16); marker.Tag = Convert.ToString(i) + "." + Convert.ToString(count); marker.IsVisible = visible; marker.ToolTipText = "WP(" + Convert.ToString(count) + ") - Alt:" + Convert.ToString(wp.alt); _overmarkers.Markers.Add(marker); wp.marker = marker; GMAPWPMarker wpmarker = new GMAPWPMarker(); wpmarker.path = i; wpmarker.wp = count; wpmarker.marker = marker; wpmarker.selected = wp.selected; _markers.Add(wpmarker); count++; } GMapRoute route = new GMapRoute(points, name); route.Stroke = new Pen(Color.Blue, 2); route.Tag = i; route.IsVisible = visible; route.IsHitTestVisible = true; _overroutes.Routes.Add(route); //mapcontrol.Overlays.Add(overroutes); //mapcontrol.Overlays.Add(markers); } //mapcontrol.Overlays.Add(markers); // Map Polygon int polycount = _wpg.ShapeCount(); for (int i = 0; i < polycount; i++) { Shape polyshape = _wpg.ShapeAt(i); string name = polyshape.name; bool visible = polyshape.visible; LinkedList <PolyPoint> wplist = polyshape.points; int wpcount = wplist.Count; List <PointLatLng> points = new List <PointLatLng>(); foreach (PolyPoint wp in wplist) { points.Add(new PointLatLng(wp.lat, wp.lon)); } GMapPolygon poly = new GMapPolygon(points, name); if (polyshape.selected) { poly.Stroke = new Pen(Color.Red, 1); } else { poly.Stroke = new Pen(Color.Yellow, 1); } poly.Fill = new SolidBrush(Color.FromArgb(25, Color.Yellow)); poly.Tag = polyshape.name; poly.IsVisible = visible; _overpolys.Polygons.Add(poly); } if (!Form1.Globals.Map_FirstDraw) { _mapcontrol.Position = Form1.Globals.map_center; Form1.Globals.Map_FirstDraw = false; } _center = _mapcontrol.Position; }
public void ReDrawgMap() { string lat, lon, poiname; PointLatLng center_position = _mapcontrol.Position; //_markers.Clear(); _mapcontrol.Overlays.Clear(); _mapcontrol.Position = center_position; //_mapcontrol.ShowCenter = false; _overmarkers = new GMapOverlay("markers"); _overroutes = new GMapOverlay("routes"); _overpolys = new GMapOverlay("polygons"); _mapcontrol.Overlays.Add(_overmarkers); _mapcontrol.Overlays.Add(_overroutes); _mapcontrol.Overlays.Add(_overpolys); // Map POI int poicount = _wpg.POICount(); for (int i = 0; i < poicount; i++) { GMapMarker marker; POIPoints pnt = _wpg.POIPointAt(i); poiname = pnt.name; //if (i == 0) _mapcontrol.Position = new global::GMap.NET.PointLatLng(pnt.lat, pnt.lon); if (pnt.selected) { marker = new GMarkerGoogle(new PointLatLng(pnt.lat, pnt.lon), _poi_selected_image); } else { marker = new GMarkerGoogle(new PointLatLng(pnt.lat, pnt.lon), _poi_image); } //GMarkerGoogleType.blue_pushpin); marker.Offset = new Point(-16, -16); marker.ToolTipText = poiname; marker.Tag = poiname; marker.IsVisible = pnt.visible; //marker.IsVisible = true; marker.IsHitTestVisible = true; _overmarkers.Markers.Add(marker); } // Map Path int pathcount = _wpg.PathCount(); for (int i = 0; i < pathcount; i++) { Models.Path path = _wpg.PathAt(i); bool path_visible = path.visible; bool path_selected = path.selected; string name = path.name; LinkedList <WayPoints> wplist = path.waypoints; if (wplist != null) { int wpcount = wplist.Count; List <PointLatLng> points = new List <PointLatLng>(); int count = 0; foreach (WayPoints wp in wplist) { points.Add(new PointLatLng(wp.lat, wp.lon)); GMapMarker marker; if (path_selected | wp.selected) { _drone_image = _drone_image_selected; _drone_image = RotateImage(_drone_image_selected, wp.head); marker = new GMarkerGoogle(new PointLatLng(wp.lat, wp.lon), _drone_image); //GMarkerGoogleType.red_pushpin); } else { _drone_image = _drone_image_notselected; _drone_image = RotateImage(_drone_image_notselected, wp.head); marker = new GMarkerGoogle(new PointLatLng(wp.lat, wp.lon), _drone_image); //GMarkerGoogleType.blue_pushpin); } //marker.Size = new Size(64,64); marker.Offset = new Point(-16, -16); marker.Tag = Convert.ToString(i) + "." + Convert.ToString(count); marker.IsVisible = path_visible; marker.ToolTipText = "WP(" + Convert.ToString(count) + ") - Alt:" + Convert.ToString(wp.alt); _overmarkers.Markers.Add(marker); GMAPWPMarker wpmarker = new GMAPWPMarker(); wpmarker.path = i; wpmarker.wp = count; wpmarker.marker = marker; wpmarker.selected = wp.selected; _markers.Add(wpmarker); count++; } GMapRoute route = new GMapRoute(points, name); route.Stroke = new Pen(Color.Blue, 2); route.Tag = i; route.IsVisible = path_visible; route.IsHitTestVisible = true; _overroutes.Routes.Add(route); } //gMap.Overlays.Add(overroutes); //gMap.Overlays.Add(markers); } //gMap.Overlays.Add(markers); // Map Polygon int polycount = _wpg.ShapeCount(); for (int i = 0; i < polycount; i++) { Models.Shape polyshape = _wpg.ShapeAt(i); string name = polyshape.name; LinkedList <PolyPoint> wplist = polyshape.points; int wpcount = wplist.Count; List <PointLatLng> points = new List <PointLatLng>(); foreach (PolyPoint wp in wplist) { points.Add(new PointLatLng(wp.lat, wp.lon)); } GMapPolygon poly = new GMapPolygon(points, name); if (polyshape.selected) { poly.Stroke = new Pen(Color.Red, 1); } else { poly.Stroke = new Pen(Color.Yellow, 1); } poly.Fill = new SolidBrush(Color.FromArgb(25, Color.Yellow)); poly.Tag = polyshape.name; poly.IsVisible = polyshape.visible; poly.IsHitTestVisible = true; _overpolys.Polygons.Add(poly); } _mapcontrol.Position = center_position; }