How to resize the map window

jharding@mtaonline.netjharding@mtaonline.net Global Mapper UserPosts: 7
edited February 2014 in SDK
Hello,
I have a treeview docked on the left side of my program and the shapes and maps I load under the treeview. Is there a way to resize the area the map draws to? Or how can I display the map in a picture box or another form window. Thanks in advance for your help.

Comments

  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited February 2014
    The size and position of the map display is entirely determined by the device context that you pass into the draw function and the draw coordinates and pixel dimensions that you provide. So you can put the map window anywhere and even have multiple map windows just by passing in different sets of coordinates and different drawing contexts. The SDK doesn't manage any of that, but the C++ sample application has a GM_MapWindow class that you can use in your own application to simplify some of that.

    Thanks,

    Mike
    Global Mapper Guru
    geohelp@bluemarblegeo.com
    Blue Marble Geographics for Coordinate Conversion, Image Reprojection and Vector Translation
  • GayleShierGayleShier Global Mapper User Posts: 12Trusted User
    edited February 2014
    could you please suggest how to make pixel domentions and coordinates settings right ?
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited February 2014
    If you want to do the same thing as the C++ sample application included with the SDK, just define some hidden control on your dialog or application definition, then get its dimensions at startup and set them in a GM_MapWindow class. The C# sample application just uses the entire client area of the window for the map, but you can do any subset you want. Here is the code from the C++ sample application:

    // Get the map area window and rectangle
    CWnd* theMapWnd = GetDlgItem( IDC_DRAW_WINDOW );
    RECT theMapWndRect;
    theMapWnd->GetWindowRect( &theMapWndRect );
    ScreenToClient( &theMapWndRect );

    // Setup the map window to draw to the dialog window in the area of the
    // IDC_MAP_AREA control
    mMapWindow.SetDrawWindow( GetSafeHwnd() );
    mMapWindow.SetDrawWindowRect( theMapWndRect );

    For the ground coordinates to draw, the sample applications initially set those to the full bounds of all loaded layers, so when you first load some layers it calls GM_GetLayerInfo on each and builds a full union of the bounding rectangles, then uses that as the initial draw rectangle. Then the bounds of that draw rectangle change to zoom in and out and to pan. The pixel draw coordinates do not change unless you actually resize the map window.

    All of the sample applications demonstrate this behavior, so you can check out the sample application in whatever language you are using. The C++ sample app is by far the most extensive though.

    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.