你好 ,試下下面代碼,希望對你有用
成都創(chuàng)新互聯(lián)公司長期為上1000+客戶提供的網(wǎng)站建設(shè)服務(wù),團(tuán)隊(duì)從業(yè)經(jīng)驗(yàn)10年,關(guān)注不同地域、不同群體,并針對不同對象提供差異化的產(chǎn)品和服務(wù);打造開放共贏平臺,與合作伙伴共同營造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為孟連企業(yè)提供專業(yè)的成都做網(wǎng)站、成都網(wǎng)站制作,孟連網(wǎng)站改版等技術(shù)服務(wù)。擁有十多年豐富建站經(jīng)驗(yàn)和眾多成功案例,為您定制開發(fā)。
//這是直接根據(jù)路徑名稱加載
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();
}
是做網(wǎng)站中的電子地圖嗎?試試百度或者google地圖,很簡單有例子的。
其他的天地圖、MapABC、圖吧等。
新建一個文件,寫入下面的代碼:
!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,?(經(jīng)度,?緯度)
map.centerAndZoom(point,?15);??????????????????? ????//?show?Map
//?添加縮放功能
map.enableScrollWheelZoom();
map.enableKeyboard();
/script
保存到程序exe同一目錄下,文件名:map.html
然后BUTTON點(diǎn)擊事件:
WebBrowser1.Navigate(Application.StartupPath??"\map.html")
這樣就可以了
ps:經(jīng)緯度可以到百度地圖官網(wǎng)去獲取
或者到: ?去生成代碼