Display scale bar with GM_DrawLayerList

ApliesAplies Global Mapper UserPosts: 35Trusted User
edited May 2013 in SDK
Hello,

I have a problem to display a scale bar with the function "GM_DrawLayerList" and the flag "GM_DrawFlags_t32.GM_DrawFlags_DrawMapLayoutLayers".
Actually, the scale bar is displayed and works but I use the function "GM_DrawLayerList" to get a bitmap of my layers one by one (cause I save these bitmaps independently). So, I set the paramater "int aLayerCount" to 1 for each call :
lastGMError = GlobalMapperDLL.GM_DrawLayerList
                (
                Hdc,
                layerToDraw,
                1,
                GlobalMapperDLL.GM_DrawFlags_t32.GM_DrawFlags_DrawMapLayoutLayers,
                ref currentViewRect,
                0,
                0,
                widthGraphic,
                heightGraphic
                );

Now, my problem. I get a pointer of a layer from my database with the function "GM_LoadLayerListEx". When I pass this pointer to the function "GM_DrawLayer" (not "GM_DrawLayerList"), I have the right Bitmap of the layer. But when I use "GM_DrawLayerList", I have "GM_Error_InvalidLayer".
Moreover, if I set the parameter "int aLayerCount" to 0 (to draw all layers in the list whereas I have always only one), it works but the generated Bitmap has all previous layers drawn and not only the one that I passed in parameter (I already verified the paramater "layerToDraw").

Best regards,

Tristan

Comments

  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited May 2013
    Tristan,

    If you use GM_DrawLayerList the layer list parameter is the address of an array of GM_LayerHandle_t32 types and not just the actual layer handle value for GM_DrawLayer. For just a single layer you can just pass in the address of that one value with a value of 1. For multiple layers you would need to allocate a contiguous chunk of memory, which gets slightly more complex in languages that hide all that stuff.

    If you will only ever need to draw all or none, define the layer list as 'ref GM_LayerHandle_32' in the declaration for GM_DrawLayerList. That will then get the address of your variable automatically and pass that in, which is essentially an array of length 1.

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    Blue Marble Geographics for Coordinate Conversion, Image Reprojection and Vector Translation
  • ApliesAplies Global Mapper User Posts: 35Trusted User
    edited May 2013
    Mike,

    Thank you very much, it works prefectly with "ref GM_LayerHandle_32" !

    Best regards,

    Tristan
  • ApliesAplies Global Mapper User Posts: 35Trusted User
    edited May 2013
    Hello,

    I think the last release of SDK on your website ("http://www.bluemarblegeo.com/products/global-mapper-sdk-download.php";) don't have the correction for connection with a spatial database. When I use this last release, I have the same problems than old release. So I use the release that you gave me in a post on the forum.

    Just for information. If it is a mistake from me, sorry.

    Best regards,

    Tristan
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited May 2013
    Tristan,

    We haven't official released a new SDK since that fix so it's not out there on the normal download page. We should officially release a new one in a week or two though that will include that fix. It will then be v14.2.0.

    Thanks,

    Mike
    Global Mapper Guru
    geohelp@bluemarblegeo.com
    Blue Marble Geographics for Coordinate Conversion, Image Reprojection and Vector Translation
Sign In or Register to comment.