protected async override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.PopupViewerSample); // Used in Callout to see feature details in PopupViewer _infoIcon = await RuntimeImage.FromStreamAsync(Assets.Open("info.png")); // Used to demonstrate display of EditSummary in PopupViewer // Provides credentials to token-secured layer that has editor-tracking enabled AuthenticationManager.Current.ChallengeHandler = new ChallengeHandler(async(info) => { return(await AuthenticationManager.Current.GenerateCredentialAsync(info.ServiceUri, "user1", "user1")); }); mapView = FindViewById <MapView>(Resource.Id.mapView); mapView.Map = new Map(Basemap.CreateLightGrayCanvasVector()); mapView.GeoViewTapped += mapView_GeoViewTapped; // Webmap configured with Popup mapView.Map = new Map(new Uri("https://www.arcgis.com/home/item.html?id=d4fe39d300c24672b1821fa8450b6ae2")); popupViewer = FindViewById <UI.Controls.PopupViewer>(Resource.Id.popupViewer); }
private async void LoadService(string uri) { var client = await StreamServiceClient.CreateAsync(new Uri(uri)); client.FeatureTimeout = TimeSpan.FromMinutes(5); // Removes any features that hasn't reported back in over 5 minutes client.OnUpdate += Client_OnUpdate; // Create overlay for rendering updates var si = typeof(LocationDisplay).Assembly.GetManifestResourceStream("Esri.ArcGISRuntime.Esri.ArcGISRuntime.LocationDisplayCourse.scale-200.png"); var ri = await RuntimeImage.FromStreamAsync(si); PictureMarkerSymbol vehicleSymbol = new PictureMarkerSymbol(ri) { Width = 25, Height = 25 }; var overlay = new Esri.ArcGISRuntime.UI.GraphicsOverlay() { Renderer = new SimpleRenderer(vehicleSymbol), SceneProperties = new LayerSceneProperties(SurfacePlacement.Absolute) //In case we use it in 3D and have Z values }; var headingField = client.ServiceInfo.Fields.Where(f => f.Name.ToLower() == "heading").Select(f => f.Name).FirstOrDefault(); if (!string.IsNullOrEmpty(headingField)) { overlay.Renderer.RotationExpression = $"[{headingField}]"; overlay.Renderer.SceneProperties.HeadingExpression = $"[{headingField}]"; } mapView.GraphicsOverlays.Add(overlay); client.Overlay = overlay; // Connect await client.ConnectAsync(); }
/// <summary> /// Initializes and if necessary provisions the data needed for the application /// </summary> /// <returns></returns> public async Task LoadAsync() { try { await ProvisionDataAsync(); } catch (System.Exception ex) { UpdateLoadStatus("Failed to provision data:\n" + ex.Message); } UpdateLoadStatus("Initializing map..."); GeocodeHelper.Initialize(); PictureMarkerSymbol a; PictureMarkerSymbol b; using (var markera = typeof(MapViewModel).Assembly.GetManifestResourceStream("OfficeLocator.Core.MarkerA.png")) { a = new PictureMarkerSymbol(await RuntimeImage.FromStreamAsync(markera)) { Width = 20, Height = 20 }; } using (var markerb = typeof(MapViewModel).Assembly.GetManifestResourceStream("OfficeLocator.Core.MarkerB.png")) { b = new PictureMarkerSymbol(await RuntimeImage.FromStreamAsync(markerb)) { Width = 20, Height = 20 }; } Overlays[1].Graphics.Add(new Graphic() { Symbol = a }); //From Overlays[1].Graphics.Add(new Graphic() { Symbol = b }); //To try { await InitializeMap(); InitializeScene(); IsLoaded = true; UpdateLoadStatus(""); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsLoaded))); DoStartupZoomIn(); } catch (System.Exception ex) { System.Diagnostics.Debug.WriteLine($"An unexpected error occured while loading the map: {ex.Message}"); UpdateLoadStatus(ex.Message); } }