大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
你好 ,试下下面代码,希望对你有用
让客户满意是我们工作的目标,不断超越客户的期望值来自于我们对这个行业的热爱。我们立志把好的技术通过有效、简单的方式提供给客户,将通过不懈努力成为客户在信息化领域值得信任、有价值的长期合作伙伴,公司提供的服务项目有:主机域名、网页空间、营销软件、网站建设、铁岭网站维护、网站推广。
//这是直接根据路径名称加载
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画的齿轮:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
b = New Bitmap(PictureBox1.Width, PictureBox1.Height)
g = Graphics.FromImage(b)
'g.RotateTransform(90)
g.Clear(Color.White)
g.TranslateTransform(PictureBox1.Width / 2, PictureBox1.Height / 2)
g.ScaleTransform(1, -1)
'g.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
g.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
DrawCL(g, New PointF(Val(TextBox1.Text), Val(TextBox2.Text)), Val(TextBox3.Text), Val(TextBox4.Text), Val(TextBox5.Text), Val(TextBox6.Text), Val(TextBox7.Text), Val(TextBox8.Text), Val(TextBox9.Text))
DrawCL(g, New PointF(Val(TextBox18.Text), Val(TextBox17.Text)), Val(TextBox16.Text), Val(TextBox15.Text), Val(TextBox14.Text), Val(TextBox13.Text), Val(TextBox12.Text), Val(TextBox11.Text), Val(TextBox10.Text))
PictureBox1.Image = b
End Sub
这个说简单也简单,百度google都有自己的地图接口,去找一下接口调用说明,里面都有案例。在程序里面调用即可。至于调用后具体的功能则需要查询接口函数。我以前做过google的,百度的实际上也是一样
新建一个文件,写入下面的代码:
!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:经纬度可以到百度地图官网去获取
或者到: 去生成代码