首页 / 浏览问题 / 组件GIS / 问题详情
地图上添加省后,如何将整个地图重新保存,加到布局中
25EXP 2025年09月16日
问题描述:地图上添加省后,如何将整个地图重新保存,加到布局中,使用如下代码界面上并未出现布局地图

1个回答

您好,没有看到您的代码呢

你可以在桌面打开该工作空间,确认下地图已经保存成功,且添加了需要的元素
1,460EXP 2025年09月16日
根据这段代码布局中已显示地图,但无法缩放

添加代码后,评论一直提交不了,只能文字叙述

​

Layer provinceLayer = mapControl.Map.Layers.Add(datasetProvince, setting, true);

ThemeUnique railTheme = RailwayLineStyle();
mapControl.Map.Layers.Add(workspace.Datasources[0].Datasets["railway"], railTheme, true);

string mapXML = mapControl.Map.ToXML();
//workspace.Maps.SetMapXML("DynamicMap", mapXML); // 存到工作空间

                                               
mapLayoutControl.MapLayout.Paper.Size = PaperSize.A4;
mapLayoutControl.MapLayout.Paper.Orientation = PaperOrientation.Landscape;

GeoMap geoMap = new GeoMap
{
    MapXML = mapXML, // 直接用内存 XML
    ID = 1,
    Shape = new GeoRectangle(mapLayoutControl.MapLayout.Bounds.Center, 2500,1500, 0),
    
};
mapLayoutControl.MapLayout.Elements.AddNew(geoMap);


mapControl.Map.Zoom(4);        
mapLayoutControl.MapLayout.Zoom(4); 
if (mapControl.Map.Bounds.IsEmpty)
{
    mapControl.Map.ViewEntire(); 
}

if (geoMap == null) return;

// 4. 刷新布局
mapLayoutControl.MapLayout.Refresh();
this.mapLayoutControl.LayoutAction = SuperMap.UI.Action.Pan;
mapControl.Map.Refresh();        // 控件刷新
mapLayoutControl.MapLayout.Refresh(); // 布局刷新

​

新问题已在http://ask.supermap.com/158837回复

...