vb.net地图控件,winform 地图控件
请问vb.net添加了ARCGIS的mapcontrol控件后如何添加shp文件然后显示出来?
你好 ,试下下面代码,希望对你有用
成都创新互联公司长期为上1000+客户提供的网站建设服务,团队从业经验10年,关注不同地域、不同群体,并针对不同对象提供差异化的产品和服务;打造开放共赢平台,与合作伙伴共同营造健康的互联网生态环境。为孟连企业提供专业的成都做网站、成都网站制作,孟连网站改版等技术服务。拥有十多年丰富建站经验和众多成功案例,为您定制开发。
//这是直接根据路径名称加载
private voidmenuAddShp_Click(object sender, EventArgs e)
{
IWorkspaceFactory pWorkspaceFactory = new ShapefileWorkspaceFactory();
IWorkspace pWorkspace = pWorkspaceFactory.OpenFromFile(@"D:\GIS-Data",0);
IFeatureWorkspace pFeatureWorkspace =pWorkspace as IFeatureWorkspace;
IFeatureClass pFC =pFeatureWorkspace.OpenFeatureClass("continent.shp");
IFeatureLayer pFLayer = new FeatureLayerClass();
pFLayer.FeatureClass = pFC;
pFLayer.Name = pFC.AliasName;
ILayerpLayer = pFLayer as ILayer;
IMappMap = axMapControl1.Map;
pMap.AddLayer(pLayer);
axMapControl1.ActiveView.Refresh();
}
//这段是利用对话框添加
从工具箱往窗体上添加一个OpenFileDialog控件。
private voidmenuAddShp_Click(object sender, EventArgs e)
{
IWorkspaceFactorypWorkspaceFactory = new ShapefileWorkspaceFactory();
openFileDialog1.Filter = "shapefile文件(*.shp)|*.shp";
openFileDialog1.InitialDirectory = @"D:\GIS-Data";
openFileDialog1.Multiselect = false;
DialogResultpDialogResult = openFileDialog1.ShowDialog();
if(pDialogResult != DialogResult.OK)
return;
stringpPath = openFileDialog1.FileName;
stringpFolder = Path.GetDirectoryName(pPath);
stringpFileName = Path.GetFileName(pPath);
IWorkspacepWorkspace = pWorkspaceFactory.OpenFromFile(pFolder,0);
IFeatureWorkspacepFeatureWorkspace = pWorkspace as IFeatureWorkspace;
IFeatureClasspFC = pFeatureWorkspace.OpenFeatureClass(pFileName);
IFeatureLayerpFLayer = new FeatureLayerClass();
pFLayer.FeatureClass = pFC;
pFLayer.Name = pFC.AliasName;
ILayerpLayer = pFLayer as ILayer;
IMap pMap =axMapControl1.Map;
pMap.AddLayer(pLayer);
axMapControl1.ActiveView.Refresh();
}
VB.NET (c#) 想做个电子地图 用什么控件或者第三方控件 (C/S)具体点,谢谢了! 可以追加100分
是做网站中的电子地图吗?试试百度或者google地图,很简单有例子的。
其他的天地图、MapABC、图吧等。
vb.net 如何嵌入地图
新建一个文件,写入下面的代码:
!doctype html
html
head
meta name="viewport" content="initial-scale=1.0, user-scalable=no" /
meta http-equiv="Content-Type" content="text/html; charset=gbk" /
titleBaidu Map V1.2/title
script type="text/javascript" src=";services=true"
!-- add baidu map api --
/script
/head
body
div id="container" style="width: 600px; height: 400px;"
/div
/body
/html
script type="text/javascript"
var map = new BMap.Map("container"); // new Map
var point = new BMap.Point(116.397128, 39.916527); // Location, (经度, 纬度)
map.centerAndZoom(point, 15); // show Map
// 添加缩放功能
map.enableScrollWheelZoom();
map.enableKeyboard();
/script
保存到程序exe同一目录下,文件名:map.html
然后BUTTON点击事件:
WebBrowser1.Navigate(Application.StartupPath "\map.html")
这样就可以了
ps:经纬度可以到百度地图官网去获取
或者到: 去生成代码
本文名称:vb.net地图控件,winform 地图控件
网站URL:http://scyanting.com/article/hsssoi.html