Ejemplo n.º 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);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// load layer from file, layer -> mapMain ocx
        /// </summary>
        private void InitializeMainMap()
        {
            mapMain.Layers.Clear();
            mapMain.ScrollBars = false;
            MapObjects2.DataConnection mapCon = new MapObjects2.DataConnectionClass();
            try
            {
                mapCon.Database = Path.GetDirectoryName(Application.ExecutablePath) + "\\shaps\\";
                for (int m = 0; m < 3; m++)
                {
                    for (int i = 0; i < mapLayer.m_layers.Length; i++)
                    {
                        MapObjects2.MapLayer layer;
                        layer            = new MapObjects2.MapLayer();
                        layer.GeoDataset = mapCon.FindGeoDataset(mapLayer.m_layers[i].dtFile);
                        switch (m)
                        {
                        case 0:
                            if (layer.shapeType != MapObjects2.ShapeTypeConstants.moShapeTypePolygon)
                            {
                                continue;
                            }
                            break;

                        case 1:
                            if (layer.shapeType != MapObjects2.ShapeTypeConstants.moShapeTypeLine)
                            {
                                continue;
                            }
                            break;

                        case 2:
                            if (layer.shapeType != MapObjects2.ShapeTypeConstants.moShapeTypePoint)
                            {
                                continue;
                            }
                            break;

                        default:
                            continue;
                        }
                        mapLayer.m_layers[i].layer = layer;
                        mapMain.Layers.Add(mapLayer.m_layers[i].layer);
                        mapLayer.m_layers[i].layer.Symbol.Style = (short)mapLayer.m_layers[i].dtSymbol;
                        mapLayer.m_layers[i].layer.Symbol.Color = System.Convert.ToUInt32(mapLayer.m_layers[i].dtColor);
                        mapLayer.m_layers[i].layer.Symbol.Size  = (short)mapLayer.m_layers[i].dtSize;
                        if (mapLayer.m_layers[i].layer.shapeType == MapObjects2.ShapeTypeConstants.moShapeTypePolygon)
                        {
                            mapLayer.m_layers[i].layer.Symbol.OutlineColor = System.Convert.ToUInt32(mapLayer.m_layers[i].dtColor);
                        }
                    }
                }

                zoomRect = mapMain.Extent;
                zoomRect.ScaleRectangle(SC);
                //				mapMain.CenterAt(STAT.X,STAT.Y);
                mapMain.Extent = zoomRect;
                mapMain.Refresh();
            }
            catch (Exception ex)
            {
                //MessageBox.Show("加载图层失败,请重新起动软件!","错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
                ExceptionHandler.Handle("加载图层失败,请重新起动软件!", ex);
            }
        }