示例#1
0
 public void Add(ISimpleVectorObject obj)
 {
     if (obj == null)
     {
         return;
     }
     if (_features.ContainsKey(obj))
     {
         _datasource.Remove(_features[obj]);
         _features.Remove(obj);
         Add(obj);
     }
     else
     {
         Feature fet = GetFeature(obj);
         if (fet == null)
         {
             return;
         }
         _datasource.AddFeatures(new Feature[] { fet });
         _features.Add(obj, fet);
     }
     if (obj is SimpleVectorObject)
     {
         (obj as SimpleVectorObject).SetHost(this);
     }
     _canvas.Refresh(enumRefreshType.All);
 }
 public static CodeCell.AgileMap.Core.IFeatureLayer CreateAndLoadVectorLayerForMicaps(ISmartSession session, ICanvas canvas, string fname, string dataTypeId, params object[] args)
 {
     if (string.IsNullOrEmpty(fname) || !File.Exists(fname))
     {
         return(null);
     }
     using (IVectorFeatureDataReader reader = MicapsDataReaderFactory.GetVectorFeatureDataReader(fname, dataTypeId))
     {
         if (reader == null)
         {
             return(null);
         }
         if (reader.Features != null)
         {
             MemoryDataSource mds      = new MemoryDataSource(fname, reader.ShapeType, enumCoordinateType.Geographic, reader.Envelope, reader.Fields);
             IFeatureClass    fetClass = new FeatureClass(mds);
             mds.AddFeatures(reader.Features);
             CodeCell.AgileMap.Core.IFeatureLayer fetLayer = new FeatureLayer(fname, fetClass);
             TryApplyStyle(fetLayer, dataTypeId);
             IVectorHostLayer host = canvas.LayerContainer.VectorHost as IVectorHostLayer;
             if (host != null)
             {
                 host.Set(canvas);
                 IMapRuntime mapRuntime = host.MapRuntime as IMapRuntime;
                 if (mapRuntime != null)
                 {
                     IMap map = mapRuntime.Map as IMap;
                     if (map != null)
                     {
                         map.LayerContainer.Append(fetLayer);
                         FeatureLayer  fetL  = map.LayerContainer.Layers[0] as FeatureLayer;
                         FeatureClass  fetC  = fetL.Class as FeatureClass;
                         Envelope      evp   = fetC.FullEnvelope.Clone() as Envelope;
                         CoordEnvelope cvEvp = new CoordEnvelope(evp.MinX, evp.MaxX, evp.MinY, evp.MaxY);
                         canvas.CurrentEnvelope = cvEvp;
                         canvas.Refresh(enumRefreshType.All);
                     }
                 }
                 return(fetLayer);
             }
         }
     }
     return(null);
 }
示例#3
0
        private void button2_Click(object sender, EventArgs e)
        {
            //IMap map = MapFactory.LoadMapFrom(@"E:\AgileMap项目\配置好的地图\Map1\CC_MapLocalFile-Default.mcd");
            IMap map = MapFactory.LoadMapFrom(@"d:\m.mcd");

            agileMapControl1.Apply(map);

            ShapePoint       pt  = new ShapePoint(116, 39);
            Feature          fet = new Feature(0, pt, null, null, null);
            MemoryDataSource ds  = new MemoryDataSource("memeory", enumShapeType.Point);

            FeatureClass       fetc   = new FeatureClass(ds);
            FeatureLayer       fetlay = new FeatureLayer("memory", fetc);
            SimpleMarkerSymbol sym    = new SimpleMarkerSymbol(masSimpleMarkerStyle.Circle);

            sym.Size        = new System.Drawing.Size(10, 10);
            fetlay.Renderer = new SimpleFeatureRenderer(sym);
            ds.AddFeatures(new Feature[] { fet });
            agileMapControl1.Map.LayerContainer.Append(fetlay);
        }
示例#4
0
 public static CodeCell.AgileMap.Core.IFeatureLayer CreateAndLoadVectorLayerForMicaps(ISmartSession session, ICanvas canvas, string fname, Feature[] features)
 {
     if (string.IsNullOrEmpty(fname) || !File.Exists(fname))
     {
         return(null);
     }
     if (features != null)
     {
         MemoryDataSource mds      = new MemoryDataSource(fname, enumShapeType.Polyline);
         IFeatureClass    fetClass = new FeatureClass(mds);
         mds.AddFeatures(features);
         CodeCell.AgileMap.Core.IFeatureLayer fetLayer = new FeatureLayer(fname, fetClass);
         //TryApplyStyle(fetLayer, dataTypeId);
         IVectorHostLayer host = canvas.LayerContainer.VectorHost as IVectorHostLayer;
         if (host != null)
         {
             host.Set(canvas);
             IMapRuntime mapRuntime = host.MapRuntime as IMapRuntime;
             if (mapRuntime != null)
             {
                 IMap map = mapRuntime.Map as IMap;
                 if (map != null)
                 {
                     map.LayerContainer.Append(fetLayer);
                     FeatureLayer fetL = map.LayerContainer.Layers[0] as FeatureLayer;
                     FeatureClass fetC = fetL.Class as FeatureClass;
                     Envelope     evp  = fetC.FullEnvelope.Clone() as Envelope;
                     GeoDo.RSS.Core.DrawEngine.CoordEnvelope cvEvp = new GeoDo.RSS.Core.DrawEngine.CoordEnvelope(evp.MinX, evp.MaxX, evp.MinY, evp.MaxY);
                     canvas.CurrentEnvelope = cvEvp;
                     canvas.Refresh(enumRefreshType.All);
                 }
             }
             return(fetLayer);
         }
     }
     return(null);
 }