zoukankan      html  css  js  c++  java
  • 向地图中添加地图资源

    这段代码是用来从本地文件中读取一个文件,然后放入MAP1控件中

    IGISFunctionality functionality = (IGISFunctionality)this.Map1.GetFunctionality(0);
    MapResourceLocal gisRes = functionality.Resource as MapResourceLocal;

    IServerContext mapContext = gisRes.ServerContextInfo.ServerContext;
    IWorkspaceFactory pWsFactory = (IWorkspaceFactory)mapContext.CreateObject("esriDataSourcesFile.ShapefileWorkspaceFactory");
    IFeatureWorkspace pFeatureWsp = (IFeatureWorkspace)pWsFactory.OpenFromFile(@"D:\GIS-Data\", 0);
    IFeatureLayer pFeaLayer = (IFeatureLayer)mapContext.CreateObject("esriCarto.FeatureLayer");
    pFeaLayer.FeatureClass = pFeatureWsp.OpenFeatureClass("Cities.shp");
    pFeaLayer.Name = "world30";
    pFeaLayer.Visible = true;


    IMapServerObjects mso = (IMapServerObjects)gisRes.MapServer;
    string resStr = gisRes.DataFrame;
    IMap map = mso.get_Map(resStr);
    map.AddLayer(pFeaLayer);
    map.MoveLayer(pFeaLayer, 0);
    gisRes.RefreshServerObjects();

    Map1.Refresh();

    一起学习GIS及其二次开发,一起进步!
  • 相关阅读:
    外设简述
    代C语言上机实践
    css动画效果
    css滑动门原理
    css整理
    html
    html单词
    倒计时.js
    随机方块
    求字符串出现次数和最大值
  • 原文地址:https://www.cnblogs.com/tuncaysanli/p/1392360.html
Copyright © 2011-2022 走看看