How To Create Simple Measure Tool

DanaBDanaB Global Mapper UserPosts: 13
edited February 2012 in SDK
Can you provide me with more info (or even sample code) on how to create a simple Distance Measure Tool using the SDK.

Comments

  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited February 2012
    The code would vary tremendously based on your development environment, but in terms of the SDK you would simply use GM_ConvertCoordPixelToGround to get the coordinates of your click locations in the current projection coordinates, then use GM_CalcDistance to calculate the distance between those 2 points. It is up to you to track the mouse in your own application and report the calculated value however is appropriate for your application.

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    http://www.globalmapper.com
  • DanaBDanaB Global Mapper User Posts: 13
    edited February 2012
    Hi Mike

    Thanks for the quick response.

    Using C#. OK, so the SDK would not provide me with the mouse tracking functionality while the second point is not yet selected.

    Would drawing a "measure line" using the 1st point and then mouse_move positions until the 2nd point is selected be an option? Is this how Global Mapper App is doing the measure tool (without any performance issues)?

    Thanks Dana
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited February 2012
    Dana,

    The SDK sits below the user interface, it doesn't do any mouse handling itself. You would handle the mouse movement in your own code, then if you want to dynamically draw a line just draw that on top of the map. I would definitely make sure to double-buffer the SDK-map display so you just have to BitBlt that on each mouse move then draw the new line on top rather than doing a full new draw. The C++ sample application implements double-buffering for the map display, but the concept is the same in C#.

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    http://www.globalmapper.com
  • DanaBDanaB Global Mapper User Posts: 13
    edited February 2012
    Mike,

    I realized drawing the "measure line" on top of the map is the way to go. I found the double buffering is not required in C# when the DoubleBuffered setting is enabled for that control (in this case the Form).

    Thanks
    Dana
Sign In or Register to comment.