I am very new to ArcGIS and ArcObjects.
I am writing a code for a button that will detect a selected feature and then select other features based on the feature that I had selected please take a look at my code
public class LandmarkBtn : ESRI.ArcGIS.Desktop.AddIns.Button {
public LandmarkBtn() {
}
protected override void OnClick() {
var doc = ArcMap.Document;
var focusMap = doc.FocusMap;
IEnumLayer layer = focusMap.get_Layers(null,true);
ILayer lyr = null;
IFeatureClass Lmarks = null;
while ((lyr = layer.Next()) != null) {
var featureLayer = lyr as IFeatureLayer;
if (featureLayer == null)
continue;
var name = featureLayer.FeatureClass.AliasName;
if ("landmarks".Equals(name.ToLowerInvariant())) {
Lmarks = featureLayer.FeatureClass;
break;
}
}
if (Lmarks == null) {
MessageBox.Show("Sorry, No LM Layer Found");
return;
}
var selection = (IEnumFeature)focusMap.FeatureSelection;
IFeature ftr = null;
ftr = selection.Next();
ftr now holds the selected landmark(feature), I want to perform a query that will select features from another layer that are within 100 meters of the landmark feature, can you please direct me onto where I should look or provide me with a sample code that might help?
Best Answer
This will take multiple steps:
Get a cursor from you selection set
Union and buffer the items in the cursor
Select the spatial filter on the new shape
Search on the feature class with the filter.
Then if you want to select the new features:
Good Luck