How to change line style
jharding@mtaonline.net
Global Mapper User
Hello,
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'
Code:
GM_LineStyle_t tempLineStyle = newGM_LineStyle_t();
tempLineStyle.mPenStyle =
GM_PenStyle_t16.GM_PEN_DIAMONDS_RIGHT;
tempLineStyle.mPenWidth =
Convert.ToByte(2);
IntPtr tempLineStylePTR = (IntPtr)tempLineStyle;
GlobalMapperDLL.GM_SetLineFeatureDrawStyle(theLayerHandle, Convert.ToUInt32(5), tempLineStylePTR);
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'
Code:
GM_LineStyle_t tempLineStyle = newGM_LineStyle_t();
tempLineStyle.mPenStyle =
GM_PenStyle_t16.GM_PEN_DIAMONDS_RIGHT;
tempLineStyle.mPenWidth =
Convert.ToByte(2);
IntPtr tempLineStylePTR = (IntPtr)tempLineStyle;
GlobalMapperDLL.GM_SetLineFeatureDrawStyle(theLayerHandle, Convert.ToUInt32(5), tempLineStylePTR);
Comments
-
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.
Thanks,
Mike
Global Mapper Guru
geohelp@bluemarblegeo.com
Blue Marble Geographics for Coordinate Conversion, Image Reprojection and Vector Translation -
Thanks Mike, that worked.
Categories
- 12.7K All Categories
- 5.6K Features Discussion
- 342 Downloading Imagery
- 1.3K Elevation Data
- 380 Georeferencing Imagery Discussion
- 628 GM Script Language
- 53 User Scripts
- 113 GPS Features
- 414 Projection Questions
- 819 Raster Data
- 1.3K Vector Data
- 6.6K Support
- 177 Announcement and News
- 908 Bug Report
- 558 SDK
- 1.2K Suggestion Box
- 3.7K Technical Support
- 562 Other Discussion
- 129 GIS Data Sources
- 27 Global Mapper Showcase
- 233 How I use Global Mapper
- 107 Global Mapper Forum Website