コード例 #1
0
ファイル: frmMap.cs プロジェクト: yifeidong/gvms
        private void mapControl_BeforeLayerDraw(object sender, AxMapObjects2._DMapEvents_BeforeLayerDrawEvent e)
        {
            if (e.index == this.mapControl.Layers.Count - 1)
            {
                //绘制导航地图中的视图范围框线
                frmNavigation.Instance.DrawMainMapViewExtent(this.mapControl.Extent);

                //更新比例尺
                MapUtil.MapOperation oMapOper = new MapUtil.MapOperation();
                this._mapScale = oMapOper.ComputeMapScale(this.mapControl);
                this.lblScale.Text = string.Format("比例尺 : 1 : {0}", this._mapScale.ToString());
            }

            object oLayer = this.mapControl.Layers.Item(e.index);
            int iMinScale = 0;
            int iMaxScale = 0;
            string[] sScales = new string[2];

            if (oLayer is MapObjects2.MapLayer)
            {
                sScales = (oLayer as MapLayer).Tag.Split('-');
                iMinScale = int.Parse(sScales[0]);
                iMaxScale = int.Parse(sScales[1]);

                if (iMinScale == 0 && iMaxScale == 0) return;

                if (this._mapScale >= iMinScale && this._mapScale <= iMaxScale)
                {
                    (oLayer as MapLayer).Visible = true;
                }
                else
                {
                    (oLayer as MapLayer).Visible = false;
                }
            }
            else if (oLayer is MapObjects2.ImageLayer)
            {
                sScales = (oLayer as ImageLayer).Tag.Split('-');
                iMinScale = int.Parse(sScales[0]);
                iMaxScale = int.Parse(sScales[1]);

                if (iMinScale == 0 && iMaxScale == 0) return;

                if (this._mapScale >= iMinScale && this._mapScale <= iMaxScale)
                {
                    (oLayer as ImageLayer).Visible = true;
                }
                else
                {
                    (oLayer as ImageLayer).Visible = false;
                }
            }
        }
コード例 #2
0
ファイル: MapOperation.cs プロジェクト: uwitec/gvms
        public FeatureInformations GetIdentifyFeatureInfos(MapObjects2.Point mousePosition, AxMapObjects2.AxMap mapControl,MapProject.MapStruct mapInfosCollection)
        {
            FeatureInformations oFeatureInfos = null;

            foreach (ILayerStruct oLayerInfos in mapInfosCollection.Layers)
            {
                if (oLayerInfos.LayerType != (short)LayerTypeConstants.moMapLayer)
                    continue;

                MapUtil.MapOperation oMapOper = new MapOperation();
                MapObjects2.MapLayer oMapLayer = oMapOper.GetLayerByName(mapControl, oLayerInfos.AliasName) as MapObjects2.MapLayer;

                if (oMapLayer.Visible == false)
                    continue;

                Recordset oSelectedRecords = oMapLayer.SearchShape(mousePosition, SearchMethodConstants.moAreaIntersect, "");

                if (oSelectedRecords.EOF)
                    continue;

                oSelectedRecords.MoveFirst();

                oFeatureInfos = new FeatureInformations();
                oFeatureInfos.CurrentLayerInfos = oLayerInfos;
                oFeatureInfos.Geometry = oSelectedRecords.Fields.Item("shape").Value;

                TableDesc oTableDesc = oSelectedRecords.TableDesc;
                oFeatureInfos.FieldsAndValuesCollection = new Dictionary<string, string>();
                int iFieldsCount = oTableDesc.FieldCount;
                string sFieldName = "";
                string sValue = "";

                for (short i = 0; i < iFieldsCount; i++)
                {
                    sFieldName = oTableDesc.get_FieldName(i);
                    sValue = oSelectedRecords.Fields.Item(sFieldName).ValueAsString;
                    oFeatureInfos.FieldsAndValuesCollection.Add(sFieldName, sValue);
                }

                break;
            }

            return oFeatureInfos;
        }
コード例 #3
0
ファイル: frmMap.cs プロジェクト: uwitec/gvms
        private void mapControl_BeforeLayerDraw(object sender, AxMapObjects2._DMapEvents_BeforeLayerDrawEvent e)
        {
            if (e.index == this.mapControl.Layers.Count - 1)
            {
                //���Ƶ�����ͼ�е���ͼ��Χ����
                frmNavigation.Instance.DrawMainMapViewExtent(this.mapControl.Extent);

                //���±�����
                MapUtil.MapOperation oMapOper = new MapUtil.MapOperation();
                this._mapScale = oMapOper.ComputeMapScale(this.mapControl);
                this.lblScale.Text = string.Format("������ �� 1 : {0}", this._mapScale.ToString());
            }

            object oLayer = this.mapControl.Layers.Item(e.index);
            int iMinScale = 0;
            int iMaxScale = 0;
            string[] sScales = new string[2];

            if (oLayer is MapObjects2.MapLayer)
            {
                sScales = (oLayer as MapLayer).Tag.Split('-');
                iMinScale = int.Parse(sScales[0]);
                iMaxScale = int.Parse(sScales[1]);

                if (iMinScale == 0 && iMaxScale == 0) return;

                if (this._mapScale >= iMinScale && this._mapScale <= iMaxScale)
                {
                    (oLayer as MapLayer).Visible = true;
                }
                else
                {
                    (oLayer as MapLayer).Visible = false;
                }
            }
            else if (oLayer is MapObjects2.ImageLayer)
            {
                sScales = (oLayer as ImageLayer).Tag.Split('-');
                iMinScale = int.Parse(sScales[0]);
                iMaxScale = int.Parse(sScales[1]);

                if (iMinScale == 0 && iMaxScale == 0) return;

                if (this._mapScale >= iMinScale && this._mapScale <= iMaxScale)
                {
                    (oLayer as ImageLayer).Visible = true;
                }
                else
                {
                    (oLayer as ImageLayer).Visible = false;
                }
            }
        }