// Summary: // Load features in a FeatureTable into a GraphicsLayer // async Task <IS3GraphicsLayer> featureTable2GraphicsLayer(FeatureTable table, int start = 0, int maxFeatures = 0, bool isShp = false) { if (table == null) { return(null); } if (_srEMap == null) { // The spatial reference in the first table is used as the project spatial reference. // All features on other layers will be projected to the spatial reference. _srEMap = table.SpatialReference; _map.SpatialReference = table.SpatialReference; } //// We cannot use the feature layer class because it typically //// has a different SpatialReferece object (coordinate system) //// other than the tiled layer (WKID = 3857 or 102100), //// and there is no easy way to reproject feature layer //// to another coordinate system. //// We can only use the feature layer when there is no tiled layer defined, //// which is not a usual case. //FeatureLayer fLayer = new FeatureLayer(table); //fLayer.ID = table.Name; //fLayer.DisplayName = table.Name; //_map.Layers.Add(fLayer); QueryFilter qf = new QueryFilter(); qf.WhereClause = "1=1"; IEnumerable <Feature> features = await table.QueryAsync(qf); IS3GraphicCollection graphics = new IS3GraphicCollection(); int index = 0, count = 0; foreach (Feature f in features) { // jump to start position if (index++ < start) { continue; } // Note: // In ArcGIS Runtime SDK: User-defined coordinate system // is not allowed when using ShapefileTable.OpenAsync(). // Workaround: // (1) Do not assign user-defined CS in shape file; // (2) Assign CS dynamically here to _srEMap. // Geometry geometry = f.Geometry; if (isShp == true) { geometry = ArcGISMappingUtility.ChangeSpatailReference(geometry, _srEMap); if (geometry == null) { continue; } } if (_srEMap != null && isShp == false && geometry.SpatialReference != _srEMap) { geometry = GeometryEngine.Project(geometry, _srEMap); } // import the attributes IS3Graphic g = new IS3Graphic(geometry); foreach (KeyValuePair <string, object> item in f.Attributes.AsEnumerable()) { g.Attributes.Add(item); } graphics.Add(g); // Load max featuers if (maxFeatures != 0 && count++ == maxFeatures) { break; } } IS3GraphicsLayer gLayer = new IS3GraphicsLayer(); gLayer.DisplayName = table.Name; gLayer.GraphicsSource = graphics; gLayer.geometryType = (Core.Model.GeometryType)(int) table.GeometryType; return(gLayer); }
public IGraphic newPoint(double x, double y, ISpatialReference spatialReference) { IS3Graphic g = new IS3Graphic(); g.Geometry = new IS3MapPoint(x, y, spatialReference); return g; }
public IGraphic newPolyline(IPointCollection part) { IS3Polyline pline = new IS3Polyline(part); IS3Graphic g = new IS3Graphic(); g.Geometry = pline; return g; }
public IGraphic newPoint(double x, double y) { IS3Graphic g = new IS3Graphic(); g.Geometry = new IS3MapPoint(x, y); return g; }
public IGraphic newGraphic(IGeometry geom) { IS3Graphic g = new IS3Graphic(); g.Geometry = geom; return g; }
public IGraphic newText(string text, IMapPoint p, Color color, string fontName, double fontSize) { IS3TextSymbol textSymbol = new IS3TextSymbol(); textSymbol.Text = text; textSymbol.Color = color; IS3SymbolFont font = new IS3SymbolFont(fontName, fontSize); textSymbol.Font = font; IS3Graphic g = new IS3Graphic(); g.Symbol = textSymbol; g.Geometry = p; return g; }
public IGraphic newPolygon(IPointCollection part) { IS3Polygon pgon = new IS3Polygon(part); IS3Graphic g = new IS3Graphic(); g.Geometry = pgon; return g; }
// Summary: // Load features in a FeatureTable into a GraphicsLayer // async Task<IS3GraphicsLayer> featureTable2GraphicsLayer(FeatureTable table, int start = 0, int maxFeatures = 0, bool isShp = false) { if (table == null) return null; if (_srEMap == null) { // The spatial reference in the first table is used as the project spatial reference. // All features on other layers will be projected to the spatial reference. _srEMap = table.SpatialReference; _map.SpatialReference = table.SpatialReference; } //// We cannot use the feature layer class because it typically //// has a different SpatialReferece object (coordinate system) //// other than the tiled layer (WKID = 3857 or 102100), //// and there is no easy way to reproject feature layer //// to another coordinate system. //// We can only use the feature layer when there is no tiled layer defined, //// which is not a usual case. //FeatureLayer fLayer = new FeatureLayer(table); //fLayer.ID = table.Name; //fLayer.DisplayName = table.Name; //_map.Layers.Add(fLayer); QueryFilter qf = new QueryFilter(); qf.WhereClause = "1=1"; IEnumerable<Feature> features = await table.QueryAsync(qf); IS3GraphicCollection graphics = new IS3GraphicCollection(); int index = 0, count = 0; foreach (Feature f in features) { // jump to start position if (index++ < start) continue; // Note: // In ArcGIS Runtime SDK: User-defined coordinate system // is not allowed when using ShapefileTable.OpenAsync(). // Workaround: // (1) Do not assign user-defined CS in shape file; // (2) Assign CS dynamically here to _srEMap. // Geometry geometry = f.Geometry; if (isShp == true) { geometry = ArcGISMappingUtility.ChangeSpatailReference(geometry, _srEMap); if (geometry == null) continue; } if (_srEMap != null && isShp == false && geometry.SpatialReference != _srEMap) geometry = GeometryEngine.Project(geometry, _srEMap); // import the attributes IS3Graphic g = new IS3Graphic(geometry); foreach (KeyValuePair<string, object> item in f.Attributes.AsEnumerable()) g.Attributes.Add(item); graphics.Add(g); // Load max featuers if (maxFeatures != 0 && count++ == maxFeatures) break; } IS3GraphicsLayer gLayer = new IS3GraphicsLayer(); gLayer.DisplayName = table.Name; gLayer.GraphicsSource = graphics; gLayer.geometryType = (IS3.Core.Geometry.GeometryType)(int)table.GeometryType; return gLayer; }