1、调用地图并将micaps文件加载地图上
IFileBindingService fbs = ServiceLocator.Current.GetInstance< IFileBindingService>();
ILayer layer = fbs.CreateLayerForFile(new CMA.MICAPS.Infrastructures.FileSystems.FSPath ("D:\测试文件夹\555"));
IMapManager mapManager = ServiceLocator .Current.GetInstance<IMapManager>();
Map map = mapManager.ActiveMap.Map;
map.Layers.Add(layer);
2、加载m4省界地图
/// <summary>
/// 加载省界地图
/// </summary>
public static void addTheShengMap()
{
CommandManager cm = Bootstrapper .Current.GetService<CommandManager>();
Configuration config = new Configuration();
config.SetString( "name", "山西省" );
config.SetColor( "color", Color .YellowGreen);
cm.GetCommandBinding( "set_mask_cmd").Command.Execute(config);
//显示市县边界
LayerManager lm = ServiceLocator.Current.GetInstance<LayerManager>();
IMultiLayer layer = (IMultiLayer)lm.CurrentMap.Layers[0];
// var country= layer.SubLayers.Find(m => m.Name == "县界");
var city = layer.SubLayers.Find(m => m.Name == "市界");
lm.SetVisible(city, true);
}
3、把地图转成图片导出
/// <summary>
/// 把地图转成图片导出
/// </summary>
public static void outTheMapToPic()
{
ImageCapturer.Capture().Save("D:\pic.png");//调用m4将地图导出为图片的方法
}