Cynthia

Cynthia

  • 1.4k
  • 215
  • 34k

Display graphic objects from spatialquery result on arcmap

Dec 19 2013 6:47 AM
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