|
POST
|
Ah yes, that makes sense to me now. Thanks for helping!!
... View more
11-21-2017
06:37 AM
|
0
|
0
|
1747
|
|
POST
|
Hi, I'm trying to do a spatial query on a layer in my map. In my code, I first check to see if the layer is there: IEnumerable<Layer> gridLayer = map.GetLayersAsFlattenedList().Where(l => l.Name.IndexOf("GISWRKS1.WORKS.LAND_Grid", StringComparison.CurrentCultureIgnoreCase) >= 0); if (gridLayer.Count() == 0) { ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Please add the GRID layer before proceeding.", "Missing Layer"); return; } Later in the code I want to use a point to intersect the gridLayer using this code: SpatialQueryFilter spatialFilter = new SpatialQueryFilter(); spatialFilter.FilterGeometry = intersectPoint; spatialFilter.SpatialRelationship = SpatialRelationship.Intersects; spatialFilter.SubFields = "GRIDNO"; FeatureLayer grid = (FeatureLayer)gridLayer; //This does not work. Null Reference Exception or sometimes an InvalidCast, depending on what I am doing. How do I turn my gridLayer from above into something I can use to query?? I've tried many different things...FeatureLayer, BasicFeatureLayer, FeatureClass.....nothing works. RowCursor gridCursor = grid.Search(spatialFilter); while (gridCursor.MoveNext()) { using (Feature feature = (Feature)gridCursor.Current) { ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(feature[0].ToString()); } }
... View more
11-20-2017
11:58 AM
|
0
|
2
|
1969
|
|
POST
|
Hi Sean, Yes, I eventually found a sample that broke my line down into segments, but I like your solution much better. Two lines of code is always better than 10, especially when all I need is the first point. This is what I had: Polyline theLine = insp.Shape as Polyline; ReadOnlyPartCollection polylineParts = theLine.Parts; IEnumerator<ReadOnlySegmentCollection> segments = polylineParts.GetEnumerator(); segments.MoveNext(); ReadOnlySegmentCollection seg = segments.Current; foreach (Segment s in seg) { intersectPoint = s.StartPoint; break; //to get just the first point } Thanks for your help!! This is what I ultimately went with: var pointCollection = ((Multipart)insp.Shape).Points; MapPoint thePoint = pointCollection[0];
... View more
11-20-2017
10:21 AM
|
0
|
0
|
2007
|
|
POST
|
Hi, I'm trying to get the StartPoint of a selected Polyline. So far, this is what I have: I use an Inspector to get each selected feature, like this: var selection = currentLayer.GetSelection(); IReadOnlyList<long> selectedOIDs = selection.GetObjectIDs(); //save the selected OBJECTIDs to a list. var insp = new ArcGIS.Desktop.Editing.Attributes.Inspector(); //create the Inspector Then I loop through each selected OBJECTID: foreach (var oid in selectedOIDs) { insp.Load(currentLayer, oid); //use the current OBJECTID as you go through the loop of selected features Polyline theLine = insp.Shape as Polyline; //This works Segment theSegment = insp.Shape as Segment; //This will not cast....not quite sure what to do here MapPoint startPoint = theSegment.StartPoint; //This is ultimately what I want to get at } Since a Segment has a .StartPoint property, I think I need to cast my Polyline into a Segment, I'm just not sure how to do it. Of course, I could be totally wrong. Any advice on how to do this would be appreciated.
... View more
11-20-2017
07:08 AM
|
0
|
2
|
2190
|
|
POST
|
OK. It looks like the problem is a C# issue with the || operator and those null values. Not exactly sure why, but this seems to fix the problem: Map map = MapView.Active.Map; IEnumerable<Layer> gridLayer = map.GetLayersAsFlattenedList().Where(l => l.Name.IndexOf("GISWRKS1.WORKS.LAND_Grid", StringComparison.CurrentCultureIgnoreCase) >= 0); IEnumerable<Layer> localMunicipalityLayer = map.GetLayersAsFlattenedList().Where(l => l.Name.IndexOf("GISWRKS1.WORKS.LAND_LocalMunicipality", StringComparison.CurrentCultureIgnoreCase) >= 0); IEnumerable<Layer> administrativeAreaLayer = map.GetLayersAsFlattenedList().Where(l => l.Name.IndexOf("GISWRKS1.WORKS.LAND_AdministrativeArea", StringComparison.CurrentCultureIgnoreCase) >= 0); IEnumerable<Layer> communitiesLayer = map.GetLayersAsFlattenedList().Where(l => l.Name.IndexOf("GISWRKS1.WORKS.LAND_Communities", StringComparison.CurrentCultureIgnoreCase) >= 0); IEnumerable<Layer> depotAreaLayer = map.GetLayersAsFlattenedList().Where(l => l.Name.IndexOf("GISWRKS1.WORKS.LAND_DepotArea", StringComparison.CurrentCultureIgnoreCase) >= 0); IEnumerable<Layer> pressureZoneLayer = map.GetLayersAsFlattenedList().Where(l => l.Name.IndexOf("GISWRKS1.WORKS.WAT_PressureZone", StringComparison.CurrentCultureIgnoreCase) >= 0); if (gridLayer.Count() == 0 || localMunicipalityLayer.Count() == 0 || administrativeAreaLayer.Count() == 0 || communitiesLayer.Count() == 0 || depotAreaLayer.Count() == 0 || pressureZoneLayer.Count() == 0) { ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Please add the LAND and Water Pressure Zone layers before proceeding.", "Missing Layers"); return; }
... View more
11-17-2017
10:18 AM
|
0
|
0
|
554
|
|
POST
|
I'm trying to determine if specific layers are in the map before proceeding with more code. The following produces an error at the line where I am checking to the value == null of each layer. Is this the best way to do this? Or is there a better way to check for specific layers in the map?? protected override void OnClick() { var gridLayer = MapView.Active.Map.FindLayers("GISWRKS1.WORKS.LAND_Grid").FirstOrDefault() as BasicFeatureLayer; var localMunicipalityLayer = MapView.Active.Map.FindLayers("GISWRKS1.WORKS.LAND_LocalMunicipality").FirstOrDefault() as BasicFeatureLayer; var administrativeAreaLayer = MapView.Active.Map.FindLayers("GISWRKS1.WORKS.LAND_AdministrativeArea").FirstOrDefault() as BasicFeatureLayer; var communitiesLayer = MapView.Active.Map.FindLayers("GISWRKS1.WORKS.LAND_Communities").FirstOrDefault() as BasicFeatureLayer; var depotAreaLayer = MapView.Active.Map.FindLayers("GISWRKS1.WORKS.LAND_DepotArea").FirstOrDefault() as BasicFeatureLayer; var pressureZoneLayer = MapView.Active.Map.FindLayers("GISWRKS1.WORKS.LAND_PressureZone").FirstOrDefault() as BasicFeatureLayer; ****This is where I get the error!! If I check these one at a time, it works, but when combining with the || is when the error happens. In ArcMap 10.2, I have similar code running with no problems.**** if ((gridLayer == null) || (localMunicipalityLayer == null) || (administrativeAreaLayer == null) || (communitiesLayer == null) || (depotAreaLayer == null) || (pressureZoneLayer = null)) { ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Please add the LAND and Water Pressure Zone layers before proceeding."); return; } ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("All the layers are there!!"); }
... View more
11-17-2017
06:48 AM
|
0
|
1
|
645
|
|
POST
|
Hi, I've created a WebMap in AGOL that uses clustering on a point feature class. All is working fine. When using the WebApp Builder 2.4 to create an app, I can add the above mentioned WebMap, but the clustering is not working. The points just display as regular points. I am using the 'Foldable' theme, and have only added the WebMap, no widgets or anything else. Is there something I need to set to get the clustering to work in the App?? Thanks,
... View more
10-25-2017
07:19 AM
|
0
|
1
|
1138
|
|
POST
|
I found it!! FrameworkApplication.SetCurrentToolAsync("esri_mapping_selectByRectangleTool");
... View more
09-08-2017
07:11 AM
|
0
|
0
|
2028
|
|
POST
|
Is there a listing available of ToolIDs within ArcPro? I've been looking through the API Reference and have only found one reference to esri_editing_SketchLineTool, but I would imagine there must be a whole list of them somewhere. What I want to do is automatically switch to the Select tool after a MapTool I am coding is finished running. Thanks,
... View more
09-08-2017
06:10 AM
|
0
|
2
|
2918
|
|
POST
|
Hi Uma, So I got it working, but was wondering if there is a better way. Is there a way to do what I want to do with just one event, or do I need to use all three to monitor the layers in the map?? This is in the Module1.cs of my MapTool code. protected override bool Initialize() { LayersAddedEvent.Subscribe((args) => { // Get the layers and also any selected OIDs for the AsBuilt and the SitePlan layers var asBuiltLayer = MapView.Active.Map.FindLayers("GISWRKS1.WORKS.Drawings_AsBuilts").FirstOrDefault() as BasicFeatureLayer; var sitePlanLayer = MapView.Active.Map.FindLayers("GISWRKS1.WORKS.Drawings_SitePlans").FirstOrDefault() as BasicFeatureLayer; // Check that the required layers are in the map. if (asBuiltLayer == null && sitePlanLayer == null) FrameworkApplication.State.Deactivate(StateID); else FrameworkApplication.State.Activate(StateID); } ); DrawCompleteEvent.Subscribe((args) => { // Get the layers and also any selected OIDs for the AsBuilt and the SitePlan layers var asBuiltLayer = MapView.Active.Map.FindLayers("GISWRKS1.WORKS.Drawings_AsBuilts").FirstOrDefault() as BasicFeatureLayer; var sitePlanLayer = MapView.Active.Map.FindLayers("GISWRKS1.WORKS.Drawings_SitePlans").FirstOrDefault() as BasicFeatureLayer; // Check that the required layers are in the map. if (asBuiltLayer == null && sitePlanLayer == null) FrameworkApplication.State.Deactivate(StateID); else FrameworkApplication.State.Activate(StateID); } ); LayersRemovedEvent.Subscribe((args) => { // Get the layers and also any selected OIDs for the AsBuilt and the SitePlan layers var asBuiltLayer = MapView.Active.Map.FindLayers("GISWRKS1.WORKS.Drawings_AsBuilts").FirstOrDefault() as BasicFeatureLayer; var sitePlanLayer = MapView.Active.Map.FindLayers("GISWRKS1.WORKS.Drawings_SitePlans").FirstOrDefault() as BasicFeatureLayer; // Check that the required layers are in the map. if (asBuiltLayer == null && sitePlanLayer == null) FrameworkApplication.State.Deactivate(StateID); else FrameworkApplication.State.Activate(StateID); } ); return base.Initialize(); }
... View more
09-07-2017
01:05 PM
|
0
|
1
|
699
|
|
POST
|
Yes, I am actually looking through the WorkingWithDAML example right now, but will check out the ConstructMarkerFromFont sample too. Thanks!
... View more
09-07-2017
12:30 PM
|
0
|
0
|
699
|
|
POST
|
Hi Charles, Yes, I was doing some copy/paste without really realizing what the MapPointBuilder was doing. Anyways.....just using the geometry parameter is working: modifyAsBuilts.Modify(asBuiltLayer, oid, geometry); One thing I am noticing is that the points in the map don't actually move until I click on 'OK' for the message box that pops up after I run modifyAsBuilts.Execute().....see below: modifyAsBuilts.Execute(); ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(abCount.ToString() + " As-Builts moved.", "Points moved"); I am guessing that I need some sort of a delay in there for the moving of the points to catch up to the processing of the code.....right?? Now on to the next phase; figuring out how to enable/disable this tool based on certain layers being in the map or not....and also changing the mouse cursor to the 'Explore' tool after the points have been moved. Any advice??
... View more
09-07-2017
10:48 AM
|
0
|
2
|
2552
|
|
POST
|
See this thread for some solutions to this: https://community.esri.com/thread/200266-moving-selected-features
... View more
09-07-2017
08:43 AM
|
0
|
0
|
713
|
|
POST
|
Thanks again Uma. You have been a great help! I tweaked yours to work with a selection of features. Here is my final solution for anyone else who may be following this thread: // Get the layers and also any selected OIDs for the AsBuilt and the SitePlan layers var asBuiltLayer = MapView.Active.Map.FindLayers("GISWRKS1.WORKS.Drawings_AsBuilts").FirstOrDefault() as BasicFeatureLayer; // variable for the coordinate of the mouse click in the whatever the SpatialReference of the map is var coord = GeometryEngine.Instance.Project(geometry, MapView.Active.Map.SpatialReference) as MapPoint; var moveToPoint = new MapPointBuilder(coord.X, coord.Y, MapView.Active.Map.SpatialReference); // create counter for showing final results int abCount = 0; // start the EditOperation var modifyAsBuilts = new EditOperation(); modifyAsBuilts.Name = "Move As-Builts and Site Plans"; // Get any selected OIDs for the layer, and move each point to the mouse click point. if (asBuiltLayer != null) { var selectedAB = asBuiltLayer.GetSelection(); IReadOnlyList<long> selectedAsbuiltOIDs = selectedAB.GetObjectIDs(); foreach (var oid in selectedAsbuiltOIDs) { modifyAsBuilts.Modify(asBuiltLayer, oid, moveToPoint.ToGeometry()); abCount++; } } modifyAsBuilts.Execute();
... View more
09-07-2017
08:40 AM
|
3
|
4
|
2552
|
| Title | Kudos | Posted |
|---|---|---|
| 2 | 08-18-2023 08:57 AM | |
| 1 | 04-19-2018 05:53 AM | |
| 1 | 04-13-2018 10:07 AM | |
| 1 | 04-13-2018 10:04 AM | |
| 1 | 04-13-2018 05:56 AM |
| Online Status |
Offline
|
| Date Last Visited |
02-20-2025
03:53 PM
|