• Add Graphic to Map Snippet


    Draw a specified graphic on the map using the supplied colors.

    ///<summary>Draw a specified graphic on the map using the supplied colors.</summary>
    ///      
    ///<param name="map">An IMap interface.</param>
    ///<param name="geometry">An IGeometry interface. It can be of the geometry type: esriGeometryPoint, esriGeometryPolyline, or esriGeometryPolygon.</param>
    ///<param name="rgbColor">An IRgbColor interface. The color to draw the geometry.</param>
    ///<param name="outlineRgbColor">An IRgbColor interface. For those geometry's with an outline it will be this color.</param>
    ///      
    ///<remarks>Calling this function will not automatically make the graphics appear in the map area. Refresh the map area after after calling this function with Methods like IActiveView.Refresh or IActiveView.PartialRefresh.</remarks>
    public void AddGraphicToMap(ESRI.ArcGIS.Carto.IMap map, ESRI.ArcGIS.Geometry.IGeometry geometry, ESRI.ArcGIS.Display.IRgbColor rgbColor, ESRI.ArcGIS.Display.IRgbColor outlineRgbColor)
    {
      ESRI.ArcGIS.Carto.IGraphicsContainer graphicsContainer = (ESRI.ArcGIS.Carto.IGraphicsContainer)map; // Explicit Cast
      ESRI.ArcGIS.Carto.IElement element = null;
      if ((geometry.GeometryType) == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint)
      {
        // Marker symbols
        ESRI.ArcGIS.Display.ISimpleMarkerSymbol simpleMarkerSymbol = new ESRI.ArcGIS.Display.SimpleMarkerSymbolClass();
        simpleMarkerSymbol.Color = rgbColor;
        simpleMarkerSymbol.Outline = true;
        simpleMarkerSymbol.OutlineColor = outlineRgbColor;
        simpleMarkerSymbol.Size = 15;
        simpleMarkerSymbol.Style = ESRI.ArcGIS.Display.esriSimpleMarkerStyle.esriSMSCircle;
    
        ESRI.ArcGIS.Carto.IMarkerElement markerElement = new ESRI.ArcGIS.Carto.MarkerElementClass();
        markerElement.Symbol = simpleMarkerSymbol;
        element = (ESRI.ArcGIS.Carto.IElement)markerElement; // Explicit Cast
      }
      else if ((geometry.GeometryType) == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline)
      {
        //  Line elements
        ESRI.ArcGIS.Display.ISimpleLineSymbol simpleLineSymbol = new ESRI.ArcGIS.Display.SimpleLineSymbolClass();
        simpleLineSymbol.Color = rgbColor;
        simpleLineSymbol.Style = ESRI.ArcGIS.Display.esriSimpleLineStyle.esriSLSSolid;
        simpleLineSymbol.Width = 5;
    
        ESRI.ArcGIS.Carto.ILineElement lineElement = new ESRI.ArcGIS.Carto.LineElementClass();
        lineElement.Symbol = simpleLineSymbol;
        element = (ESRI.ArcGIS.Carto.IElement)lineElement; // Explicit Cast
      }
      else if ((geometry.GeometryType) == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon)
      {
        // Polygon elements
        ESRI.ArcGIS.Display.ISimpleFillSymbol simpleFillSymbol = new ESRI.ArcGIS.Display.SimpleFillSymbolClass();
        simpleFillSymbol.Color = rgbColor;
        simpleFillSymbol.Style = ESRI.ArcGIS.Display.esriSimpleFillStyle.esriSFSForwardDiagonal;
        ESRI.ArcGIS.Carto.IFillShapeElement fillShapeElement = new ESRI.ArcGIS.Carto.PolygonElementClass();
        fillShapeElement.Symbol = simpleFillSymbol;
        element = (ESRI.ArcGIS.Carto.IElement)fillShapeElement; // Explicit Cast
      }
      if (!(element == null))
      {
        element.Geometry = geometry;
        graphicsContainer.AddElement(element, 0);
      }
    }
    本博客有部分内容来自网络,如有问题请联系:hebeilijianghua@qq.com,并注明来自博客园。
  • 相关阅读:
    关于数组赋值时找不到数组名字的问题
    显示转换与隐式转换
    类型(值类型和引用类型)
    .net webconfig中配置httphanlder无法生效的问题
    微信小程序开发知识点总结
    Raphael.js API 之 Element.attr()
    Raphael.js API 之 Element.attr()
    Raphael.js API之 Animation.delay(),Animation.repeat(),Element.animateWith()
    Raphael.js API之 Animation.delay(),Animation.repeat(),Element.animateWith()
    Raphael.js API之 Paper.path(),Element.click()
  • 原文地址:https://www.cnblogs.com/leebokeyuan/p/5594048.html
Copyright © 2020-2023  润新知