Solved! Go to Solution.
WHAT WE NEED
Guidance on how to identify the causes of the issues we are having adding a new point to the layer. Is it a process problem? Is it a code problem? If so, who can help us identify the failure points?
The full source code is available if it would be helpful for you to decipher the issue.
We have created our project in Visual Studio 2008 .net 2.0.
What we can do:
- Run the project in Debug mode through Windows Mobile 6 classic Emulator
- Load a MobileCache of 6 Feature Layers �?? 3 editable with existing feature points & 3 as background data
- ZoomIn, ZoomOut, Pan, IdentifyFeature on map using toolbar control
- Load Existing Feature Data to screens when using the IdentifyFeature toolbar function
What we can�??t do (identified so far):
- Adding new Feature Point
- How we are attempting this:
- Click toolbar button
- Click map to add new feature
- Run code that we have sourced from multiple different online examples in an attempt to add a new point �?? we have had several different stages of errors thrown from the �??The geometry is empty�??, to completely destroying the MobileCache
Example of current relevant code
private void toolBar1_ButtonClick(object sender, ToolBarButtonClickEventArgs e)
{
switch (toolBar1.Buttons.IndexOf(e.Button))
{
case 0:
MapMain.CurrentMapAction = zoomInMapAction1;
break;
case 1:
MapMain.CurrentMapAction = zoomOutMapAction1;
break;
case 2:
MapMain.CurrentMapAction = panMapAction1;
break;
case 3:
MapMain.CurrentMapAction = null;
break;
case 4:
MapMain.CurrentMapAction = addVertexSketchTool1;
break;
default:
break;
}
}
private void MapMain_MouseDown(object sender, ESRI.ArcGIS.Mobile.MapMouseEventArgs e)
{
if (MapMain.CurrentMapAction == addVertexSketchTool1)
{
AddNewFeaturePoint();
}
}
private void AddNewFeaturePoint()
{
sketchGraphicLayer1.Geometry = new ESRI.ArcGIS.Mobile.Geometries.Point();
FeatureLayer locationLayer = mobileCache1.Layers["Location"] as FeatureLayer;
using (FeatureDataTable locationTable = locationLayer.GetDataTable())
{
DataRow locationRow = locationTable.NewRow();
locationRow.BeginEdit();
locationRow["LocationID"] = Guid.NewGuid();
locationRow[locationLayer.GeometryColumnIndex] = sketchGraphicLayer1.Geometry;
locationRow.EndEdit();
locationTable.Rows.Add(locationRow);
locationTable.SaveInFeatureLayer();
DataRow[] errors = locationTable.GetErrors();
for (int i = 0; i < errors.Length; i++)
{
if (errors.HasErrors)
{
DataColumn[] colArr = errors.GetColumnsInError();
for (int j = 0; j < colArr.Length; j++)
{
MessageBox.Show(string.Format("Error '{0}' in column '{1}'.", errors.GetColumnError(colArr), colArr .ColumnName));
}
}
}
}
}
private void MapMain_MouseDown(object sender, ESRI.ArcGIS.Mobile.MapMouseEventArgs e)
{
if (MapMain.CurrentMapAction == addVertexSketchTool1)
{
AddNewFeaturePoint(e.MapCoordinate); // pass the map click as the location to store
}
}
private void AddNewFeaturePoint(Coordinate mapCoord)
{
var pointGeom = new ESRI.ArcGIS.Mobile.Geometries.Point(mapCoord);
// ...
locationRow[locationLayer.GeometryColumnIndex] = pointGeom;
// ...
}Thanks for your reply Thad!
I did actually have the geometry being set that way, but I�??d removed it wondering if that was causing the problem then forgot to re-add it to the example code. Thanks for the reminder, frustratingly we are still having problems though. The cache appears to be fine as we can load it onto a window application that we have and it works fine.
What would be really great would be to be able to find an example mobile application that adds/edits features.
Do you know of anyone who can provide this?
FeatureDataTable fTable = editlayer.GetDataTable(); // creates a new row DataRow editedFeature = fTable.NewRow(); //sets the new geometry to the geometry field editedFeature[editlayer.GeometryColumnIndex] = sketchGraphicLayer1.Geometry; //sets other required fields editedFeature["xxxxxx"] = "xxxxxx"; //sets the new geometry to the feature layer data table fTable.Rows.Add(editedFeature); // updates the feature layer data table fTable.SaveInFeatureLayer();
Hi Karen,
Quick question - by solution do you just mean that you have saved the mobile cache to the device rather than the sd card and now it works?
We have had similar issues and can save to the device fine but not to the sd card which is ok but going forward when we have a range of projects with differing datasets we really need to use multiple sd cards...
I, personally, don't think this is a solution but really just a workaround... and it would be good if the saving to sd card functionality was made available.
Thanks
Tim