private void openMap(string serName)
{
this.MapResourceManager1.ResourceItems.Clear();
string definition = "(default)@" + serName;
//MapResourceManager1.Dispose();
MapResourceItem mri = new MapResourceItem();
GISResourceItemDefinition grid = new GISResourceItemDefinition();
mri.Name = "MapResourceItem0";
grid.DataSourceDefinition = ConfigurationManager.AppSettings["dataSourceDefinition"].ToString();
grid.DataSourceType = "ArcGIS Server Local";
grid.ResourceDefinition = definition;
grid.DataSourceShared = true;
mri.Parent = this.MapResourceManager1;
mri.Definition = grid;
DisplaySettings displaySettings = new DisplaySettings();
displaySettings.DisplayInTableOfContents = true;
displaySettings.Visible = true;
mri.DisplaySettings = displaySettings;
this.MapResourceManager1.ResourceItems.Add(mri);
this.MapResourceManager1.Initialize();
this.MapResourceManager1.Refresh();
this.Map1.MapResourceManagerInstance = this.MapResourceManager1;
this.Map1.MapResourceManager = "MapResourceManager1";
if(Map1 != null)
Map1.Reset();
Map1.ZoomToFullExtent();
this.Map1.Refresh();
}
protected void btncapital_Click(object sender, EventArgs e)
{
#region//贵州省
openMap("贵州省");
#endregion
initddlregion();
}
要等地图完全初始化后,些方法才生效,不能用在page_load()中实现,只能是用户触发