I have this wierd problem i guess.
I have made some code that creates an shapefile with pointdata but when the layer is added the points are not visible but the layer contains data. Are I missing something:
public void addDataToMap(string folder, string shapefilename) {
pMap = mDoc.FocusMap;
string strFolder = folder;
string strName = shapefilename;
string strShapeFileName = "Shape";
string strLatitude = "Latitude";
string strLongitude = "Longitude";
string strLocationName = "Name";
IFeatureWorkspace pFWS;
IWorkspaceFactory pWorkspaceFactory;
pWorkspaceFactory = new ShapefileWorkspaceFactory();
pFWS = (IFeatureWorkspace)pWorkspaceFactory.OpenFromFile(strFolder, 0);
//FIELDS SETUP
IFields pFields;
IFieldsEdit pFieldsEdit;
pFields = new Fields();
pFieldsEdit = (IFieldsEdit)pFields;
//FIELD 0
IField pField;
IFieldEdit pFieldEdit;
pField = new Field();
pFieldEdit = (IFieldEdit)pField;
pFieldEdit.Name_2 = strShapeFileName;
pFieldEdit.Type_2 = esriFieldType.esriFieldTypeGeometry;
pFieldsEdit.AddField(pField);
//FIELD 1
IField pField1;
IFieldEdit pFieldEdit1;
pField1 = new Field();
pFieldEdit1 = (IFieldEdit)pField1;
pFieldEdit1.Name_2 = strLatitude;
pFieldEdit1.Type_2 = esriFieldType.esriFieldTypeDouble;
pFieldsEdit.AddField(pField1);
//FIELD 2
IField pField2;
IFieldEdit pFieldEdit2;
pField2 = new Field();
pFieldEdit2 = (IFieldEdit)pField2;
pFieldEdit2.Name_2 = strLongitude;
pFieldEdit2.Type_2 = esriFieldType.esriFieldTypeDouble;
pFieldsEdit.AddField(pField2);
//FIELD 3
IField pField3;
IFieldEdit pFieldEdit3;
pField3 = new Field();
pFieldEdit3 = (IFieldEdit)pField3;
pFieldEdit3.Name_2 = strLocationName;
pFieldEdit3.Type_2 = esriFieldType.esriFieldTypeString;
pFieldsEdit.AddField(pField3);
IGeometryDef pGeomDef;
IGeometryDefEdit pGeomDefEdit;
pGeomDef = new GeometryDef();
pGeomDefEdit = (IGeometryDefEdit)pGeomDef;
pGeomDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPoint;
//Spatialreference setup
ISpatialReferenceFactory SRF = new SpatialReferenceEnvironmentClass();
ISpatialReference SR = SRF.CreateProjectedCoordinateSystem((int)esriSRProjCSType.esriSRProjCS_World_Mercator);
ISpatialReferenceResolution SRR = (ISpatialReferenceResolution)SR;
SRR.ConstructFromHorizon();
ISpatialReferenceTolerance SRT = (ISpatialReferenceTolerance)SR;
SRT.SetDefaultXYTolerance();
pGeomDefEdit.SpatialReference_2 = SR;
pFieldEdit.GeometryDef_2 = pGeomDef;
IFeatureClass pFeatClass;
pFeatClass = pFWS.CreateFeatureClass(strName, pFields, null, null, esriFeatureType.esriFTSimple, strShapeFileName, "");
IFeatureLayer pFeaturelayer = new FeatureLayerClass();
pFeaturelayer.FeatureClass = pFeatClass;
pFeaturelayer.Name = pFeatClass.AliasName;
data = handler.getPointData();
for (int i = 1; i < data.Count; i++)
{
IFeature pNewFeature;
pNewFeature = pFeatClass.CreateFeature();
pNewFeature.Value[2] = data.getLatgAsDouble();
pNewFeature.Value[3] = data.getLngAsDouble();
pNewFeature.Value[4] = data.getName();
pNewFeature.Store();
}
pMap.AddLayer(pFeaturelayer);
mDoc.UpdateContents();
mDoc.ActiveView.Refresh();
}