/** * 绘制圆,该圆随地图状态变化 * @return 圆对象 */ public Graphic DrawCircle() { double mLat = 39.90923; double mLon = 116.447428; int lat = (int)(mLat * 1E6); int lon = (int)(mLon * 1E6); GeoPoint pt1 = new GeoPoint(lat, lon); //构建圆 Geometry circleGeometry = new Geometry(); //设置圆中心点坐标和半径 circleGeometry.SetCircle(pt1, 2500); //设置样式 Symbol circleSymbol = new Symbol(); Symbol.Color circleColor = new Com.Baidu.Mapapi.Map.Symbol.Color(circleSymbol); circleColor.Red = 0; circleColor.Green = 255; circleColor.Blue = 0; circleColor.Alpha = 126; circleSymbol.SetSurface(circleColor, 1, 3, new Com.Baidu.Mapapi.Map.Symbol.Stroke(3, new Com.Baidu.Mapapi.Map.Symbol.Color(circleSymbol, Android.Graphics.Color.ParseColor("#FFFF0000").ToArgb()))); //生成Graphic对象 Graphic circleGraphic = new Graphic(circleGeometry, circleSymbol); return circleGraphic; }
/** * 绘制多边形,该多边形随地图状态变化 * @return 多边形对象 */ public Graphic DrawPolygon() { double mLat = 39.93923; double mLon = 116.357428; int lat = (int)(mLat * 1E6); int lon = (int)(mLon * 1E6); GeoPoint pt1 = new GeoPoint(lat, lon); mLat = 39.91923; mLon = 116.327428; lat = (int)(mLat * 1E6); lon = (int)(mLon * 1E6); GeoPoint pt2 = new GeoPoint(lat, lon); mLat = 39.89923; mLon = 116.347428; lat = (int)(mLat * 1E6); lon = (int)(mLon * 1E6); GeoPoint pt3 = new GeoPoint(lat, lon); mLat = 39.89923; mLon = 116.367428; lat = (int)(mLat * 1E6); lon = (int)(mLon * 1E6); GeoPoint pt4 = new GeoPoint(lat, lon); mLat = 39.91923; mLon = 116.387428; lat = (int)(mLat * 1E6); lon = (int)(mLon * 1E6); GeoPoint pt5 = new GeoPoint(lat, lon); //构建多边形 Geometry polygonGeometry = new Geometry(); //设置多边形坐标 GeoPoint[] polygonPoints = new GeoPoint[5]; polygonPoints[0] = pt1; polygonPoints[1] = pt2; polygonPoints[2] = pt3; polygonPoints[3] = pt4; polygonPoints[4] = pt5; polygonGeometry.SetPolygon(polygonPoints); //设置多边形样式 Symbol polygonSymbol = new Symbol(); Symbol.Color polygonColor = new Com.Baidu.Mapapi.Map.Symbol.Color(polygonSymbol); polygonColor.Red = 0; polygonColor.Green = 0; polygonColor.Blue = 255; polygonColor.Alpha = 126; polygonSymbol.SetSurface(polygonColor, 1, 5); //生成Graphic对象 Graphic polygonGraphic = new Graphic(polygonGeometry, polygonSymbol); return polygonGraphic; }