cynthia@sinha

Create graphic objects from spatialquery result features and add these to the arcmap

Discussion created by cynthia@sinha on Dec 19, 2013
Latest reply on Dec 20, 2013 by Neil
Hello Experts,

Hey , i am new to arcobject so need a help... I have to display those points on arcmap that lies inside the envelope.I am explainingwhat i have done so far. I have one point feature class say featureclass having (lat/lon)detail.I opened it  and used one ARCGIS Snippet i.e. GetActiveviewFromArcmap() and constructed one envelope as mentioned below-:




Iactiveview pactiveview=GetActiveviewFromArcmap(m_application);
Ienvelope penvelope=new EnvelopeClass();
penvelope=pactiveview.extent;
penvelope.QueryCoord(out minx, out miny,out maxX,out maxY);

Ispatialfilter sp=New IspatialfilterClass();
sp.geometry=penvelope;
sp.geometryfield=featureclass.shapefieldname;
sp.spatialrel=esrispatialrelenum.esrispatialrelIntersects;


Ifeaturecursor fc=featureclass.Search(sp,false);

IgraphicContainer pgc;
Ielement pElement;
pElement=new MarkerElementClass();
Ipoint ppoint=new PointClass();

Ifeature feature=featurecursor.NextFeature();

while(feature!=null)
{double x=Convert.ToDouble(feature.get_value(featureclass.fields.findfield("LAT")));
double y=Convert.ToDouble(feature.get_value(featureclass.fields.findfield("LON")));
ppoint.PutCoord(x,y);
pElement.Geometry=ppoint;
ppoint.AddElement(pElement,0);
pActiveview.Refresh();
featurecursor.NextFeature();}



The problem is it is  displaying  only one graphic object(point) on arcmap though there are 19 features satisfying the spatial query.I want that when i click the tool all features (point)/graphic object display on map at once.


Thanks in advance

Outcomes