Point feature label position

srisri Global Mapper UserPosts: 12
edited February 2010 in SDK
Hi,

I am trying to modify the label position of point features (using the SDK in C#) and regardless of the placement enum that I select the label always gets positioned at the centre of the point.

Here's how I am trying to do this:

GM_FontDef_t font = new GM_FontDef_t();
font.mPlacement = GM_LabelPlacement_t8.GM_LABEL_TOP;

where

public struct GM_FontDef_t
{
...
public GM_LabelPlacement_t8 mPlacement;
...
}

public enum GM_LabelPlacement_t8 : byte
{
GM_LABEL_AUTO = 0,
GM_LABEL_CENTER = 1,
GM_LABEL_TOP_RIGHT = 2,
GM_LABEL_RIGHT = 3,
GM_LABEL_BOTTOM_RIGHT = 4,
GM_LABEL_BOTTOM = 5,
GM_LABEL_BOTTOM_LEFT = 6,
GM_LABEL_LEFT = 7,
GM_LABEL_TOP_LEFT = 8,
GM_LABEL_TOP = 9,

GM_LABEL_NUM_PLACEMENTS
};

Thanks in advance

Comments

  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited February 2010
    Can you show me the call that you are making to modify the font for a point feature?

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • srisri Global Mapper User Posts: 12
    edited February 2010
    sure thing...

    GM_PointStyle_t style = new GM_PointStyle_t();
    style.mFont = font;

    and i'm using GM_SetPointFeatureDrawStyle to set the style.

    Cheers
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited February 2010
    Can you show me your actual GM_SetPointFeatureDrawStyle call and all of the code where you set this up? If you call GM_GetPointFeatureDrawStyle after setting it, does it return the new style that you just set?

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • srisri Global Mapper User Posts: 12
    edited February 2010
    The call to set the draw style is as follows:

    SetDrawStyle(IntPtr layerHandle, UInt32 pointIndex, GM_PointStyle_t aPointStyle)
    {

    IntPtr ipPointStyle = Marshal.AllocCoTaskMem(Marshal.SizeOf(aPointStyle));
    Marshal.StructureToPtr(aPointStyle, ipPointStyle, false);
    GMWrapper.GM_SetPointFeatureDrawStyle(layerHandle, pointIndex, ipPointStyle);
    Marshal.FreeCoTaskMem(ipPointStyle);

    }

    I have successfully set the font face name, point size and weight using the above call. When trying to retrieve the style I couldn't find a function called GM_GetPointFeatureDrawStyle, only GM_GetPointFeatureClassDrawStyle. Is this the function you intended?

    Additionally, can you confirm if the function GM_SetVectorDrawScale scales the size of the labels?

    Many thanks.
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited February 2010
    I took a look and discovered that there was a problem with the label placement value not actually being stored when you updated a point style. I have placed a new build of the SDK with this fixed at http://www.globalmapper.com/GlobalMapperSDK_v133_beta.zip for you to try.

    To get the style of an existing point, use the GM_GetPointFeature function. The mPointStyle member of the returned structure will contain the current style. Then update that to change the style and pass it back in via GM_SetPointFeatureDrawStyle. Remember to call GM_FreePointFeature after a call to GM_GetPointFeature.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • srisri Global Mapper User Posts: 12
    edited February 2010
    Thanks Mike, that works just fine now.
Sign In or Register to comment.