Exemple #1
0
 /// <summary>
 /// di tu ceng = eyemap
 /// </summary>
 private void InitializeEyeMap()
 {
     MapObjects2.DataConnection mapCon   = new MapObjects2.DataConnectionClass();
     MapObjects2.MapLayer       EyeLayer = null;
     try
     {
         mapCon.Database = Path.GetDirectoryName(Application.ExecutablePath) + "\\shaps\\";
         for (int i = 0; i < mapLayer.m_layers.Length; i++)
         {
             if (mapLayer.m_layers[i].typeName == "地图层")
             {
                 EyeLayer              = new MapObjects2.MapLayerClass();
                 EyeLayer.GeoDataset   = mapCon.FindGeoDataset(mapLayer.m_layers[i].dtFile);
                 EyeLayer.Symbol.Color = System.Convert.ToUInt32(mapLayer.m_layers[i].dtColor);
                 EyeLayer.Symbol.Size  = 1;
                 if (EyeLayer.shapeType == MapObjects2.ShapeTypeConstants.moShapeTypePolygon)
                 {
                     EyeLayer.Symbol.OutlineColor = System.Convert.ToUInt32(mapLayer.m_layers[i].dtColor);
                 }
                 mapEye.Layers.Add(EyeLayer);
                 mapEye.Refresh();
             }
         }
     }
     catch (Exception ex)
     {
         //MessageBox.Show("加载图层失败,请重新起动软件!","错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
         ExceptionHandler.Handle("加载图层失败,请重新起动软件!", ex);
     }
 }
        public MapStruct LoadProjectByMapInfos(string projectFileName, AxMapObjects2.AxMap mapControl)
        {
            ProjectSerialization oProjectSerialization = new ProjectSerialization();
            MapStruct            oMapStruct            = oProjectSerialization.DeserializeProject(projectFileName);
            List <ILayerStruct>  oLayers = oMapStruct.Layers;

            MapObjects2.DataConnection oConn = new MapObjects2.DataConnectionClass();

            foreach (ILayerStruct oLayer in oLayers)
            {
                if (oLayer is MapLayerInfoStruct)
                {
                    MapObjects2.MapLayer oMapLayer = new MapObjects2.MapLayerClass();
                    oConn.Database = System.IO.Path.GetDirectoryName(oLayer.FileName);

                    if (oConn.Connect())
                    {
                        oMapLayer.GeoDataset = oConn.FindGeoDataset(oLayer.DataSetName);

                        this.SetLayerRender(oMapLayer, (oLayer as MapLayerInfoStruct).Render);
                        this.ConvertSymbol((oLayer as MapLayerInfoStruct).Symbol, oMapLayer.Symbol);

                        oMapLayer.Name    = oLayer.AliasName;
                        oMapLayer.Visible = oLayer.Visible;
                        oMapLayer.Tag     = string.Format("{0}-{1}", oLayer.MinLevel, oLayer.MaxLevel);
                        mapControl.Layers.Add(oMapLayer);
                        oConn.Disconnect();
                    }
                }
                else if (oLayer is ImageLayerInfoStruct)
                {
                    //not implement
                    //MapObjects2.ImageLayer oImageLayer = new MapObjects2.ImageLayerClass();
                    //oImageLayer.Name = oLayer.Name;
                }
            }

            MapObjects2.Rectangle oViewExtent = new MapObjects2.RectangleClass();

            oViewExtent.Left   = oMapStruct.BBox.MinX;
            oViewExtent.Top    = oMapStruct.BBox.MinY;
            oViewExtent.Right  = oMapStruct.BBox.MaxX;
            oViewExtent.Bottom = oMapStruct.BBox.MaxY;
            mapControl.Extent  = oViewExtent;
            //mapControl.CoordinateSystem = oMapStruct.CoordinateSystem;

            return(oMapStruct);
        }
        public void LoadProjectByMapInfos(MapStruct mapInfos, AxMapObjects2.AxMap mapControl)
        {
            List <ILayerStruct> oLayers = mapInfos.Layers;

            MapObjects2.DataConnection oConn = new MapObjects2.DataConnectionClass();

            oConn.Database = mapInfos.GeoDataSetPath;

            oConn.Connect();

            foreach (ILayerStruct oLayer in oLayers)
            {
                if (oLayer is MapLayerInfoStruct && oConn.Connected)
                {
                    MapObjects2.MapLayer oMapLayer = new MapObjects2.MapLayerClass();
                    oMapLayer.GeoDataset = oConn.FindGeoDataset(oLayer.Name);

                    this.SetLayerRender(oMapLayer, (oLayer as MapLayerInfoStruct).Render);
                    this.ConvertSymbol((oLayer as MapLayerInfoStruct).Symbol, oMapLayer.Symbol);

                    mapControl.Layers.Add(oMapLayer);
                }
                else if (oLayer is ImageLayerInfoStruct)
                {
                    //not implement
                    //MapObjects2.ImageLayer oImageLayer = new MapObjects2.ImageLayerClass();
                    //oImageLayer.Name = oLayer.Name;
                }
            }

            if (oConn.Connected)
            {
                oConn.Disconnect();
            }

            mapControl.Extent.Top       = mapInfos.BBox.MinX;
            mapControl.Extent.Left      = mapInfos.BBox.MinY;
            mapControl.Extent.Bottom    = mapInfos.BBox.MaxX;
            mapControl.Extent.Right     = mapInfos.BBox.MaxY;
            mapControl.CoordinateSystem = mapInfos.CoordinateSystem;
        }
Exemple #4
0
 /// <summary>
 /// di tu ceng = eyemap
 /// </summary>
 private void InitializeEyeMap()
 {
     MapObjects2.DataConnection mapCon=new MapObjects2.DataConnectionClass();
     MapObjects2.MapLayer EyeLayer=null;
     try
     {
         mapCon.Database=Path.GetDirectoryName(Application.ExecutablePath)+"\\shaps\\";
         for(int i=0;i<mapLayer.m_layers.Length;i++)
         {
             if(mapLayer.m_layers[i].typeName=="��ͼ��" || mapLayer.m_layers[i].typeName=="ȫ�Բ�")
             {
                 EyeLayer=new MapObjects2.MapLayerClass();
                 EyeLayer.GeoDataset=mapCon.FindGeoDataset(mapLayer.m_layers[i].dtFile);
                 EyeLayer.Symbol.Color=System.Convert.ToUInt32(mapLayer.m_layers[i].dtColor);
                 EyeLayer.Symbol.Size=1;
                 if(EyeLayer.shapeType==MapObjects2.ShapeTypeConstants.moShapeTypePolygon)
                     EyeLayer.Symbol.OutlineColor=System.Convert.ToUInt32(mapLayer.m_layers[i].dtColor);
                 axMap2.Layers.Add(EyeLayer);
                 axMap2.Refresh();
             }
         }
     }
     catch( Exception ex )
     {
         //MessageBox.Show("����ͼ��ʧ��,�����������!","����",MessageBoxButtons.OK,MessageBoxIcon.Error);
         ExceptionHandler.Handle("����ͼ��ʧ��,�����������!", ex );
     }
 }
Exemple #5
0
        public void LoadProjectByMapInfos(MapStruct mapInfos,AxMapObjects2.AxMap mapControl)
        {
            List<ILayerStruct> oLayers = mapInfos.Layers;
            MapObjects2.DataConnection oConn = new MapObjects2.DataConnectionClass();

            oConn.Database = mapInfos.GeoDataSetPath;

            oConn.Connect();

            foreach (ILayerStruct oLayer in oLayers)
            {
                if (oLayer is MapLayerInfoStruct && oConn.Connected)
                {
                    MapObjects2.MapLayer oMapLayer = new MapObjects2.MapLayerClass();
                    oMapLayer.GeoDataset = oConn.FindGeoDataset(oLayer.Name);

                    this.SetLayerRender(oMapLayer, (oLayer as MapLayerInfoStruct).Render);
                    this.ConvertSymbol((oLayer as MapLayerInfoStruct).Symbol, oMapLayer.Symbol);

                    mapControl.Layers.Add(oMapLayer);
                }
                else if (oLayer is ImageLayerInfoStruct)
                {
                    //not implement
                    //MapObjects2.ImageLayer oImageLayer = new MapObjects2.ImageLayerClass();
                    //oImageLayer.Name = oLayer.Name;
                }
            }

            if(oConn.Connected) oConn.Disconnect();

            mapControl.Extent.Top = mapInfos.BBox.MinX;
            mapControl.Extent.Left = mapInfos.BBox.MinY;
            mapControl.Extent.Bottom = mapInfos.BBox.MaxX;
            mapControl.Extent.Right = mapInfos.BBox.MaxY;
            mapControl.CoordinateSystem = mapInfos.CoordinateSystem;
        }