Esempio n. 1
0
        /// <summary>
        /// 更新线的位置
        /// </summary>
        /// <param name="pList">经纬度列表</param>
        /// <returns></returns>
        public bool UpdatePosition(List <MapLngLat> pList)
        {
            IPointCollection pointCollection = base.Geometry as IPointCollection;

            if (pointCollection != null)
            {
                pointCollection.RemovePoints(0, pointCollection.PointCount);   // 清空之前的点,再添加新点

                for (int i = 0; i < pList.Count; i++)
                {
                    IPoint point = new PointClass();
                    point.PutCoords(pList[i].Lng, pList[i].Lat);
                    point.Z = pList[i].Alt;
                    (point as IZAware).ZAware = true;
                    pointCollection.AddPoint(point);
                }

                Dosomething((Action) delegate()
                {
                    int outIndex = -1;
                    graphcisLayer.FindElementIndex(this, out outIndex);
                    if (outIndex > 0)
                    {
                        base.Geometry = pointCollection as IGeometry;
                        graphcisLayer.UpdateElementByIndex(outIndex);
                    }
                }, true);

                return(true);
            }

            return(false);
        }
Esempio n. 2
0
        /// <summary>
        /// Adds a sphere element to the given graphics layer at the specified position
        /// </summary>
        /// <param name="globeGraphicsLayer"></param>
        /// <param name="position"></param>
        /// <returns></returns>
        private int AddTrackElement(IGlobeGraphicsLayer globeGraphicsLayer, esriGpsPositionInfo position)
        {
            if (null == globeGraphicsLayer)
            {
                return(-1);
            }

            //create a new point at the given position
            IPoint point = new PointClass();

            ((IZAware)point).ZAware = true;
            point.X = position.longitude;
            point.Y = position.latitude;
            point.Z = 0.0;

            //set the color for the element (red)
            IRgbColor color = new RgbColorClass();

            color.Red   = 255;
            color.Green = 0;
            color.Blue  = 0;

            //create a new 3D marker symbol
            IMarkerSymbol markerSymbol = new SimpleMarker3DSymbolClass();

            //set the marker symbol's style and resolution
            ((ISimpleMarker3DSymbol)markerSymbol).Style             = esriSimple3DMarkerStyle.esriS3DMSSphere;
            ((ISimpleMarker3DSymbol)markerSymbol).ResolutionQuality = 1.0;

            //set the symbol's size and color
            markerSymbol.Size  = 700;
            markerSymbol.Color = color as IColor;

            //crate the graphic element
            IElement trackElement = new MarkerElementClass();

            //set the element's symbol and geometry (location and shape)
            ((IMarkerElement)trackElement).Symbol = markerSymbol;
            trackElement.Geometry = point as IPoint;


            //add the element to the graphics layer
            int elemIndex = 0;

            ((IGraphicsContainer)globeGraphicsLayer).AddElement(trackElement, 0);

            //get the element's index
            globeGraphicsLayer.FindElementIndex(trackElement, out elemIndex);
            return(elemIndex);
        }
Esempio n. 3
0
        /// <summary>
        /// 更新模型
        /// </summary>
        /// <param name="_lnglat">坐标</param>
        /// <param name="angle">角度</param>
        public void UpdateModel(MapLngLat _lnglat, double angle)
        {
            this.Dosomething((Action) delegate()
            {
                IPoint point = new PointClass();
                point.PutCoords(_lnglat.Lng, _lnglat.Lat);
                point.Z = _lnglat.Alt;
                (point as IZAware).ZAware = true;
                base.Geometry             = point;

                markerSymbol.Angle = angle;
                base.Symbol        = markerSymbol;

                int outIndex = -1;
                graphicLayer.FindElementIndex(this, out outIndex);
                if (outIndex > -1)
                {
                    graphicLayer.UpdateElementByIndex(index);   // 刷新图元
                }
            }, true);

            this.lngLat = _lnglat;
        }
    /// <summary>
    /// Adds a sphere element to the given graphics layer at the specified position
    /// </summary>
    /// <param name="globeGraphicsLayer"></param>
    /// <param name="position"></param>
    /// <returns></returns>
    private int AddTrackElement(IGlobeGraphicsLayer globeGraphicsLayer, esriGpsPositionInfo position)
    {
      if (null == globeGraphicsLayer)
        return -1;

      //create a new point at the given position
      IPoint point = new PointClass();
      ((IZAware)point).ZAware = true;
      point.X = position.longitude;
      point.Y = position.latitude;
      point.Z = 0.0;

      //set the color for the element (red)
      IRgbColor color = new RgbColorClass();
      color.Red = 255;
      color.Green = 0;
      color.Blue = 0;

      //create a new 3D marker symbol
      IMarkerSymbol markerSymbol = new SimpleMarker3DSymbolClass();

      //set the marker symbol's style and resolution
      ((ISimpleMarker3DSymbol)markerSymbol).Style = esriSimple3DMarkerStyle.esriS3DMSSphere;
      ((ISimpleMarker3DSymbol)markerSymbol).ResolutionQuality = 1.0;

      //set the symbol's size and color
      markerSymbol.Size = 700;
      markerSymbol.Color = color as IColor;

      //crate the graphic element
      IElement trackElement = new MarkerElementClass();

      //set the element's symbol and geometry (location and shape)
      ((IMarkerElement)trackElement).Symbol = markerSymbol;
      trackElement.Geometry = point as IPoint;


      //add the element to the graphics layer
      int elemIndex = 0;
      ((IGraphicsContainer)globeGraphicsLayer).AddElement(trackElement, 0);

      //get the element's index
      globeGraphicsLayer.FindElementIndex(trackElement, out elemIndex);
      return elemIndex;
    }