private async void Initialize()
{
// Create new Map with basemap
var myMap = new Map(Basemap.CreateTopographic());
// Create envelope to be used as a target extent for map's initial viewpoint
Envelope myEnvelope = new Envelope(
-1131596.019761, 3893114.069099, 3926705.982140, 7977912.461790,
SpatialReferences.WebMercator);
// Set the initial viewpoint for map
myMap.InitialViewpoint = new Viewpoint(myEnvelope);
// Provide used Map to the MapView
MyMapView.Map = myMap;
// Create Uri for the feature service
Uri featureServiceUri = new Uri(
"http://sampleserver6.arcgisonline.com/arcgis/rest/services/DamageAssessment/FeatureServer/0");
// Initialize feature table using a url to feature server url
var featureTable = new ServiceFeatureTable(featureServiceUri);
// Initialize a new feature layer based on the feature table
_featureLayer = new FeatureLayer(featureTable);
// Set the selection color for feature layer
_featureLayer.SelectionColor = Colors.Cyan;
// Set the selection width
_featureLayer.SelectionWidth = 3;
// Make sure that used feature layer is loaded before we hook into the tapped event
// This prevents us trying to do selection on the layer that isn't initialized
await _featureLayer.LoadAsync();
// Check for the load status. If the layer is loaded then add it to map
if (_featureLayer.LoadStatus == LoadStatus.Loaded)
{
// Add the feature layer to the map
myMap.OperationalLayers.Add(_featureLayer);
// Add tap event handler for mapview
MyMapView.GeoViewTapped += OnMapViewTapped;
}
}