2 qq 35980546 qq_35980546 于 2017.09.19 08:22 提问

如何将web中的SuperMap地图用iObjects生成一张图片导出呢?

就是网页中的地图将可视的范围变成一张图片导出本地,地图是SuperMap的,要怎么做?

1个回答

code68
code68   2017.09.19 08:34

DatasourceConnectionInfo datasourceConnnectionInfo = new DatasourceConnectionInfo();
datasourceConnnectionInfo.EngineType = EngineType.UDB;
datasourceConnnectionInfo.Server = ":memory:"
datasourceConnnectionInfo.Alias = "mdata";

DatasetVector datasetvectorgrid = workspace.Datasources["mdata"].Datasets["mapgrid"] as DatasetVector;
Recordset recordset = datasetvectorgrid.GetRecordset(false, CursorType.Dynamic);
Rectangle2D maprectangle = new Rectangle2D();
maprectangle = mapcontrol.Map.ViewBounds;
double distancex = (maprectangle.Right - maprectangle.Left) / 10;
double distancey = (maprectangle.Top - maprectangle.Bottom) / 9;
Point2D point2d = new Point2D();
rectangles = new Rectangle2D[100];
Array .Clear (rectangles ,0, rectangles .Length );
int count = 0;
For (int j = 0; j <= 8; j++)
{
for (int i = 0; i <= 9; i++)
{
point2d.X = maprectangle.Left + distancex * i;
point2d.Y = maprectangle.Bottom + distancey * j;
Rectangle2D rectangle = new Rectangle2D(point2d, distancex, distancey);
rectangles[count] = rectangle;
count++;
GeoRectangle georectangle = new GeoRectangle(rectangle, 0);
GeoStyle style = Setgeostyle();
georectangle.Style = style;
recordset.AddNew(georectangle);
recordset.Update();
}
}

计算每一个网格里面有多少个点,并且将将聚合点聚合在当前网格内点对象的中心,将聚合点对象添加到内存数据源“point”,将聚合点数以字段的方式存储,对于在网格线上的点则做优先选择处理,
实现代码如下:

//检查是否包含;
private void IsCanContain()
{
//聚合点数据集;
DatasetVector datasetvectorgrid = workspace.Datasources["mdata"].Datasets["point"] as DatasetVector;
Recordset recordsetpoint = datasetvectorgrid.GetRecordset(false, CursorType.Dynamic);
//原始点数据集;
DatasetVector datasetvectorpoint = workspace.Datasources[0].Datasets["POIP"] as DatasetVector;

Recordset recordset = datasetvectorpoint.GetRecordset(false, CursorType.Static);
//临时单个聚合对象点
DatasetVector datasetvetortpoint = workspace .Datasources ["mdata"].Datasets ["tpoint"] as DatasetVector ;
recordsetpoint.DeleteAll();
Point2D[] point2ds = new Point2D[recordset.RecordCount];
int pointitem = 0;
for (int i = 0; i < 100; i++)
{
int count = 0;
Rectangle2D rectangle = rectangles[i];

recordset.MoveFirst();
Recordset rectangleitemrecordset = datasetvetortpoint.GetRecordset(false, CursorType.Dynamic);
for (int j = 0; j < recordset.RecordCount; j++)
{
Geometry geometry = recordset.GetGeometry();

GeoPoint geopoint = geometry as GeoPoint ;
Point2D point2d = new Point2D (geopoint .X ,geopoint .Y );
if (rectangle .Contains (point2d ))
{
if (Array.IndexOf(point2ds, point2d) == -1)
{
count++;
point2ds[pointitem] = point2d;
pointitem++;
GeoPoint itemgeopoint = new GeoPoint(point2d);
rectangleitemrecordset.AddNew(itemgeopoint);
rectangleitemrecordset.Update();
}
}
recordset.MoveNext();
}
可以参考下

qq_35980546
qq_35980546 不行,生成不了图片,
2 个月之前 回复
qq_35980546
qq_35980546 谢谢大哥,我看一下
2 个月之前 回复
Csdn user default icon
上传中...
上传图片
插入图片