/** * 绘制弧线 * * @return 折线对象 */ public Graphic DrawArc() { double mLat = 39.97923; double mLon = 116.357428; int lat = (int)(mLat * 1E6); int lon = (int)(mLon * 1E6); GeoPoint pt1 = new GeoPoint(lat, lon); mLat = 39.94923; mLon = 116.397428; lat = (int)(mLat * 1E6); lon = (int)(mLon * 1E6); GeoPoint pt2 = new GeoPoint(lat, lon); mLat = 39.97923; mLon = 116.437428; lat = (int)(mLat * 1E6); lon = (int)(mLon * 1E6); GeoPoint pt3 = new GeoPoint(lat, lon); Geometry arcGeometry = new Geometry(); arcGeometry.SetArc(pt1, pt3, pt2); // 设定样式 Symbol arcSymbol = new Symbol(); Symbol.Color arcColor = new Com.Baidu.Mapapi.Map.Symbol.Color(arcSymbol); arcColor.Red = 255; arcColor.Green = 0; arcColor.Blue = 225; arcColor.Alpha = 255; arcSymbol.SetLineSymbol(arcColor, 4); // 生成Graphic对象 Graphic arcGraphic = new Graphic(arcGeometry, arcSymbol); return arcGraphic; }
/** * 绘制折线,该折线状态随地图状态变化 * @return 折线对象 */ public Graphic DrawLine() { double mLat = 39.97923; double mLon = 116.357428; int lat = (int)(mLat * 1E6); int lon = (int)(mLon * 1E6); GeoPoint pt1 = new GeoPoint(lat, lon); mLat = 39.94923; mLon = 116.397428; lat = (int)(mLat * 1E6); lon = (int)(mLon * 1E6); GeoPoint pt2 = new GeoPoint(lat, lon); mLat = 39.97923; mLon = 116.437428; lat = (int)(mLat * 1E6); lon = (int)(mLon * 1E6); GeoPoint pt3 = new GeoPoint(lat, lon); //构建线 Geometry lineGeometry = new Geometry(); //设定折线点坐标 GeoPoint[] linePoints = new GeoPoint[3]; linePoints[0] = pt1; linePoints[1] = pt2; linePoints[2] = pt3; lineGeometry.SetPolyLine(linePoints); //设定样式 Symbol lineSymbol = new Symbol(); Symbol.Color lineColor = new Com.Baidu.Mapapi.Map.Symbol.Color(lineSymbol); lineColor.Red = 255; lineColor.Green = 0; lineColor.Blue = 0; lineColor.Alpha = 255; lineSymbol.SetLineSymbol(lineColor, 10); //生成Graphic对象 Graphic lineGraphic = new Graphic(lineGeometry, lineSymbol); return lineGraphic; }