public ArcGisPortalWebMapListBoxItem(ArcGisPortalWebMapItem arcGisPortalWebMapItem, RelayCommand<ArcGisPortalWebMapItem> loadWebMapCommand, RelayCommand<ArcGisPortalWebMapItem> createOfflineMapCommand) { _arcGisPortalWebMapItem = arcGisPortalWebMapItem; _loadWebMapCommand = loadWebMapCommand; _createOfflineMapCommand = createOfflineMapCommand; }
public void TriggerCreateOfflineMapEvent(ArcGisPortalWebMapItem arcGisPortalWebMapItem, ArcGISPortal arcGisPortal) { CreateOfflineMap(arcGisPortalWebMapItem, arcGisPortal); }
private async void SearchArcgisOnline() { try { IsBusy = true; //create Portal instance try { _arcGisPortal = await ArcGISPortal.CreateAsync(_model.DefaultServerUri); } catch (ArcGISWebException agwex) { _model.SetMessageInfo(agwex.Message); if ((int) agwex.Code == 498) { MessageBox.Show("Der Token ist abgelaufen"); } return; } //define search creteria var sb = new StringBuilder(); sb.Append(string.Format("{0} ", SearchText)); sb.Append("type:(\"web map\" NOT \"web mapping application\") "); sb.Append("typekeywords:(\"offline\") "); if (_arcGisPortal.CurrentUser != null && _arcGisPortal.ArcGISPortalInfo != null && !string.IsNullOrEmpty(_arcGisPortal.ArcGISPortalInfo.Id)) { sb.Append(string.Format("orgid:(\"{0}\")", _arcGisPortal.ArcGISPortalInfo.Id)); } var searchParams = new SearchParameters(sb.ToString()) { Limit = 20, SortField = "avgrating", SortOrder = QuerySortOrder.Descending, }; //search for items var result = await _arcGisPortal.SearchItemsAsync(searchParams); //rate the result items foreach (var item in result.Results.Where(x => x.TypeKeywords.Contains("Offline"))) { try { var webMap = await WebMap.FromPortalItemAsync(item); bool isEditable = false; bool isSyncable = false; if (webMap.OperationalLayers.Count > 0) { foreach (var operationalLayer in webMap.OperationalLayers) { if (!operationalLayer.Url.Contains("FeatureServer")) continue; var featureLayer = new FeatureLayer(new Uri(operationalLayer.Url)); await featureLayer.InitializeAsync(); var serviceFeatureTable = featureLayer.FeatureTable as ServiceFeatureTable; var capabilities = serviceFeatureTable.ServiceInfo.Capabilities; foreach (var capability in capabilities) { if (capability == "Editing") { isEditable = true; } if (capability == "Sync") { isSyncable = true; } } if (isEditable) { var arcGisPortalWebMapItem = new ArcGisPortalWebMapItem(item, webMap, isEditable, isSyncable); ArcGisPortalWebMapListBoxItems.Add(new ArcGisPortalWebMapListBoxItem(arcGisPortalWebMapItem, LoadWebMapCommand, CreateOfflineMapCommand)); break; } } } } catch { } } } finally { IsBusy = false; } }
private async void LoadMap(ArcGisPortalWebMapItem arcGisPortalWebMapItem, ArcGISPortal arcGisPortal) { _currentArcGisPortalWebMapItem = arcGisPortalWebMapItem; _graphicsOverlay = new GraphicsOverlay(); _graphicsOverlay.Renderer = new SimpleRenderer(); var vm = await WebMapViewModel.LoadAsync(arcGisPortalWebMapItem.WebMap, arcGisPortal); var mapView = new MapView {Map = vm.Map}; mapView.GraphicsOverlays.Add(_graphicsOverlay); CurrentEsriMapView = mapView; IsMapLoaded = true; }