private async void OnZoomClick(object sender, EventArgs e) { try { // Initiate task to zoom both map views in. Task t1 = StaticMapView.SetViewpointAsync(_zoomInPoint, TimeSpan.FromSeconds(5)); Task t2 = DynamicMapView.SetViewpointAsync(_zoomInPoint, TimeSpan.FromSeconds(5)); await Task.WhenAll(t1, t2); // Delay start of next set of zoom tasks. await Task.Delay(2000); // Initiate task to zoom both map views out. Task t3 = StaticMapView.SetViewpointAsync(_zoomOutPoint, TimeSpan.FromSeconds(5)); Task t4 = DynamicMapView.SetViewpointAsync(_zoomOutPoint, TimeSpan.FromSeconds(5)); await Task.WhenAll(t3, t4); } catch (Exception ex) { await Application.Current.MainPage.DisplayAlert("Error", ex.ToString(), "OK"); } }
private void Initialize() { // Create maps for the map views. StaticMapView.Map = new Map(); DynamicMapView.Map = new Map(); // Create service feature table using a point, polyline, and polygon service. ServiceFeatureTable pointServiceFeatureTable = new ServiceFeatureTable(new Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/Energy/Geology/FeatureServer/0")); ServiceFeatureTable polylineServiceFeatureTable = new ServiceFeatureTable(new Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/Energy/Geology/FeatureServer/8")); ServiceFeatureTable polygonServiceFeatureTable = new ServiceFeatureTable(new Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/Energy/Geology/FeatureServer/9")); // Create feature layers from service feature tables List <FeatureLayer> featureLayers = new List <FeatureLayer> { new FeatureLayer(pointServiceFeatureTable), new FeatureLayer(polylineServiceFeatureTable), new FeatureLayer(polygonServiceFeatureTable) }; // Add each layer to the map as a static layer and a dynamic layer foreach (FeatureLayer layer in featureLayers) { // Add the static layer to the top map view layer.RenderingMode = FeatureRenderingMode.Static; StaticMapView.Map.OperationalLayers.Add(layer); // Add the dynamic layer to the bottom map view FeatureLayer dynamicLayer = (FeatureLayer)layer.Clone(); dynamicLayer.RenderingMode = FeatureRenderingMode.Dynamic; DynamicMapView.Map.OperationalLayers.Add(dynamicLayer); } // Set the view point of both MapViews. StaticMapView.SetViewpoint(_zoomOutPoint); DynamicMapView.SetViewpoint(_zoomOutPoint); }