Пример #1
0
        /// <summary>
        /// 聚焦到目标地物
        /// </summary>
        /// <param name="pMapCtrl">地图控件control</param>
        /// <param name="pGeo">地物</param>
        public static void ZoomToFeature(AxMapControl pMapCtrl, IGeometry pGeo)
        {
            if (pGeo == null || pGeo.IsEmpty)
            {
                return;
            }
            IEnvelope pEnvelope = pGeo.Envelope;

            //pMapCtrl.ActiveView.Extent = pEnvelope;
            //如果是点类型则集中显示
            if (pGeo.GeometryType == esriGeometryType.esriGeometryPoint)
            {
                //IEnvelope pEnv = pMapCtrl.ActiveView.FullExtent;
                //pEnv.Expand(0.005, 0.005, false);
                //pMapCtrl.ActiveView.Extent = pEnv;

                IPoint pPoint = (IPoint)pGeo;
                pMapCtrl.CenterAt(pPoint);
                pMapCtrl.MapScale = 2000;
            }
            else if (pGeo.GeometryType == esriGeometryType.esriGeometryPolyline)
            {
                if (!pEnvelope.IsEmpty)
                {
                    pEnvelope.Expand(3, 3, true);
                    pMapCtrl.ActiveView.Extent = pEnvelope;
                }
                else
                {
                    IPointCollection pPntColl = pGeo as IPointCollection;
                    IPoint           pt       = pPntColl.get_Point(1);
                    pMapCtrl.CenterAt(pt);
                    pMapCtrl.MapScale = 2000;
                }
            }
            else if (pGeo.GeometryType == esriGeometryType.esriGeometryPolygon)
            {
                pEnvelope.Expand(2, 2, true);
                pMapCtrl.ActiveView.Extent = pEnvelope;
            }

            //pMapCtrl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
            pMapCtrl.ActiveView.Refresh();
            pMapCtrl.ActiveView.ScreenDisplay.UpdateWindow();
            FlashGeometry(pMapCtrl.Object as IMapControl4, pGeo);
            //pMapCtrl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
            //pMapCtrl.ActiveView.ScreenDisplay.UpdateWindow();
        }
Пример #2
0
        //在鹰眼控件的OnMouseMove中使用
        public static void RectangleMove(AxMapControl mapControl1, IMapControlEvents2_OnMouseMoveEvent e)
        {
            if (e.button != 1)
            {
                return;
            }
            IPoint pPoint = new PointClass();

            pPoint.PutCoords(e.mapX, e.mapY);
            mapControl1.CenterAt(pPoint);
            mapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
        }
Пример #3
0
        public void MouseMov()
        {
            if (em.button != 1)
            {
                return;
            }
            IPoint pPt = new ESRI.ArcGIS.Geometry.Point();

            pPt.X = em.mapX;
            pPt.Y = em.mapY;
            axMapControl1.CenterAt(pPt);
            axMapControl2.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Пример #4
0
    public void axMapControl2_OnMouseMove(AxMapControl axMapControl1, AxMapControl axMapControl2, object sender, IMapControlEvents2_OnMouseMoveEvent e)
    {
        // 如果不是左键按下就直接返回
        if (e.button != 1)
        {
            return;
        }
        IPoint pPoint = new PointClass();

        pPoint.PutCoords(e.mapX, e.mapY);
        axMapControl1.CenterAt(pPoint);
        axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
    }
Пример #5
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            if (_axmapcontrol != null)
            {
                try
                {
                    /*xisheng 20110802 */
                    p1.Visible = p2.Visible = p3.Visible = p4.Visible = false;
                    ISpatialReferenceFactory2 pSpatRefFac = new SpatialReferenceEnvironmentClass();
                    earthref = pSpatRefFac.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_WGS1984);

                    point = new ESRI.ArcGIS.Geometry.PointClass();
                    double x1 = Convert.ToDouble(textBoxX.Text);
                    double y1 = Convert.ToDouble(textBoxY.Text);
                    if (_axmapcontrol.MapUnits == esriUnits.esriMeters)
                    {
                        flatref = _axmapcontrol.Map.SpatialReference;
                        point   = GetProject(x1, y1);
                    }
                    else if (_axmapcontrol.MapUnits == esriUnits.esriDecimalDegrees)
                    {
                        point.PutCoords(x1, y1);
                    }
                    //end 0802
                    if (this.WriteLog)
                    {
                        Plugin.LogTable.Writelog("地图坐标定位到中心点(" + x1 + "," + y1 + ")");//xisheng 日志记录
                    }
                    _axmapcontrol.CenterAt(point);
                    _axmapcontrol.ActiveView.Refresh();

                    int x = Convert.ToInt32(point.X);
                    int y = Convert.ToInt32(point.Y);
                    _axmapcontrol.ActiveView.ScreenDisplay.DisplayTransformation.FromMapPoint(point, out x, out y);
                    p1.Location = new System.Drawing.Point(x - 11, y - 1);
                    p2.Location = new System.Drawing.Point(x - 1, y - 11);
                    p3.Location = new System.Drawing.Point(x + 1, y - 1);
                    p4.Location = new System.Drawing.Point(x - 1, y + 1);
                    p1.Visible  = p2.Visible = p3.Visible = p4.Visible = true;
                }
                catch (Exception ex)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "错误:" + ex.Message);
                }
            }
        }
Пример #6
0
 /// <summary>
 /// 定位
 /// </summary>
 /// <param name="lngLat">经纬度</param>
 /// <param name="zoomLevel"></param>
 public void ZoomToPosition(Core.Model.MapLngLat lngLat, int?zoomLevel = null)
 {
     ESRI.ArcGIS.Geometry.IPoint point = new PointClass();
     point.PutCoords(lngLat.Lng, lngLat.Lat);
     mapControl.CenterAt(point);
 }
Пример #7
0
        /// <summary>
        /// 聚焦到目标地物
        /// </summary>
        /// <param name="pMapCtrl">地图控件control</param>
        /// <param name="pFt">地物</param>
        public static void ZoomToElement(AxMapControl pMapCtrl, IGeometry pGeo)
        {
            if (pGeo == null || pGeo.IsEmpty)
            {
                return;
            }
            IEnvelope pEnvelope = pGeo.Envelope;

            IGraphicsContainer pGraphContainer = pMapCtrl.ActiveView.GraphicsContainer;
            //根据拓扑错误图形的几何类型,来创建相应的element
            IElement ipElement = null;
            RgbColor ipColor   = new RgbColor();

            if (pGeo.GeometryType == esriGeometryType.esriGeometryPoint)
            {
                IMarkerElement ipMarkElement = new MarkerElementClass();
                ipElement          = (IElement)ipMarkElement;
                ipElement.Geometry = pGeo;
                ISimpleMarkerSymbol ipMarkerSymbol = new SimpleMarkerSymbolClass();
                ipColor.Red   = 0;
                ipColor.Blue  = 255;
                ipColor.Green = 0;

                RgbColor ipColor1 = new RgbColor();

                ipColor1.NullColor          = true;
                ipMarkerSymbol.Color        = (IColor)ipColor1;
                ipMarkerSymbol.OutlineColor = (IColor)ipColor;
                ipMarkerSymbol.Outline      = true;
                ipMarkerSymbol.OutlineSize  = 2;
                ipMarkerSymbol.Style        = esriSimpleMarkerStyle.esriSMSCircle;
                ipMarkerSymbol.Size         = 14;
                ipMarkElement.Symbol        = ipMarkerSymbol;
            }
            else if (pGeo.GeometryType == esriGeometryType.esriGeometryPolyline)
            {
                ILineElement ipLineElement = new LineElementClass();
                ipElement          = (IElement)ipLineElement;
                ipElement.Geometry = pGeo;
                ISimpleLineSymbol ipLineSymbol = new SimpleLineSymbolClass();
                ipColor.Red          = 255;
                ipColor.Blue         = 0;
                ipColor.Green        = 0;
                ipLineSymbol.Color   = (IColor)ipColor;
                ipLineSymbol.Width   = 2.0;
                ipLineElement.Symbol = ipLineSymbol;
            }
            else if (pGeo.GeometryType == esriGeometryType.esriGeometryPolygon)
            {
                IPolygonElement ipPolygonElement = new PolygonElementClass();
                ipElement          = (IElement)ipPolygonElement;
                ipElement.Geometry = pGeo;
                ISimpleFillSymbol ipFillSymbol = new SimpleFillSymbolClass();
                ILineSymbol       ipLineSymbol = ipFillSymbol.Outline;
                ipLineSymbol.Width   = 2.0;
                ipColor.Red          = 255;
                ipColor.Blue         = 0;
                ipColor.Green        = 0;
                ipLineSymbol.Color   = (IColor)ipColor;
                ipFillSymbol.Outline = ipLineSymbol;
                IFillShapeElement pFillElement = (IFillShapeElement)ipPolygonElement;
                ipFillSymbol.Style  = esriSimpleFillStyle.esriSFSHollow;
                pFillElement.Symbol = ipFillSymbol;
            }

            //pGraphContainer.DeleteAllElements();

            pGraphContainer.AddElement(ipElement, 0);

            //pMapCtrl.ActiveView.Extent = pEnvelope;
            //如果是点类型则集中显示
            if (pGeo.GeometryType == esriGeometryType.esriGeometryPoint)
            {
                //IEnvelope pEnv = pMapCtrl.ActiveView.FullExtent;
                //pEnv.Expand(0.005, 0.005, false);
                //pMapCtrl.ActiveView.Extent = pEnv;

                IPoint pPoint = (IPoint)pGeo;
                pMapCtrl.CenterAt(pPoint);
                pMapCtrl.MapScale = 2000;
            }
            else if (pGeo.GeometryType == esriGeometryType.esriGeometryPolyline)
            {
                if (!pEnvelope.IsEmpty)
                {
                    pEnvelope.Expand(3, 3, true);
                    pMapCtrl.ActiveView.Extent = pEnvelope;
                }
                else
                {
                    IPointCollection pPntColl = pGeo as IPointCollection;
                    IPoint           pt       = pPntColl.get_Point(1);
                    pMapCtrl.CenterAt(pt);
                    pMapCtrl.MapScale = 2000;
                }
            }
            else if (pGeo.GeometryType == esriGeometryType.esriGeometryPolygon)
            {
                pEnvelope.Expand(2, 2, true);
                pMapCtrl.ActiveView.Extent = pEnvelope;
            }

            //pMapCtrl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
            pMapCtrl.ActiveView.Refresh();
            pMapCtrl.ActiveView.ScreenDisplay.UpdateWindow();
            FlashGeometry(pMapCtrl.Object as IMapControl4, pGeo);
            //pMapCtrl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
            //pMapCtrl.ActiveView.ScreenDisplay.UpdateWindow();
        }
Пример #8
0
        /// <summary>
        /// 聚焦到目标地物
        /// </summary>
        /// <param name="pMapCtrl">地图控件control</param>
        /// <param name="pGeo">地物</param>
        public static void ZoomToFeature(AxMapControl pMapCtrl, IGeometry pGeo)
        {
            if (pGeo == null || pGeo.IsEmpty)
            {
                return;
            }
            IEnvelope pEnvelope = pGeo.Envelope;

            //pMapCtrl.ActiveView.Extent = pEnvelope;
            //如果是点类型则集中显示
            if (pGeo.GeometryType == esriGeometryType.esriGeometryPoint)
            {
                //IEnvelope pEnv = pMapCtrl.ActiveView.FullExtent;
                //pEnv.Expand(0.005, 0.005, false);
                //pMapCtrl.ActiveView.Extent = pEnv;

                IPoint pPoint = (IPoint)pGeo;
                pMapCtrl.CenterAt(pPoint);
                pMapCtrl.MapScale = 2000;

            }
            else if (pGeo.GeometryType == esriGeometryType.esriGeometryPolyline)
            {
                if (!pEnvelope.IsEmpty)
                {
                    pEnvelope.Expand(3, 3, true);
                    pMapCtrl.ActiveView.Extent = pEnvelope;
                }
                else
                {
                    IPointCollection pPntColl = pGeo as IPointCollection;
                    IPoint pt = pPntColl.get_Point(1);
                    pMapCtrl.CenterAt(pt);
                    pMapCtrl.MapScale = 2000;
                }
            }
            else if (pGeo.GeometryType == esriGeometryType.esriGeometryPolygon)
            {
                pEnvelope.Expand(2, 2, true);
                pMapCtrl.ActiveView.Extent = pEnvelope;
            }

            //pMapCtrl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
            pMapCtrl.ActiveView.Refresh();
            pMapCtrl.ActiveView.ScreenDisplay.UpdateWindow();
            FlashGeometry(pMapCtrl.Object as IMapControl4, pGeo);
            //pMapCtrl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
            //pMapCtrl.ActiveView.ScreenDisplay.UpdateWindow();
        }
Пример #9
0
        /// <summary>
        /// 聚焦到目标地物
        /// </summary>
        /// <param name="pMapCtrl">地图控件control</param>
        /// <param name="pFt">地物</param>
        public static void ZoomToElement(AxMapControl pMapCtrl, IGeometry pGeo)
        {
            if (pGeo == null || pGeo.IsEmpty)
            {
                return;
            }
            IEnvelope pEnvelope = pGeo.Envelope;

            IGraphicsContainer pGraphContainer = pMapCtrl.ActiveView.GraphicsContainer;
            //根据拓扑错误图形的几何类型,来创建相应的element
            IElement ipElement = null;
            RgbColor ipColor = new RgbColor();
            if (pGeo.GeometryType == esriGeometryType.esriGeometryPoint)
            {
                IMarkerElement ipMarkElement = new MarkerElementClass();
                ipElement = (IElement)ipMarkElement;
                ipElement.Geometry = pGeo;
                ISimpleMarkerSymbol ipMarkerSymbol = new SimpleMarkerSymbolClass();
                ipColor.Red = 0;
                ipColor.Blue = 255;
                ipColor.Green = 0;

                RgbColor ipColor1 = new RgbColor();

                ipColor1.NullColor = true;
                ipMarkerSymbol.Color = (IColor)ipColor1;
                ipMarkerSymbol.OutlineColor = (IColor)ipColor;
                ipMarkerSymbol.Outline = true;
                ipMarkerSymbol.OutlineSize = 2;
                ipMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle;
                ipMarkerSymbol.Size = 14;
                ipMarkElement.Symbol = ipMarkerSymbol;
            }
            else if (pGeo.GeometryType == esriGeometryType.esriGeometryPolyline)
            {
                ILineElement ipLineElement = new LineElementClass();
                ipElement = (IElement)ipLineElement;
                ipElement.Geometry = pGeo;
                ISimpleLineSymbol ipLineSymbol = new SimpleLineSymbolClass();
                ipColor.Red = 255;
                ipColor.Blue = 0;
                ipColor.Green = 0;
                ipLineSymbol.Color = (IColor)ipColor;
                ipLineSymbol.Width = 2.0;
                ipLineElement.Symbol = ipLineSymbol;
            }
            else if (pGeo.GeometryType == esriGeometryType.esriGeometryPolygon)
            {
                IPolygonElement ipPolygonElement = new PolygonElementClass();
                ipElement = (IElement)ipPolygonElement;
                ipElement.Geometry = pGeo;
                ISimpleFillSymbol ipFillSymbol = new SimpleFillSymbolClass();
                ILineSymbol ipLineSymbol = ipFillSymbol.Outline;
                ipLineSymbol.Width = 2.0;
                ipColor.Red = 255;
                ipColor.Blue = 0;
                ipColor.Green = 0;
                ipLineSymbol.Color = (IColor)ipColor;
                ipFillSymbol.Outline = ipLineSymbol;
                IFillShapeElement pFillElement = (IFillShapeElement)ipPolygonElement;
                ipFillSymbol.Style = esriSimpleFillStyle.esriSFSHollow;
                pFillElement.Symbol = ipFillSymbol;
            }

            //pGraphContainer.DeleteAllElements();

            pGraphContainer.AddElement(ipElement, 0);

            //pMapCtrl.ActiveView.Extent = pEnvelope;
            //如果是点类型则集中显示
            if (pGeo.GeometryType == esriGeometryType.esriGeometryPoint)
            {
                //IEnvelope pEnv = pMapCtrl.ActiveView.FullExtent;
                //pEnv.Expand(0.005, 0.005, false);
                //pMapCtrl.ActiveView.Extent = pEnv;

                IPoint pPoint = (IPoint)pGeo;
                pMapCtrl.CenterAt(pPoint);
                pMapCtrl.MapScale = 2000;

            }
            else if (pGeo.GeometryType == esriGeometryType.esriGeometryPolyline)
            {
                if (!pEnvelope.IsEmpty)
                {
                    pEnvelope.Expand(3, 3, true);
                    pMapCtrl.ActiveView.Extent = pEnvelope;
                }
                else
                {
                    IPointCollection pPntColl = pGeo as IPointCollection;
                    IPoint pt = pPntColl.get_Point(1);
                    pMapCtrl.CenterAt(pt);
                    pMapCtrl.MapScale = 2000;
                }
            }
            else if (pGeo.GeometryType == esriGeometryType.esriGeometryPolygon)
            {
                pEnvelope.Expand(2, 2, true);
                pMapCtrl.ActiveView.Extent = pEnvelope;
            }

            //pMapCtrl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
            pMapCtrl.ActiveView.Refresh();
            pMapCtrl.ActiveView.ScreenDisplay.UpdateWindow();
            FlashGeometry(pMapCtrl.Object as IMapControl4, pGeo);
            //pMapCtrl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
            //pMapCtrl.ActiveView.ScreenDisplay.UpdateWindow();
        }