private async void GetFeaturesFromQuery() { // Create a service feature table to get features from ServiceFeatureTable featTable = new ServiceFeatureTable(new Uri(FeatureLayerUrl)); // Create a query to get all features in the table QueryParameters queryParams = new QueryParameters(); queryParams.WhereClause = "1=1"; // Query the table to get all features FeatureQueryResult featureResult = await featTable.QueryFeaturesAsync(queryParams); // Create a new feature collection table from the result features FeatureCollectionTable collectTable = new FeatureCollectionTable(featureResult); // Create a feature collection and add the table FeatureCollection featCollection = new FeatureCollection(); featCollection.Tables.Add(collectTable); // Create a layer to display the feature collection, add it to the map's operational layers FeatureCollectionLayer featCollectionTable = new FeatureCollectionLayer(featCollection); _myMapView.Map.OperationalLayers.Add(featCollectionTable); }
private async void OpenFeaturesFromArcGISOnline(string itemId) { try { // Open a portal item containing a feature collection ArcGISPortal portal = await ArcGISPortal.CreateAsync(); PortalItem collectionItem = await PortalItem.CreateAsync(portal, itemId); // Verify that the item is a feature collection if (collectionItem.Type == PortalItemType.FeatureCollection) { // Create a new FeatureCollection from the item FeatureCollection featCollection = new FeatureCollection(collectionItem); // Create a layer to display the collection and add it to the map as an operational layer FeatureCollectionLayer featCollectionLayer = new FeatureCollectionLayer(featCollection); featCollectionLayer.Name = collectionItem.Title; MyMapView.Map.OperationalLayers.Add(featCollectionLayer); } else { MessageBox.Show("Portal item with ID '" + itemId + "' is not a feature collection.", "Feature Collection"); } } catch (Exception ex) { MessageBox.Show("Unable to open item with ID '" + itemId + "': " + ex.Message, "Error"); } }
private async void GetFeaturesFromQuery() { try { // Create a service feature table to get features from ServiceFeatureTable featTable = new ServiceFeatureTable(new Uri(FeatureLayerUrl)); // Create a query to get all features in the table QueryParameters queryParams = new QueryParameters { WhereClause = "1=1" }; // Query the table to get all features FeatureQueryResult featureResult = await featTable.QueryFeaturesAsync(queryParams); // Create a new feature collection table from the result features FeatureCollectionTable collectTable = new FeatureCollectionTable(featureResult); // Create a feature collection and add the table FeatureCollection featCollection = new FeatureCollection(); featCollection.Tables.Add(collectTable); // Create a layer to display the feature collection, add it to the map's operational layers FeatureCollectionLayer featCollectionTable = new FeatureCollectionLayer(featCollection); MyMapView.Map.OperationalLayers.Add(featCollectionTable); } catch (Exception e) { await new MessageDialog2(e.ToString(), "Error").ShowAsync(); } }
private async void OpenFeaturesFromArcGISOnline(string collectionItemId) { try { // Create a portal item PortalItem collectionItem = await PortalItem.CreateAsync(_portal, collectionItemId); // Verify that the item is a feature collection and add to the map if (collectionItem.Type == PortalItemType.FeatureCollection) { // Create a new FeatureCollection from the item _featCollection = new FeatureCollection(collectionItem); // Create a layer to display the collection and add it to the map as an operational layer _featCollectionLayer = new FeatureCollectionLayer(_featCollection); // Add the feature collection layer to the map MyMapView.Map.OperationalLayers.Add(_featCollectionLayer); } else { MessageBox.Show("Portal item with ID '" + collectionItemId + "' is not a feature collection.", "Feature Collection"); } } catch (Exception ex) { MessageBox.Show("Unable to open item with ID '" + collectionItemId + "': " + ex.Message, "Error"); } }
private async void OpenFeaturesFromArcGISOnline(string itemId) { try { // Open a portal item containing a feature collection ArcGISPortal portal = await ArcGISPortal.CreateAsync(); PortalItem collectionItem = await PortalItem.CreateAsync(portal, itemId); // Verify that the item is a feature collection if (collectionItem.Type == PortalItemType.FeatureCollection) { // Create a new FeatureCollection from the item FeatureCollection featCollection = new FeatureCollection(collectionItem); // Create a layer to display the collection and add it to the map as an operational layer FeatureCollectionLayer featCollectionLayer = new FeatureCollectionLayer(featCollection); featCollectionLayer.Name = collectionItem.Title; MyMapView.Map.OperationalLayers.Add(featCollectionLayer); } else { MessageBox.Show("Portal item with ID '" + itemId + "' is not a feature collection.", "Feature Collection"); } } catch (Exception ex) { MessageBox.Show("Unable to open item with ID '" + itemId + "': " + ex.Message, "Error"); } }
private async void OpenFeaturesFromArcGISOnline(string itemId) { try { // Open a portal item containing a feature collection. ArcGISPortal portal = await ArcGISPortal.CreateAsync(); PortalItem collectionItem = await PortalItem.CreateAsync(portal, itemId); // Verify that the item is a feature collection. if (collectionItem.Type == PortalItemType.FeatureCollection) { // Create a new FeatureCollection from the item. FeatureCollection featureCollection = new FeatureCollection(collectionItem); // Create a layer to display the collection and add it to the map as an operational layer. FeatureCollectionLayer featureCollectionLayer = new FeatureCollectionLayer(featureCollection) { Name = collectionItem.Title }; _myMapView.Map.OperationalLayers.Add(featureCollectionLayer); } else { var alert = new UIAlertView("Feature Collection", "Portal item with ID '" + itemId + "' is not a feature collection.", (IUIAlertViewDelegate)null, "OK"); alert.Show(); } } catch (Exception ex) { var alert = new UIAlertView("Error", "Unable to open item with ID '" + itemId + "': " + ex.Message, (IUIAlertViewDelegate)null, "OK"); alert.Show(); } }
private async void GetFeaturesFromQuery() { // Create a service feature table to get features from. ServiceFeatureTable featTable = new ServiceFeatureTable(new Uri(FeatureLayerUrl)); // Create a query to get all features in the table. QueryParameters queryParams = new QueryParameters { WhereClause = "1=1" }; // Query the table to get all features. FeatureQueryResult featureResult = await featTable.QueryFeaturesAsync(queryParams); // Create a new feature collection table from the result features. FeatureCollectionTable collectTable = new FeatureCollectionTable(featureResult); // Create a feature collection and add the table. FeatureCollection featCollection = new FeatureCollection(); featCollection.Tables.Add(collectTable); // Create a layer to display the feature collection, add it to the map's operational layers. FeatureCollectionLayer featureCollectionLayer = new FeatureCollectionLayer(featCollection); _myMapView.Map.OperationalLayers.Add(featureCollectionLayer); // Zoom to the extent of the feature collection layer. await featureCollectionLayer.LoadAsync(); await _myMapView.SetViewpointGeometryAsync(featureCollectionLayer.FullExtent, 50); }
private async void LoadByFeatureCollectionLayer() { FeatureCollection featCollection = new FeatureCollection(); FeatureCollectionLayer layer = new FeatureCollectionLayer(featCollection); if (layer.Layers != null) { layer.Layers.Select(x => x.RenderingMode = FeatureRenderingMode.Dynamic); } MyMapView.Map.OperationalLayers.Add(layer); foreach (var tab in MyGeoPackage.GeoPackageFeatureTables)// Where(x => x.TableName.Contains("polygon")).ToList(); { var queryPts = new QueryParameters(); //queryPts.Geometry = MyMapView.VisibleArea; //queryPts.WhereClause = @" 1 = 1 "; var featureResult = await tab.QueryFeaturesAsync(queryPts); FeatureCollectionTable collectTable = new FeatureCollectionTable(featureResult); featCollection.Tables.Add(collectTable); } }
private async void CollectionLayer_Loaded(object sender, EventArgs e) { FeatureCollectionLayer collectionLayer = (FeatureCollectionLayer)sender; await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { MyMapView.SetViewpointAsync(new Viewpoint(collectionLayer.FullExtent)); }); }
private async void SaveFeatureCollectionFromQuery() { Debug.WriteLine("Creating feature collection from the service..."); // Create a service feature table to get features from ServiceFeatureTable featTable = new ServiceFeatureTable(new Uri(FeatureLayerUrl)); // Create a query to get all features in the table QueryParameters queryParams = new QueryParameters(); queryParams.WhereClause = "1=1"; // Query the table to get all features FeatureQueryResult featureResult = await featTable.QueryFeaturesAsync(queryParams); // Create a new feature collection table from the result features FeatureCollectionTable collectTable = new FeatureCollectionTable(featureResult); // Create a feature collection and add the table FeatureCollection featCollection = new FeatureCollection(); featCollection.Tables.Add(collectTable); var tokenServiceUri = new Uri("https://www.arcgis.com/sharing/rest"); // url for generating token AuthenticationManager authManager = AuthenticationManager.Current; var cred = await authManager.GenerateCredentialAsync(tokenServiceUri, "*******", "*******"); // Open a portal item containing a feature collection ArcGISPortal portal = await ArcGISPortal.CreateAsync(tokenServiceUri, cred); List <string> str = new List <string>(); str.Add("Save Feature collection"); FeatureCollectionLayer featCollectionTable = new FeatureCollectionLayer(featCollection); await featCollectionTable.LoadAsync(); MyMapView.Map.OperationalLayers.Add(featCollectionTable); Debug.WriteLine("Create a feature layer named, Feature Collection to Portal, and saving to portal..."); try { await featCollection.SaveAsAsync(portal, null, "Feature Collection to Portal", "FeatureCollection", str); MessageBox.Show("Feature Collection saved to portal"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private async void AddFeature(MapPoint mapClickPoint) { // Grab the feature collection from the operational layers and create a feature collection layer _featCollectionLayer = (FeatureCollectionLayer)MyMapView.Map.OperationalLayers[0]; // Get the points table from the feature collection layer and add to the feature collection table for editing _featCollectionTable = (FeatureCollectionTable)_featCollectionLayer.Layers[1].FeatureTable; // Create a feature Feature f = _featCollectionTable.CreateFeature(); // Populate the feature's geometry with the map point coords f.Geometry = mapClickPoint; // Add the feature to the feature collection table await _featCollectionTable.AddFeatureAsync(f); }
private async void GetFeaturesFromQuery() { // Create a service feature table to get features from ServiceFeatureTable featTable = new ServiceFeatureTable(new Uri(FeatureLayerUrl)); // Create a query to get all features in the table QueryParameters queryParams = new QueryParameters(); queryParams.WhereClause = "1=1"; // Query the table to get all features FeatureQueryResult featureResult = await featTable.QueryFeaturesAsync(queryParams); // Create a new feature collection table from the result features FeatureCollectionTable collectTable = new FeatureCollectionTable(featureResult); // Create a feature collection and add the table FeatureCollection featCollection = new FeatureCollection(); featCollection.Tables.Add(collectTable); // Create a layer to display the feature collection, add it to the map's operational layers FeatureCollectionLayer featCollectionTable = new FeatureCollectionLayer(featCollection); MyMapView.Map.OperationalLayers.Add(featCollectionTable); }
private async void OpenFeaturesFromArcGISOnline(string itemId) { try { // Open a portal item containing a feature collection var portal = await ArcGISPortal.CreateAsync(); var collectionItem = await PortalItem.CreateAsync(portal, itemId); // Verify that the item is a feature collection if (collectionItem.Type == PortalItemType.FeatureCollection) { // Create a new FeatureCollection from the item var featureCollection = new FeatureCollection(collectionItem); // Create a layer to display the collection and add it to the map as an operational layer var featureCollectionLayer = new FeatureCollectionLayer(featureCollection); featureCollectionLayer.Name = collectionItem.Title; _myMapView.Map.OperationalLayers.Add(featureCollectionLayer); } else { var alertBuilder = new AlertDialog.Builder(this); alertBuilder.SetTitle("Feature Collection"); alertBuilder.SetMessage("Portal item with ID '" + itemId + "' is not a feature collection."); alertBuilder.Show(); } } catch (Exception ex) { var alertBuilder = new AlertDialog.Builder(this); alertBuilder.SetTitle("Error"); alertBuilder.SetMessage("Unable to open item with ID '" + itemId + "': " + ex.Message); alertBuilder.Show(); } }
private async void OpenFeaturesFromArcGISOnline(string itemId) { try { // Open a portal item containing a feature collection var portal = await ArcGISPortal.CreateAsync(); var collectionItem = await PortalItem.CreateAsync(portal, itemId); // Verify that the item is a feature collection if (collectionItem.Type == PortalItemType.FeatureCollection) { // Create a new FeatureCollection from the item var featureCollection = new FeatureCollection(collectionItem); // Create a layer to display the collection and add it to the map as an operational layer var featureCollectionLayer = new FeatureCollectionLayer(featureCollection); featureCollectionLayer.Name = collectionItem.Title; _myMapView.Map.OperationalLayers.Add(featureCollectionLayer); } else { var alertBuilder = new AlertDialog.Builder(this); alertBuilder.SetTitle("Feature Collection"); alertBuilder.SetMessage("Portal item with ID '" + itemId + "' is not a feature collection."); alertBuilder.Show(); } } catch (Exception ex) { var alertBuilder = new AlertDialog.Builder(this); alertBuilder.SetTitle("Error"); alertBuilder.SetMessage("Unable to open item with ID '" + itemId + "': " + ex.Message); alertBuilder.Show(); } }
private async void CreateNewFeatureCollection() { // Create the schema for a points table (one text field to contain a name attribute). List <Field> pointFields = new List <Field>(); Field placeField = new Field(FieldType.Text, "Place", "Place Name", 50); pointFields.Add(placeField); // Create the schema for a lines table (one text field to contain a name attribute). List <Field> lineFields = new List <Field>(); Field boundaryField = new Field(FieldType.Text, "Boundary", "Boundary Name", 50); lineFields.Add(boundaryField); // Create the schema for a polygon table (one text field to contain a name attribute). List <Field> polyFields = new List <Field>(); Field areaField = new Field(FieldType.Text, "AreaName", "Area Name", 50); polyFields.Add(areaField); // Instantiate FeatureCollectionTables with schema and geometry type. FeatureCollectionTable pointsTable = new FeatureCollectionTable(pointFields, GeometryType.Point, SpatialReferences.Wgs84); FeatureCollectionTable linesTable = new FeatureCollectionTable(lineFields, GeometryType.Polyline, SpatialReferences.Wgs84); FeatureCollectionTable polysTable = new FeatureCollectionTable(polyFields, GeometryType.Polygon, SpatialReferences.Wgs84); // Set rendering for each table. pointsTable.Renderer = CreateRenderer(GeometryType.Point); linesTable.Renderer = CreateRenderer(GeometryType.Polyline); polysTable.Renderer = CreateRenderer(GeometryType.Polygon); // Create a new point feature, provide geometry and attribute values. Feature pointFeature = pointsTable.CreateFeature(); pointFeature.SetAttributeValue(placeField, "Current location"); MapPoint point1 = new MapPoint(-79.497238, 8.849289, SpatialReferences.Wgs84); pointFeature.Geometry = point1; // Create a new line feature, provide geometry and attribute values. Feature lineFeature = linesTable.CreateFeature(); lineFeature.SetAttributeValue(boundaryField, "AManAPlanACanalPanama"); MapPoint point2 = new MapPoint(-80.035568, 9.432302, SpatialReferences.Wgs84); lineFeature.Geometry = new Polyline(new[] { point1, point2 }); // Create a new polygon feature, provide geometry and attribute values. Feature polyFeature = polysTable.CreateFeature(); polyFeature.SetAttributeValue(areaField, "Restricted area"); MapPoint point3 = new MapPoint(-79.337936, 8.638903, SpatialReferences.Wgs84); MapPoint point4 = new MapPoint(-79.11409, 8.895422, SpatialReferences.Wgs84); polyFeature.Geometry = new Polygon(new[] { point1, point3, point4 }); // Add the new features to the appropriate feature collection table. await pointsTable.AddFeatureAsync(pointFeature); await linesTable.AddFeatureAsync(lineFeature); await polysTable.AddFeatureAsync(polyFeature); // Create a feature collection and add the feature collection tables. FeatureCollection featuresCollection = new FeatureCollection(); featuresCollection.Tables.Add(pointsTable); featuresCollection.Tables.Add(linesTable); featuresCollection.Tables.Add(polysTable); // Create a FeatureCollectionLayer. FeatureCollectionLayer collectionLayer = new FeatureCollectionLayer(featuresCollection); // When the layer loads, zoom the map view to the extent of the feature collection. collectionLayer.Loaded += (s, e) => _myMapView.SetViewpointAsync(new Viewpoint(collectionLayer.FullExtent)); // Add the layer to the Map's Operational Layers collection. _myMapView.Map.OperationalLayers.Add(collectionLayer); }
private async void CreateNewFeatureCollection() { // Create the schema for a points table (one text field to contain a name attribute) List <Field> pointFields = new List <Field>(); Field placeField = new Field(FieldType.Text, "Place", "Place Name", 50); pointFields.Add(placeField); // Create the schema for a lines table (one text field to contain a name attribute) List <Field> lineFields = new List <Field>(); Field boundaryField = new Field(FieldType.Text, "Boundary", "Boundary Name", 50); lineFields.Add(boundaryField); // Create the schema for a polygon table (one text field to contain a name attribute) List <Field> polyFields = new List <Field>(); Field areaField = new Field(FieldType.Text, "AreaName", "Area Name", 50); polyFields.Add(areaField); // Instantiate FeatureCollectionTables with schema and geometry type FeatureCollectionTable pointsTable = new FeatureCollectionTable(pointFields, GeometryType.Point, SpatialReferences.Wgs84); FeatureCollectionTable linesTable = new FeatureCollectionTable(lineFields, GeometryType.Polyline, SpatialReferences.Wgs84); FeatureCollectionTable polysTable = new FeatureCollectionTable(polyFields, GeometryType.Polygon, SpatialReferences.Wgs84); // Set rendering for each table pointsTable.Renderer = CreateRenderer(GeometryType.Point); linesTable.Renderer = CreateRenderer(GeometryType.Polyline); polysTable.Renderer = CreateRenderer(GeometryType.Polygon); // Create a new point feature, provide geometry and attribute values Feature pointFeature = pointsTable.CreateFeature(); pointFeature.SetAttributeValue(placeField, "Current location"); MapPoint point1 = new MapPoint(-79.497238, 8.849289, SpatialReferences.Wgs84); pointFeature.Geometry = point1; // Create a new line feature, provide geometry and attribute values Feature lineFeature = linesTable.CreateFeature(); lineFeature.SetAttributeValue(boundaryField, "AManAPlanACanalPanama"); MapPoint point2 = new MapPoint(-80.035568, 9.432302, SpatialReferences.Wgs84); Polyline line = new Polyline(new MapPoint[] { point1, point2 }); lineFeature.Geometry = line; // Create a new polygon feature, provide geometry and attribute values Feature polyFeature = polysTable.CreateFeature(); polyFeature.SetAttributeValue(areaField, "Restricted area"); MapPoint point3 = new MapPoint(-79.337936, 8.638903, SpatialReferences.Wgs84); MapPoint point4 = new MapPoint(-79.11409, 8.895422, SpatialReferences.Wgs84); Polygon poly = new Polygon(new MapPoint[] { point1, point3, point4 }); polyFeature.Geometry = poly; try { // Add the new features to the appropriate feature collection table await pointsTable.AddFeatureAsync(pointFeature); await linesTable.AddFeatureAsync(lineFeature); await polysTable.AddFeatureAsync(polyFeature); // Create a feature collection and add the feature collection tables FeatureCollection featuresCollection = new FeatureCollection(); featuresCollection.Tables.Add(pointsTable); featuresCollection.Tables.Add(linesTable); featuresCollection.Tables.Add(polysTable); // Create a FeatureCollectionLayer FeatureCollectionLayer collectionLayer = new FeatureCollectionLayer(featuresCollection); // When the layer loads, zoom the map centered on the feature collection await collectionLayer.LoadAsync(); await _myMapView.SetViewpointCenterAsync(collectionLayer.FullExtent.GetCenter(), 1000000); // Add the layer to the Map's Operational Layers collection _myMapView.Map.OperationalLayers.Add(collectionLayer); } catch (Exception e) { new AlertDialog.Builder(this).SetMessage(e.ToString()).SetTitle("Error").Show(); } }
private async void CreateNewFeatureCollection() { // Create the schema for a points table (one text field to contain a name attribute) List<Field> pointFields = new List<Field>(); Field placeField = new Field(FieldType.Text, "Place", "Place Name", 50); pointFields.Add(placeField); // Create the schema for a lines table (one text field to contain a name attribute) List<Field> lineFields = new List<Field>(); Field boundaryField = new Field(FieldType.Text, "Boundary", "Boundary Name", 50); lineFields.Add(boundaryField); // Create the schema for a polygon table (one text field to contain a name attribute) List<Field> polyFields = new List<Field>(); Field areaField = new Field(FieldType.Text, "AreaName", "Area Name", 50); polyFields.Add(areaField); // Instantiate FeatureCollectionTables with schema and geometry type FeatureCollectionTable pointsTable = new FeatureCollectionTable(pointFields, GeometryType.Point, SpatialReferences.Wgs84); FeatureCollectionTable linesTable = new FeatureCollectionTable(lineFields, GeometryType.Polyline, SpatialReferences.Wgs84); FeatureCollectionTable polysTable = new FeatureCollectionTable(polyFields, GeometryType.Polygon, SpatialReferences.Wgs84); // Set rendering for each table pointsTable.Renderer = CreateRenderer(GeometryType.Point); linesTable.Renderer = CreateRenderer(GeometryType.Polyline); polysTable.Renderer = CreateRenderer(GeometryType.Polygon); // Create a new point feature, provide geometry and attribute values Feature pointFeature = pointsTable.CreateFeature(); pointFeature.SetAttributeValue(placeField, "Current location"); MapPoint point1 = new MapPoint(-79.497238, 8.849289, SpatialReferences.Wgs84); pointFeature.Geometry = point1; // Create a new line feature, provide geometry and attribute values Feature lineFeature = linesTable.CreateFeature(); lineFeature.SetAttributeValue(boundaryField, "AManAPlanACanalPanama"); MapPoint point2 = new MapPoint(-80.035568, 9.432302, SpatialReferences.Wgs84); Polyline line = new Polyline(new MapPoint[] { point1, point2 }); lineFeature.Geometry = line; // Create a new polygon feature, provide geometry and attribute values Feature polyFeature = polysTable.CreateFeature(); polyFeature.SetAttributeValue(areaField, "Restricted area"); MapPoint point3 = new MapPoint(-79.337936, 8.638903, SpatialReferences.Wgs84); MapPoint point4 = new MapPoint(-79.11409, 8.895422, SpatialReferences.Wgs84); Polygon poly = new Polygon(new MapPoint[] { point1, point3, point4 }); polyFeature.Geometry = poly; // Add the new features to the appropriate feature collection table await pointsTable.AddFeatureAsync(pointFeature); await linesTable.AddFeatureAsync(lineFeature); await polysTable.AddFeatureAsync(polyFeature); // Create a feature collection and add the feature collection tables FeatureCollection featuresCollection = new FeatureCollection(); featuresCollection.Tables.Add(pointsTable); featuresCollection.Tables.Add(linesTable); featuresCollection.Tables.Add(polysTable); // Create a FeatureCollectionLayer FeatureCollectionLayer collectionLayer = new FeatureCollectionLayer(featuresCollection); // When the layer loads, zoom the map view to the extent of the feature collection collectionLayer.Loaded += CollectionLayer_Loaded; // Add the layer to the Map's Operational Layers collection MyMapView.Map.OperationalLayers.Add(collectionLayer); }
private async void CreateFeatureCollectionLayerFromNYTimesArticles() { // Read the NY Times data from the text file and get back a list of each article. // The format of each record/article will look like: // [Article summary]~[Article abstract]~[Country name]~[Url to the NY times article]~[Url to an image about the NY times article]~[Date of NY Times news article] // Ex: // Netanyahu not happy with Cohen~A spokesman for Prime Minister Benjamin Netanyahu disagrees with Roger Cohen’s “pessimism.”~Israel~https://www.nytimes.com/2018/01/02/opinion/israel-future.html~https://www.nytimes.com/images/2017/12/29/opinion/29cohenWeb/29cohenWeb-thumbLarge.jpg~20180102 List <string> myNYTimesArticles = ReadTextFile3(_NEWSFILE); // Get the collection of all the layers in the map. var myMapAllLayers = MyMapView.Map.AllLayers; // Create a place holder for the world countries feature layer. FeatureLayer myFeatureLayer = null; // Loop through all of the layers. foreach (var myLayer in myMapAllLayers) { // Get the Id of the layer. string myLayerName = myLayer.Id; // If the layer id matches world countries set that to the feature layer. if (myLayerName == "WorldCountries") { myFeatureLayer = (FeatureLayer)myLayer; } } // Get the feature table from the world countries shape file feature layer. FeatureTable myFeatureTable = myFeatureLayer.FeatureTable; // Create a new query parameters. QueryParameters myQueryParameters = new QueryParameters(); // Define the where clause for the query parameters. It will select all the records in the world countries shape file feature table. myQueryParameters.WhereClause = "1 = 1"; // Execute the feature query and get the results back. It will select all the records in the world countries shape file feature table. FeatureQueryResult myFeatureQueryResult = await myFeatureTable.QueryFeaturesAsync(myQueryParameters); // Create the schema for the polygon feature collection table. List <Field> myFeatureCollectionAttributeFields = new List <Field>(); // Create a field for the feature collection layer. It will contain a text field called area name that is the county name. Field myAreaNameField = new Field(FieldType.Text, "AreaName", "Area Name", 50); // Add the country name field to the list of fields that will be added to the feature collection table. myFeatureCollectionAttributeFields.Add(myAreaNameField); // Create the feature collection table based on the list of attribute fields, a polygons feature type FeatureCollectionTable myFeatureCollectionTable = new FeatureCollectionTable(myFeatureCollectionAttributeFields, GeometryType.Polygon, SpatialReferences.Wgs84); // Create the outline symbol for the country fill symbol. SimpleLineSymbol mySimpleLineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.DarkBlue, 2); // Create the fill symbol for the country. Solid yellow, with dark blue outline. SimpleFillSymbol mySimpleFillSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, Color.Yellow, mySimpleLineSymbol); // Set the renderer of the feature collection table to be the simple fill symbol. myFeatureCollectionTable.Renderer = new SimpleRenderer(mySimpleFillSymbol); // Loop through each feature in the returned feature query results of the world countries shape file foreach (Feature myFeature in myFeatureQueryResult) { // Get the geometry (aka shape) for one feature. Geometry myGeometry = myFeature.Geometry; // Get the value (aka. the text for the record of a specific field). var myValue = (string)myFeature.Attributes["NAME"]; // Loop through each NY Times article. foreach (string oneNYTimesArticle in myNYTimesArticles) { // Remove an embedded double quotes that may be in or surrounding the country name in the NY Times data base. char[] charsToTrim = { '"' }; string country = oneNYTimesArticle.Split('~')[2].Trim(charsToTrim); // Find a match from the shape file country feature and the NY Times country name in the article. if ((string)myValue == country) { // Create a new polygon feature, provide geometry and attribute values. Feature polyFeature = myFeatureCollectionTable.CreateFeature(); polyFeature.SetAttributeValue(myAreaNameField, country); polyFeature.Geometry = myGeometry; // Add the new features to the appropriate feature collection table. await myFeatureCollectionTable.AddFeatureAsync(polyFeature); // Once we have found a matching country in the subset news article file that matches a shape file record // there is no need to find another one since we have just created a record in the FeatureCollectionTable. break; } } } // Create a feature collection and add the feature collection tables FeatureCollection myFeatureCollection = new FeatureCollection(); myFeatureCollection.Tables.Add(myFeatureCollectionTable); // Create a FeatureCollectionLayer FeatureCollectionLayer myFeatureCollectionLayer = new FeatureCollectionLayer(myFeatureCollection); myFeatureCollectionLayer.Id = "Joined"; // might not be needed myFeatureCollectionLayer.Name = "JoinedFCL"; // When the layer loads, zoom the map centered on the feature collection await myFeatureCollectionLayer.LoadAsync(); // Add the layer to the Map's Operational Layers collection MyMapView.Map.OperationalLayers.Add(myFeatureCollectionLayer); }