private void DrawBeatSegment(string bsID) { esriDropSite ed = GeoClass.segPolygons.Find(delegate(esriDropSite find) { return(find.Name == bsID); }); if (ed != null) { GMapOverlay polyOverlay = new GMapOverlay(gMapControl1, "polygons"); List <PointLatLng> pointList = new List <PointLatLng>(); Polygon p = (Polygon)ed.dropSiteData.Geometry; foreach (PointCollection points in p.Rings) { for (int i = 1; i < points.Count; i++) { pointList.Add(new PointLatLng((double)points[i].Y, (double)points[i].X)); } GMapPolygon polygon = new GMapPolygon(pointList, ed.Name); polygon.Fill = new SolidBrush(Color.FromArgb(50, Color.Red)); polygon.Stroke = new Pen(Color.Red, 1); polyOverlay.Polygons.Add(polygon); polyOverlay.Id = bsID; } gMapControl1.Overlays.Add(polyOverlay); gMapControl1.ZoomAndCenterMarkers(bsID); } else { MessageBox.Show("Couldn't find beat segment " + bsID); } }
public void GetBeatSegs() { //QueryTask qt = new QueryTask("http://38.124.164.214:6080/arcgis/rest/services/MTCSegementsFinal/FeatureServer/0"); //QueryTask qt = new QueryTask("http://38.124.164.214:6080/arcgis/rest/services/Beats/FeatureServer/0"); QueryTask qt = new QueryTask("http://38.124.164.214:6080/arcgis/rest/services/DropZones/FeatureServer/0"); //QueryTask qt = new QueryTask("http://38.124.164.214:6080/arcgis/rest/services/TowTruckSites/FeatureServer/0"); Query query = new Query(); query.ReturnGeometry = true; //query.OutFields.AddRange(new string[] { "SegmentID", "BeatID", "SegmentDescription" }); //for beats query.OutFields.Add("*"); query.Where = "1=1"; qt.Execute(query); foreach (Graphic resultFeature in qt.LastResult.Features) { string BeatID = string.Empty; string Name = string.Empty; string Desc = string.Empty; System.Collections.Generic.IDictionary <string, object> allAttributes = resultFeature.Attributes; foreach (string theKey in allAttributes.Keys) { if (theKey == "BeatID") { object theValue = allAttributes[theKey]; if (theValue != null) { BeatID = theValue.ToString(); } } if (theKey == "Name") { object theValue = allAttributes[theKey]; if (theValue != null) { Name = theValue.ToString(); } } if (theKey == "DPSDSC") { object theValue = allAttributes[theKey]; if (theValue != null) { Desc = theValue.ToString(); } } } esriDropSite ed = new esriDropSite(); ed.BeatID = BeatID; ed.Desc = Desc; ed.Name = Name; ed.dropSiteData = resultFeature; GeoClass.segPolygons.Add(ed); } }