- 积分
- 418
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2012-8-4
- 最后登录
- 1970-1-1
|
楼主 |
发表于 2012-12-17 13:57:40
|
显示全部楼层
本帖最后由 记忆碎片 于 2012-12-17 14:06 编辑
我放着教程九进行了尝试
代码如下:
- //New layer
- VectorLayer aLayer = new VectorLayer(ShapeTypes.Point);
- aLayer.LayerName = "New_Point_Layer";
- aLayer.LegendScheme =LegendManage.CreateSingleSymbolLegendScheme(ShapeTypes.Point, Color.Red, 10);
- aLayer.Visible = true;
- //Add fields
- aLayer.EditAddField("STATION", typeof(string));
- aLayer.EditAddField("LON", typeof(double));
- aLayer.EditAddField("LAT", typeof(double));
- aLayer.EditAddField("DATA", typeof(double));
- //Prepare coordinate data
- double[] X = new double[2] { 120, 30 };
- double[] Y = new double[2] { 120, 30 };
- double[] data = new double[2] { 1,2 };
- //Add shape
- for (int i = 0; i < 2; i++)
- {
- PointShape aPS = new PointShape();
- PointD aPoint = new PointD();
- aPoint.X = X[i];
- aPoint.Y = Y[i];
- aPS.Point = aPoint;
- int shapeNum = aLayer.ShapeNum;
- if (aLayer.EditInsertShape(aPS, shapeNum))
- {
- //Edit record value
- aLayer.EditCellValue("STATION", shapeNum, "St1");
- aLayer.EditCellValue("LON", shapeNum, aPoint.X);
- aLayer.EditCellValue("LAT", shapeNum, aPoint.Y);
- aLayer.EditCellValue("DATA", shapeNum, data[i]);
- }
- }
- //Add Label
- aLayer.LabelSet.FieldName = "DATA";
- aLayer.LabelSet.LabelFont = new Font("Arial", 15);
- aLayer.LabelSet.YOffset = 30;
- aLayer.AddLabels();
- //Add layer
- layersLegend1.ActiveMapFrame.AddLayer(aLayer);
- layersLegend1.ActiveMapFrame.MapView.PaintLayers();
- layersLegend1.Refresh();
复制代码
很奇怪:x:120,y:30
两个点位置却不同
得到如下效果:
错误的效果
期望实现如下效果:
期望的效果
两个疑问:
1 //Prepare coordinate data
double[] X = new double[2] { 120, 30 };
double[] Y = new double[2] { 120, 30 };
double[] data = new double[2] { 1,2 };
这里1、2两个点明明一样的数字,显示的点位置却不同
2 120E,30N应该是在底图中央的,因为地图是shp的浙江地图。按理应该会叠加上去么,怎么会那么偏?
|
|