// Searches arcgis online for webmaps containing SearchText private async Task SearchArcgisOnline() { try { IsBusy = true; if (_portal == null) { _portal = await ArcGISPortal.CreateAsync(); } var searchParams = new SearchParameters(SearchText + " type: \"web map\" NOT \"web mapping application\" ") { Limit = 20, SortField = "avgrating", SortOrder = QuerySortOrder.Descending, }; var result = await _portal.SearchItemsAsync(searchParams); SearchResults = new ObservableCollection <ArcGISPortalItem>(result.Results); } finally { IsBusy = false; } }
/// <summary> /// Search the IWA-secured portal for web maps and display the results in a list box. /// </summary> private async void SearchSecureMapsButton_Click(object sender, RoutedEventArgs e) { // Set the flag variable to indicate we're working with the secure portal // (if the user wants to load a map, we'll need to know which portal it came from) _usingPublicPortal = false; MapItemListBox.Items.Clear(); // Show status message and the status bar MessagesTextBlock.Text = "Searching for web map items on the secure portal."; ProgressStatus.Visibility = Windows.UI.Xaml.Visibility.Visible; var sb = new StringBuilder(); try { // Create an instance of the IWA-secured portal _iwaSecuredPortal = await ArcGISPortal.CreateAsync(new Uri(SecuredPortalUrl)); // Report a successful connection sb.AppendLine("Connected to the portal on " + _iwaSecuredPortal.Uri.Host); sb.AppendLine("Version: " + _iwaSecuredPortal.CurrentVersion); // Report the username used for this connection if (_iwaSecuredPortal.CurrentUser != null) { sb.AppendLine("Connected as: " + _iwaSecuredPortal.CurrentUser.UserName); } else { sb.AppendLine("Anonymous"); // THIS SHOULDN'T HAPPEN! } // Search the secured portal for web maps var items = await _iwaSecuredPortal.SearchItemsAsync(new SearchParameters("type:(\"web map\" NOT \"web mapping application\")")); // Build a list of items from the results that shows the map title and stores the item ID (with the Tag property) var resultItems = from r in items.Results select new ListBoxItem { Tag = r.Id, Content = r.Title }; // Add the list items foreach (var itm in resultItems) { MapItemListBox.Items.Add(itm); } } catch (TaskCanceledException tce) { sb.AppendLine(tce.Message); } catch (Exception ex) { // Report errors connecting to or searching the secured portal sb.AppendLine(ex.Message); } finally { // Show messages, hide progress bar MessagesTextBlock.Text = sb.ToString(); ProgressStatus.Visibility = Windows.UI.Xaml.Visibility.Collapsed; } }
private void DoSearch() { ResultsListBox.ItemsSource = null; ResetVisibility(); if (QueryText == null || string.IsNullOrEmpty(QueryText.Text.Trim())) { return; } if (string.IsNullOrEmpty(portal.Url)) { portal.Url = DEFAULT_SERVER_URL; } var queryString = string.Format("{0} type:\"web map\" NOT \"web mapping application\"", QueryText.Text.Trim()); if (portal.CurrentUser != null && portal.ArcGISPortalInfo != null && !string.IsNullOrEmpty(portal.ArcGISPortalInfo.Id)) { queryString = string.Format("{0} and orgid: \"{1}\"", queryString, portal.ArcGISPortalInfo.Id); } var searchParameters = new SearchParameters() { QueryString = queryString, SortField = "avgrating", SortOrder = QuerySortOrder.Descending, Limit = 20 }; portal.SearchItemsAsync(searchParameters, (result, error) => { ResultsListBox.ItemsSource = result.Results; }); }
// Search arcgis.com for web maps matching the query text private async void DoSearch(String boton) { try { ResultsListBox.ItemsSource = null; ResetVisibility(); if (QueryText == null || string.IsNullOrEmpty(QueryText.Text.Trim())) { return; } var queryString = string.Format("{0} type:(\"web map\" NOT \"web mapping application\")", QueryText.Text.Trim()); if (_portal.CurrentUser != null && _portal.ArcGISPortalInfo != null && !string.IsNullOrEmpty(_portal.ArcGISPortalInfo.Id)) { queryString = string.Format("{0} orgid:(\"{1}\")", queryString, _portal.ArcGISPortalInfo.Id); } var searchParameters = new SearchParameters() { QueryString = queryString, SortField = "avgrating", SortOrder = QuerySortOrder.Descending, Limit = 20 }; if (boton.Equals("buscar")) { var result = await _portal.SearchItemsAsync(searchParameters); ResultsListBox.ItemsSource = result.Results; if (result.Results != null && result.Results.Count() > 0) { ResultsListBox.SelectedIndex = 0; } } else { var result = await _portal.CurrentUser.GetItemsAsync(); //SearchItemsAsync(searchParameters); ResultsListBox.ItemsSource = result; //.Results; if (result /*.Results*/ != null && result /*.Results*/.Count() > 0) { ResultsListBox.SelectedIndex = 0; } } } catch (Exception ex) { var _x = new MessageDialog(ex.Message, "Error").ShowAsync(); } }
private async void SearchPortal(ArcGISPortal currentPortal) { MapItemListBox.Items.Clear(); // Show status message and the status bar MessagesTextBlock.Text = "Searching for web map items on the portal at " + currentPortal.Uri.AbsoluteUri; ProgressStatus.Visibility = Visibility.Visible; var messageBuilder = new StringBuilder(); try { // Report connection info messageBuilder.AppendLine("Connected to the portal on " + currentPortal.Uri.Host); messageBuilder.AppendLine("Version: " + currentPortal.CurrentVersion); // Report the user name used for this connection if (currentPortal.CurrentUser != null) { messageBuilder.AppendLine("Connected as: " + currentPortal.CurrentUser.UserName); } else { // (this shouldn't happen for a secure portal) messageBuilder.AppendLine("Anonymous"); } // Search the portal for web maps var items = await currentPortal.SearchItemsAsync(new SearchParameters("type:(\"web map\" NOT \"web mapping application\")")); // Build a list of items from the results that shows the map name and stores the item ID (with the Tag property) var resultItems = from r in items.Results select new ListBoxItem { Tag = r.ItemId, Content = r.Title }; // Add the list items foreach (var itm in resultItems) { MapItemListBox.Items.Add(itm); } } catch (Exception ex) { // Report errors searching the portal messageBuilder.AppendLine(ex.Message); } finally { // Show messages, hide progress bar MessagesTextBlock.Text = messageBuilder.ToString(); ProgressStatus.Visibility = Visibility.Collapsed; } }
/// <summary> /// Fonction de mise à jour de la liste des cartes /// </summary> /// <param name="query"></param> private async void updateList(string query) { // Creation des parametres de recherche SearchParameters searchParameters = new SearchParameters(query); //searchParameters.SortField = "modified"; searchParameters.SortField = "numviews"; searchParameters.SortOrder = QuerySortOrder.Descending; // Lancement de la recherche sur le portal. SearchResultInfo <ArcGISPortalItem> resultItems = await portal.SearchItemsAsync(searchParameters); // Conversion en liste List <ArcGISPortalItem> itemList = resultItems.Results.ToList(); // On assigne les resultats à notre liste coté ihm. webmapsList.ItemsSource = itemList; }
private void FindWebMapsButton_Click(object sender, RoutedEventArgs e) { webmapGraphicsLayer.Graphics.Clear(); // Search envelope must be in geographic (WGS84). Convert the current map extent from Web Mercator // to geographic. ESRI.ArcGIS.Client.Geometry.Geometry geom = mercator.ToGeographic(MyMap.Extent); SpatialSearchParameters parameters = new SpatialSearchParameters { Limit = String.IsNullOrEmpty(resultLimit.Text) == true ? 15 : Convert.ToInt32(resultLimit.Text), SearchExtent = geom.Extent, QueryString = String.Format("{0} And type:Web Map", searchText.Text) }; arcgisPortal.SearchItemsAsync(parameters, (result, error) => { if (error == null) { // Set the ItemsSource for the Listbox to an IEnumerable of ArcGISPortalItems. // Bindings setup in the Listbox item template in XAML will enable the discovery and // display individual result items. WebMapsListBox.ItemsSource = result.Results; // For each web map returned, add the center (point) of the web map extent as a graphic. // Add the ArcGISPortalItem instance as an attribute. This will be used to select graphics // in the map. foreach (var item in result.Results) { Graphic graphic = new Graphic(); graphic.Attributes.Add("PortalItem", item); MapPoint extentCenter = item.Extent.GetCenter(); graphic.Geometry = new MapPoint(extentCenter.X, extentCenter.Y, new SpatialReference(4326)); webmapGraphicsLayer.Graphics.Add(graphic); } } }); }
/// <summary> /// Search the PKI-secured portal for web maps and display the results in a list box. /// </summary> private async void SearchSecureMapsButton_Click(object sender, RoutedEventArgs e) { // Set the flag variable to indicate we're working with the secure portal // (if the user wants to load a map, we'll need to know which portal it came from) _usingPublicPortal = false; MapItemListBox.Items.Clear(); // Show status message and the status bar MessagesTextBlock.Text = "Searching for web map items on the secure portal."; ProgressStatus.Visibility = Windows.UI.Xaml.Visibility.Visible; var sb = new StringBuilder(); try { // Create an instance of the PKI-secured portal _pkiSecuredPortal = await ArcGISPortal.CreateAsync(new Uri(SecuredPortalUrl)); // Report a successful connection sb.AppendLine("Connected to the portal on " + _pkiSecuredPortal.Uri.Host); sb.AppendLine("Version: " + _pkiSecuredPortal.CurrentVersion); // Report the username used for this connection if (_pkiSecuredPortal.CurrentUser != null) sb.AppendLine("Connected as: " + _pkiSecuredPortal.CurrentUser.UserName); else sb.AppendLine("Anonymous"); // THIS SHOULDN'T HAPPEN! // Search the secured portal for web maps var items = await _pkiSecuredPortal.SearchItemsAsync(new SearchParameters("type:(\"web map\" NOT \"web mapping application\")")); // Build a list of items from the results that shows the map name and stores the item ID (with the Tag property) var resultItems = from r in items.Results select new ListBoxItem { Tag = r.Id, Content = r.Name }; // Add the list items foreach (var itm in resultItems) { MapItemListBox.Items.Add(itm); } } catch (Exception ex) { // Report errors connecting to or searching the secured portal sb.AppendLine(ex.Message); } finally { // Show messages, hide progress bar MessagesTextBlock.Text = sb.ToString(); ProgressStatus.Visibility = Windows.UI.Xaml.Visibility.Collapsed; } }
private async void SearchPortal(ArcGISPortal currentPortal) { MapItemListBox.Items.Clear(); // Show status message and the status bar MessagesTextBlock.Text = "Searching for web map items on the portal at " + currentPortal.Uri.AbsoluteUri; ProgressStatus.Visibility = Visibility.Visible; var messageBuilder = new StringBuilder(); try { // Report connection info messageBuilder.AppendLine("Connected to the portal on " + currentPortal.Uri.Host); messageBuilder.AppendLine("Version: " + currentPortal.CurrentVersion); // Report the user name used for this connection if (currentPortal.CurrentUser != null) { messageBuilder.AppendLine("Connected as: " + currentPortal.CurrentUser.UserName); } else { // (this shouldn't happen for a secure portal) messageBuilder.AppendLine("Anonymous"); } // Search the portal for web maps var items = await currentPortal.SearchItemsAsync(new SearchParameters("type:(\"web map\" NOT \"web mapping application\")")); // Build a list of items from the results that shows the map name and stores the item ID (with the Tag property) var resultItems = from r in items.Results select new ListBoxItem { Tag = r.ItemId, Content = r.Title }; // Add the list items foreach (var itm in resultItems) { MapItemListBox.Items.Add(itm); } } catch (Exception ex) { // Report errors searching the portal messageBuilder.AppendLine(ex.Message); } finally { // Show messages, hide progress bar MessagesTextBlock.Text = messageBuilder.ToString(); ProgressStatus.Visibility = Visibility.Hidden; } }
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; } }
// Search arcgis.com for web maps matching the query text private async void DoSearch(String boton) { _portal = await ArcGISPortal.CreateAsync(new Uri(MainPage.GetUrl())); try { MyMapsProgressBar.Visibility = Visibility.Visible; ResultsListBox.ItemsSource = null; ResetVisibility(); if (boton.Equals("buscar")) { if (QueryText == null || string.IsNullOrEmpty(QueryText.Text.Trim())) { return; } var queryString = string.Format("{0} type:(\"web map\" NOT \"web mapping application\")", QueryText.Text.Trim()); if (_portal.CurrentUser != null && _portal.ArcGISPortalInfo != null && !string.IsNullOrEmpty(_portal.ArcGISPortalInfo.Id)) { queryString = string.Format("{0} orgid:(\"{1}\")", queryString, _portal.ArcGISPortalInfo.Id); } var searchParameters = new SearchParameters() { QueryString = queryString, SortField = "avgrating", SortOrder = QuerySortOrder.Descending, Limit = 20 }; var result = await _portal.SearchItemsAsync(searchParameters); ResultsListBox.ItemsSource = result.Results; if (result.Results != null && result.Results.Count() > 0) { ResultsListBox.SelectedIndex = 0; } } else { var result = await _portal.CurrentUser.GetItemsAsync(); foreach (ArcGISPortalItem i in result) { if (i.TypeName.Equals("Web Map")) { ResultsListBox.Items.Add(i); } } if (result != null && result.Count() > 0 && ResultsListBox.Items.Count() > 0) { ResultsListBox.SelectedIndex = 0; } } } catch (Exception ex) { var _x = new MessageDialog(ex.Message, "Error").ShowAsync(); } finally { MyMapsProgressBar.Visibility = Visibility.Collapsed; } }