private async void OnMapSelectionChanged(ViewEventArgs obj) { MapViewInternal view = obj.View as MapViewInternal; if (view == null) { return; } // retrieve the selection set var allSelectedFeatures = await SelectionSet.QuerySelection(view.Map); // loop through the layer, OID sets foreach (var layerOIDSetPair in allSelectedFeatures.GetSelection()) { var layer = layerOIDSetPair.Item1; var oids = layerOIDSetPair.Item2; // open the table view showing only selected records if (layer != null) { TableManager.OpenTablePane(layer, TableViewMode.eSelectedRecords); } } }
///// <summary> ///// Make a CIMPointGraphic that can be added to the map overlay ///// </summary> ///// <param name="point">The location of the graphic</param> ///// <returns></returns> //internal static CIMPointGraphicHelper MakeCIMPointGraphic(PointN point) //{ // return new CIMPointGraphicHelper(point); //} /// <summary> /// Add a point to the specified mapview /// </summary> /// <param name="mapView">The mapview to whose overlay the graphic will be added</param> /// <returns>The graphic id assigned to the graphic in the overlay</returns> public static async Task AddToMapOverlay(ArcGIS.Core.CIM.PointN point, MapViewInternal mapView) { if (!mapView.Is2D) { return;//only currently works for 2D } CIMPointGraphicHelper graphicHlpr = new CIMPointGraphicHelper(point); graphicHlpr.graphicID = await mapView.AddOverlayGraphicAsync(graphicHlpr.XML); _lookup[mapView.Map.RepositoryID] = graphicHlpr; }
/// <summary> /// Remove the Point Graphic from the specified mapview /// </summary> /// <param name="mapView"></param> public static async Task RemoveFromMapOverlay(MapViewInternal mapView) { if (!mapView.Is2D) { return;//only currently works for 2D } if (_lookup.ContainsKey(mapView.Map.RepositoryID)) { await mapView.RemoveOverlayGraphicAsync(_lookup[mapView.Map.RepositoryID].graphicID); CIMPointGraphicHelper graphicHlpr = _lookup[mapView.Map.RepositoryID]; _lookup.Remove(mapView.Map.RepositoryID); graphicHlpr = null; } }
/// <summary> /// All-in-one. Update the graphic on the overlay if it was previously added /// otherwise, make it and add it /// </summary> /// <param name="newLocation">The new location to be added to the map</param> /// <param name="mapView"></param> /// <returns></returns> public static void UpdateMapOverlay(ArcGIS.Core.CIM.PointN point, MapViewInternal mapView) { if (!mapView.Is2D) { return;//only currently works for 2D } //CIMPointGraphicHelper graphicHlpr = null; if (_lookup.ContainsKey(mapView.Map.RepositoryID)) { ////graphicHlpr = _lookup[mapView.Map.ID]; ////graphicHlpr.UpdateLocation(point); ////int id = graphicHlpr.graphicID; ////mapView.UpdateOverlayGraphic(ref id, graphicHlpr.XML); ////graphicHlpr.graphicID = id; RemoveFromMapOverlay(mapView); AddToMapOverlay(point, mapView); } else { //first time AddToMapOverlay(point, mapView); } }
/// <summary> /// Default constructor. Provide the search text for geocoding and a flag indicating whether or not /// to escape the search text. The default is True (i.e. escape the text) /// </summary> /// <param name="text">The text to search for</param> /// <param name="maxResults">The number of results to search for</param> /// <param name="escape">True to escape the text, False to include it un-escaped</param> public GeocodeURI(string text, int maxResults, bool escape = true) { //build the URL _url.Append(_baseURL); _url.Append(_verb); string queryStringFormat = "text={0}&outFields={1}&outSR={2}&maxLocations={3}&f={4}"; MapViewInternal activeView = ProSDKSampleModule.ActiveMapViewInternal; int wkid = activeView.SpatialReference.WKID; wkid = 4326; //fill in the parameters string query = string.Format(queryStringFormat, escape ? System.Web.HttpUtility.UrlPathEncode(text) : text, CandidateAttributes.outFields, wkid, maxResults, _format); _url.Append("?"); _url.Append(query); }
private async void Button_Click(object sender, RoutedEventArgs e) { // get the current module to access helper method ProSDKSampleModule module = ProSDKSampleModule.Current; // remove any existing graphics MapViewInternal mapView = ProSDKSampleModule.ActiveMapViewInternal; GeocodeUtils.RemoveFromMapOverlay(mapView); try { // initiate the search CandidateResponse results = GeocodeUtils.SearchFor(this.SearchText.Text, 1); if (results.OrderedResults.Count > 0) { // add a point graphic overlay GeocodeUtils.UpdateMapOverlay(results.OrderedResults[0].ToPointN(), mapView); // zoom to the location await GeocodeUtils.ZoomToLocation(results.OrderedResults[0].Extent); // add the search results to the dialog window this.LastSearch.Text = string.Format("Last Match: {0}", results.OrderedResults[0].CandidateDetails); } else { ArcGIS.Desktop.Internal.Framework.DialogManager.ShowMessageBox( string.Format("No results returned for {0}", this.SearchText.Text), "GeocodeExample"); } } catch (Exception ex) { string errorName = "Search Error"; System.Diagnostics.Trace.WriteLine(string.Format("{0}: {1}", errorName, ex.ToString())); ArcGIS.Desktop.Internal.Framework.DialogManager.ShowMessageBox(errorName, this.SearchText.Text); } }
/// <summary> /// Pans to a bookmark in a map view /// </summary> /// <param name="bookMark"> Mapping module Bookmark object</param> /// <param name="mapView"> A Map view</param> public static async void PanTo(this MapViewInternal mapView, Bookmark bookMark) { ArcGIS.Core.CIM.CIMBookmark bmkDef = await bookMark.GetDefinitionAsync(); mapView.PanTo(bmkDef.Location); }
///// <summary> ///// Make a CIMPointGraphic that can be added to the map overlay ///// </summary> ///// <param name="point">The location of the graphic</param> ///// <returns></returns> //internal static CIMPointGraphicHelper MakeCIMPointGraphic(PointN point) //{ // return new CIMPointGraphicHelper(point); //} /// <summary> /// Add a point to the specified mapview /// </summary> /// <param name="mapView">The mapview to whose overlay the graphic will be added</param> /// <returns>The graphic id assigned to the graphic in the overlay</returns> public static async Task AddToMapOverlay(ArcGIS.Core.CIM.PointN point, MapViewInternal mapView) { if (!mapView.Is2D) return;//only currently works for 2D CIMPointGraphicHelper graphicHlpr = new CIMPointGraphicHelper(point); graphicHlpr.graphicID = await mapView.AddOverlayGraphicAsync(graphicHlpr.XML); _lookup[mapView.Map.RepositoryID] = graphicHlpr; }
/// <summary> /// Remove the Point Graphic from the specified mapview /// </summary> /// <param name="mapView"></param> public static async Task RemoveFromMapOverlay(MapViewInternal mapView) { if (!mapView.Is2D) return;//only currently works for 2D if (_lookup.ContainsKey(mapView.Map.RepositoryID)) { await mapView.RemoveOverlayGraphicAsync(_lookup[mapView.Map.RepositoryID].graphicID); CIMPointGraphicHelper graphicHlpr = _lookup[mapView.Map.RepositoryID]; _lookup.Remove(mapView.Map.RepositoryID); graphicHlpr = null; } }
/// <summary> /// All-in-one. Update the graphic on the overlay if it was previously added /// otherwise, make it and add it /// </summary> /// <param name="newLocation">The new location to be added to the map</param> /// <param name="mapView"></param> /// <returns></returns> public static void UpdateMapOverlay(ArcGIS.Core.CIM.PointN point, MapViewInternal mapView) { if (!mapView.Is2D) return;//only currently works for 2D //CIMPointGraphicHelper graphicHlpr = null; if (_lookup.ContainsKey(mapView.Map.RepositoryID)) { ////graphicHlpr = _lookup[mapView.Map.ID]; ////graphicHlpr.UpdateLocation(point); ////int id = graphicHlpr.graphicID; ////mapView.UpdateOverlayGraphic(ref id, graphicHlpr.XML); ////graphicHlpr.graphicID = id; RemoveFromMapOverlay(mapView); AddToMapOverlay(point, mapView); } else { //first time AddToMapOverlay(point, mapView); } }
/// <summary> /// Zooms to a bookmark in a map view /// </summary> /// <param name="bookMark"> Mapping module Bookmark object</param> /// <param name="mapView"> A Map view</param> public static async void ZoomTo(this MapViewInternal mapView, Bookmark bookMark) { ArcGIS.Core.CIM.CIMBookmark bmkDef = await bookMark.QueryDefinition(); mapView.Extent = bmkDef.Location; }