Posts Tagged ‘MapObjects’

Add a record using MapObjects

April 16, 2008

To add a record to the attribute table, you need to add a record the the shapefile (i.e. you need to add a shape as well). In order to do that you need to follow the procedure below.Get a reference to the layer

Get the recordset for the layer
call the addnew method on the recordset
populate the fields for the new record with data (including the shape field)
call the update method on the recordset to commit the new data

You can not (and should not) add records the attribute table of a shapefile outside of an application (such as MO) that is aware of the linkage between the attribute records and shape records.

To add a field to the attribute table you have a few options. The first is to create a new shapefile based on the old one with the new field added, then to copy all of the data from the old shapefile to the new shapefile using MO methods. This is the safest option, and can be done completely using MO methods. A second choice is to use a non-MO based tool (such as ADO) to add the field the to dBase file. You’ll need to make sure that no map layers refer to the shapefile BEFORE attempting this, but it does save the time/trouble of having to copy the data. Once the new field is added you can query and populate the field using MO methods.

One interesting note is that recordset Fields property returns random order of fields in a collection. If you want to access the fields in their actual physical order, then do not use the Recordset’s Fields property. Rather use the Recordset’s TableDesc Property. The only fields not in the TableDesc are the “Shape” field, and the virtual, internal “FeatureID” field. The only fields which show up in the TableDesc are the fields physically stored in the *.dbf portion of the shapefile.

Another point is that there is no direct method to DELETE any field in a shapefile or feature class using MapObjects. 

MapObjects and Visual Studio compatability

April 10, 2008

MapObjects 2.2 was designed, tested, and supported for use with Visual Studio .NET (from 2002), which uses the .NET Framework v1.0. Unfortunately, it is not supported for use with Visual Studio 2005, which uses the .NET Framework v2.0. It may just work, but we have not tested it. For one, the MapObjects installer only knows how to look for the version 1.0 GAC, so at a minimum, you would have to do part of the installation manually, depending on how comfortable you are with modifying the development environment and the .NET framework.

Even the most recent version of MapObjects-Windows Edition, version 2.4 does not support Visual Studio 2005.

It is unfornuate that ESRI will end MapObjects Supports soon and discontinue the product.

MapObjects Evaluation Version

April 9, 2008

Jim Barry of ESRI writes  “We are sorry to report that free copies of MapObjects software are no longer available for evaluation.”

ESRI highly recommends that you consider using ArcGIS Engine if you want to use embeddable mapping and GIS components in your application’s design. The easiest and least expensive way to get the ArcGIS Engine developer kit is to subscribe to the ESRI Developer Network. More information here:

Great product from ESRI finally ends in peace. I love MapObjects!