How to add more attribute fields to a feature?

JerryLiaJerryLia Global Mapper UserPosts: 26
edited October 2008 in SDK
Mike,
I can add one attribute field to a feature,but have no idea how to add more attribute fields.I write it by myself such as:

GM_AttrValue_t[] lt_AttrValue_t = new GM_AttrValue_t[2];// { mName = "Name01", mVal = ps_Name };
string name = "Name01";
string ps_Name="Value01";
fixed (char* ls_Name = &(name.ToCharArray())[0])
{
lt_AttrValue_t[0].mName = ls_Name;

}
fixed (char* ls_Value = &(ps_Name.ToCharArray())[0])
{
lt_AttrValue_t[0].mVal = ls_Value;

}

name = "Name02";
fixed (char* ls_Name = &(name.ToCharArray())[0])
{
lt_AttrValue_t[0].mName = ls_Name;

}
ps_Name += "2";
fixed (char* ls_Value = &(ps_Name.ToCharArray())[0])
{
lt_AttrValue_t[0].mVal = ls_Value;

}

IntPtr ptr = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(GM_AttrValue_t)));
Marshal.StructureToPtr(lt_AttrValue_t[0], ptr, true);

GM_VectorFeature_t lt_VectorFeature = new GM_VectorFeature_t {Name = ps_Name, Desc = "testDesc", Class = 0, NumAttrs = 2};


Code can be excuted,but it fail to excute the following code:

LastGMError = GlobalMapperDLL.GM_AddAreaToCustomVectorLayer(LayerHandle, ref lt_MyPoint, 0);


Could you give me some advice?


Jerry

Comments

  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited October 2008
    Jerry,

    When setting up your second attribute value you need to use lt_AttrValue_t[1], not lt_AttrValue_t[0].

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
Sign In or Register to comment.