当前位置: 首页>>代码示例>>C#>>正文


C# Geometry.SetPolygon方法代码示例

本文整理汇总了C#中Geometry.SetPolygon方法的典型用法代码示例。如果您正苦于以下问题:C# Geometry.SetPolygon方法的具体用法?C# Geometry.SetPolygon怎么用?C# Geometry.SetPolygon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Geometry的用法示例。


在下文中一共展示了Geometry.SetPolygon方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DrawPolygon

        /**
         * 绘制多边形,该多边形随地图状态变化
         * @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;
        }
开发者ID:hnhhzy,项目名称:BaiduMap_SDK_DEMO_for_Xamarin.Android,代码行数:54,代码来源:GeometryDemo.cs


注:本文中的Geometry.SetPolygon方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。