木白林
路人甲
路人甲
  • 注册日期2004-03-19
  • 发帖数319
  • QQ
  • 铜币824枚
  • 威望0点
  • 贡献值0点
  • 银元0个
10楼#
发布于:2005-07-05 23:57
谢谢了,谢谢了,我试试
心情卡片 一起分享...
举报 回复(0) 喜欢(0)     评分
木白林
路人甲
路人甲
  • 注册日期2004-03-19
  • 发帖数319
  • QQ
  • 铜币824枚
  • 威望0点
  • 贡献值0点
  • 银元0个
11楼#
发布于:2005-07-06 22:58
<P>Set pMap = MapControl1.Map  '这里mapcontrol改成你的控件名字就可以了</P>
<P>老大,这一行有错,他提示说变量未定义,这个是控件名称,还要定义么?</P>
心情卡片 一起分享...
举报 回复(0) 喜欢(0)     评分
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15951
  • QQ
  • 铜币25345枚
  • 威望15368点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
12楼#
发布于:2005-07-07 12:35
<P>pmap已经定义了,自己调试程序看看哪里错了,</P>
GIS麦田守望者,期待与您交流。
举报 回复(0) 喜欢(0)     评分
木白林
路人甲
路人甲
  • 注册日期2004-03-19
  • 发帖数319
  • QQ
  • 铜币824枚
  • 威望0点
  • 贡献值0点
  • 银元0个
13楼#
发布于:2005-07-08 11:22
<P>实在不知道哪里出问题了,我把全部都帖出来吧,谢谢各位了</P>
<P>下面这个是在窗体加载中的代码,调用类模块</P>
<P> 'Create a MenuDef object<BR>  Dim pMenuDef As esriSystemUI.IMenuDef<BR>  Set pMenuDef = New NavigationMenu<BR>  <BR>  <BR>  'Add to the end of the Toolbar - it will be the 6th item<BR>   ToolbarControl1.AddItem pMenuDef, , , , , esriCommandStyleMenuBar</P>
<P>下面这个是类模块的完整代码:</P>
<P>Option Explicit<BR>Dim FEATURELAYER As IFeatureLayer<BR>Implements IMenuDef</P>
<P>Private Property Get IMenuDef_Caption() As String<BR>  IMenuDef_Caption = "土壤"<BR>End Property</P>
<P>Private Sub IMenuDef_GetItemInfo(ByVal pos As Long, ByVal itemDef As esriSystemUI.IItemDef)<BR>  Select Case pos 'Commands for the menu - the object browser lists these commands<BR>    Case 0<BR>      <BR>      Call AddShapeFile<BR>   <BR>    Case 1<BR>      itemDef.ID = "esriControlCommands.ControlsMapZoomOutFixedCommand"<BR>    Case 2<BR>      itemDef.ID = "esriControlCommands.ControlsMapFullExtentCommand"<BR>      itemDef.Group = True<BR>    Case 3<BR>      itemDef.ID = "esriControlCommands.ControlsMapZoomToLastExtentBackCommand"<BR>    Case 4<BR>      itemDef.ID = "esriControlCommands.ControlsMapZoomToLastExtentForwardCommand"<BR>  End Select<BR>End Sub</P>
<P><BR>Public Sub AddShapeFile()<BR>  Dim pWorkspaceFactory As IWorkspaceFactory<BR>  Dim pFeatureWorkspace As IFeatureWorkspace<BR>  Dim pFeatureLayer As IFeatureLayer<BR>  Dim pMap As IMap<BR>  <BR>  'Create a new ShapefileWorkspaceFactory object and open a shapefile folder<BR>  Set pWorkspaceFactory = New ShapefileWorkspaceFactory<BR>  Set pFeatureWorkspace = pWorkspaceFactory.OpenFromFile("d:\Program Files\ArcGIS\DeveloperKit\Samples\Data\World", 0)<BR>  'Create a new FeatureLayer and assign a shapefile to it<BR>  Set pFeatureLayer = New FEATURELAYER<BR>  Set pFeatureLayer.FeatureClass = pFeatureWorkspace.OpenFeatureClass("Country")<BR>  pFeatureLayer.Name = pFeatureLayer.FeatureClass.AliasName<BR>  'Add the FeatureLayer to the focus map<BR>  Set pMap = MapControl1.Map  '这里mapcontrol改成你的控件名字就可以了</P>
<P>  pMap.AddLayer pFeatureLayer<BR>End Sub</P>

<P><BR>Private Property Get IMenuDef_ItemCount() As Long<BR>  IMenuDef_ItemCount = 5<BR>End Property</P>
<P>Private Property Get IMenuDef_Name() As String<BR>  IMenuDef_Name = "Navigation"<BR>End Property<BR></P>
心情卡片 一起分享...
举报 回复(0) 喜欢(0)     评分
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15951
  • QQ
  • 铜币25345枚
  • 威望15368点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
14楼#
发布于:2005-07-08 15:18
<P>把下面的拷进去吧,应该可以加了吧,你注意下变量的定义了,imap是可以和mapcontrol1.map等同的</P>
<P> Case 0<BR>  Dim pWorkspaceFactory As IWorkspaceFactory<BR>  Dim pFeatureWorkspace As IFeatureWorkspace<BR>  Dim pFeatureLayer As IFeatureLayer<BR> ' Dim pMap As IMap<BR>  <BR>  'Create a new ShapefileWorkspaceFactory object and open a shapefile folder<BR>  Set pWorkspaceFactory = New ShapefileWorkspaceFactory<BR>  Set pFeatureWorkspace = pWorkspaceFactory.OpenFromFile("d:\Program Files\ArcGIS\DeveloperKit\Samples\Data\World", 0)<BR>  'Create a new FeatureLayer and assign a shapefile to it<BR>  Set pFeatureLayer = New FEATURELAYER<BR>  Set pFeatureLayer.FeatureClass = pFeatureWorkspace.OpenFeatureClass("Country")<BR>  pFeatureLayer.Name = pFeatureLayer.FeatureClass.AliasName</P>
<P><BR>  'Add the FeatureLayer to the focus map<BR>  'Set pMap = MapControl1.Map  '这里mapcontrol改成你的控件名字就可以了</P>
<P>  MapControl1.Map.AddLayer pFeatureLayer<BR>      <BR></P>
GIS麦田守望者,期待与您交流。
举报 回复(0) 喜欢(0)     评分
木白林
路人甲
路人甲
  • 注册日期2004-03-19
  • 发帖数319
  • QQ
  • 铜币824枚
  • 威望0点
  • 贡献值0点
  • 银元0个
15楼#
发布于:2005-07-08 20:46
还是提示mapcontrol1没有定义
心情卡片 一起分享...
举报 回复(0) 喜欢(0)     评分
木白林
路人甲
路人甲
  • 注册日期2004-03-19
  • 发帖数319
  • QQ
  • 铜币824枚
  • 威望0点
  • 贡献值0点
  • 银元0个
16楼#
发布于:2005-07-13 09:57
郁闷啊!~~~~~~~~~~~~~~~~
心情卡片 一起分享...
举报 回复(0) 喜欢(0)     评分
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15951
  • QQ
  • 铜币25345枚
  • 威望15368点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
17楼#
发布于:2005-07-14 13:07
<DIV class=quote><B>以下是引用<I>木白林</I>在2005-7-8 20:46:16的发言:</B><BR>还是提示mapcontrol1没有定义</DIV>
<P>
<P>这个是你自己取的控件名字,不要定义哦,兄弟</P>

GIS麦田守望者,期待与您交流。
举报 回复(0) 喜欢(0)     评分
木白林
路人甲
路人甲
  • 注册日期2004-03-19
  • 发帖数319
  • QQ
  • 铜币824枚
  • 威望0点
  • 贡献值0点
  • 银元0个
18楼#
发布于:2005-07-15 10:21
mapcontrol1我没有定义啊!这个就是默认的控件名称
心情卡片 一起分享...
举报 回复(0) 喜欢(0)     评分
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15951
  • QQ
  • 铜币25345枚
  • 威望15368点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
19楼#
发布于:2005-07-19 11:25
实在是难说了,方便的话,把程序打包上来看看
GIS麦田守望者,期待与您交流。
举报 回复(0) 喜欢(0)     评分
游客

返回顶部