Global Mapper v24.0

How to change line style Global Mapper User
edited February 2014 in SDK
I am trying to change the line style of a loaded shape file but having problems. After reading through many threads. I am still not able to get it to work. Please help. Below is the code I have so far but I get an error that I

Cannot convert type 'GlobalMapperDLLWrapper.GM_LineStyle_t' to 'System.IntPtr'


GM_LineStyle_t tempLineStyle = newGM_LineStyle_t();
tempLineStyle.mPenStyle =

tempLineStyle.mPenWidth =

IntPtr tempLineStylePTR = (IntPtr)tempLineStyle;

GlobalMapperDLL.GM_SetLineFeatureDrawStyle(theLayerHandle, Convert.ToUInt32(5), tempLineStylePTR);


  • global_mapper
    global_mapper Administrator
    edited February 2014
    Try changing the declaration of the GM_LineStyle_t parameter from 'IntPtr' to 'ref GM_LineStyle_t', then you can just directly pass in the tempLineStyle value and the address will be taken automatically. The IntPtr declaration is only there to make it easier to pass in a NULL pointer to reset the style to default. In C# they hide all of the pointer stuff so you have to do things a bit differently to get the address out, you can't just cast.

    Note I would also suggest calling GM_GetLineFeature to get the original line features, then copying the line style from that and changing what you want, then calling GM_SetLineFeatureDrawStyle and GM_FreeLineFeature on the line. That way you only change what you want about the style and not anything else, like the font.


    Global Mapper Guru
    Blue Marble Geographics for Coordinate Conversion, Image Reprojection and Vector Translation
  • Global Mapper User
    edited February 2014
    Thanks Mike, that worked.
Sign In or Register to comment.