Global Mapper v25.0

Load a custom layer on top of the existing one

mrkrishnan
mrkrishnan Global Mapper User
edited May 2010 in SDK
hai guys,
i am developing one application using Global mapper SDK in MFC.
Now i have loaded the dt1 data as one layer. Now i want to define some custom area on to the map as a new layer. Is it possible?
i.e i want to create a own shape file and load as another layer.
i want to know how to create a shape file.


Thanks in advance
Regards
Radhakrishnan

Comments

  • global_mapper
    global_mapper Administrator
    edited May 2010
    Yes, you can use the GM_CreateCustomVectorLayer function to create a new vector layer, then use the GM_AddAreaToVectorLayer, GM_AddLineToVectorLayer, or GM_AddPointToVectorLayer functions to add new features to those layers. If you want to create a Shapefile, you can then use the GM_ExportVector function to export that layer to a new Shapefile.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • mrkrishnan
    mrkrishnan Global Mapper User
    edited May 2010
    Thank you for your support.
    Now i want to know, is there any API to display the grid with kilometer like lat and long/global projection with some reference Lat/Long?

    Regards
    Radhakrishnan
  • global_mapper
    global_mapper Administrator
    edited May 2010
    Use the GM_DrawGridLines function to draw grid lines on your map.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • mrkrishnan
    mrkrishnan Global Mapper User
    edited May 2010
    i did that already. but that is giving the grid in the format lat/long and projection format, but i want that with every 10 kilometer space.
    i have one more doubt, i wanted to load a dt1 data in a full view in MFC and specified the full area also, but it loaded in some portion only. how can i load that in full size.

    Regards
    Radhakrisnan
  • global_mapper
    global_mapper Administrator
    edited May 2010
    To get a grid with a 10 kilometer spacing, you need to set your projection to a projected system (like UTM, or anything else with linear units), then provide a grid spacing equal to 10 km in the units of the current projection (like 10000.0 if the units are GM_PRJ_UNIT_METERS).

    Whenever you load a file, like a DT1 file, the entire file will be loaded. You can however specify for just a portion to draw by using the rectangle bounds parameter to the draw function.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • mrkrishnan
    mrkrishnan Global Mapper User
    edited May 2010
    As you replied the entire file loaded properly, but i specified the full window size as drawing area, but it is loading in some portion only instead of full window size. Because of this issue when i tried to draw the grid that also drawn in that portion only.

    i have just added some portion of code for your reference

    void CGlobalMapperTestAppView::OnSize(UINT nType, int cx, int cy)
    {
    CView::OnSize(nType, cx, cy);

    RECT theMapWndRect;
    /*GetSafeOwner()->*/GetClientRect( &theMapWndRect );
    // ScreenToClient( &theMapWndRect );

    mMapWindow.SetDrawWindow( GetSafeHwnd());
    mMapWindow.SetDrawWindowRect( theMapWndRect );
    }

    i call this portion when user load a new layer
    void CGlobalMapperTestAppView::OnLoadNewlayer()
    {
    if ( GM_Error_None == mMapWindow.LoadLayer() )
    {
    // Refill our layer list
    GM_SetBackgroundColor(RGB(255, 255, 0)) ;
    FillLayerList();
    mMapWindow.ZoomIn(2.0) ;
    }
    }

    regards
    Radhakrishnan
  • global_mapper
    global_mapper Administrator
    edited May 2010
    It looks like in your OnLoadNewlayer function that for the first file that is loaded you will zoom in by a factor of 2 on the center of that data as the initial load view will be to all loaded data. For subsequent loads where something is already loaded, you will just zoom in by a factor of 2.0 on your current view rather than a factor of 2 on the bounds of all loaded data. If you want to always zoom in on all loaded data, add a call to mMapWindow.ZoomToAllLayers() after your mMapWindow.LoadLayer() call.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • mrkrishnan
    mrkrishnan Global Mapper User
    edited May 2010
    Because of the full area loading problem i just did that zoom to make that in full view. Just i have attached the output for your reference.
  • global_mapper
    global_mapper Administrator
    edited May 2010
    Is there any further issue or have you got everything figured out?

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • mrkrishnan
    mrkrishnan Global Mapper User
    edited May 2010
    in that figure it shows that is loaded in some portion only, but i want that is to be loaded in full window size.

    Thanks and Regards
    Radhakrishnan
  • global_mapper
    global_mapper Administrator
    edited May 2010
    You control what the ground coordinate are of your view window when you draw. Just modify the draw rectangle that you pass into the draw function (or use GM_MapWindow::SetCurrentViewRect) to draw just what you want to draw.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • mrkrishnan
    mrkrishnan Global Mapper User
    edited May 2010
    Thanks for your patient mike, but still i couldn't get that in full view after used SetCurrentViewRect function also.
  • global_mapper
    global_mapper Administrator
    edited May 2010
    Maybe I'm misunderstanding what you want to do, but I think what you may be seeing is because by default the draw maintains the aspect ratio of the data bounding rectangle that you pass in to the GM_DrawLayerList function in relationship to the aspect ratio of the pixel area being drawn. So your draw rectangle will be grown vertically or horizontally until the aspect ratio matches the pixel ratio to avoid stretching.

    If you really the exact rectangle that you provide to be drawn and don't care about stretching, pass in the GM_DrawFlags_DontMaintainAspectRatio draw flag to the GM_DrawLayerList function.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • mrkrishnan
    mrkrishnan Global Mapper User
    edited May 2010
    Thanks mike i have got it.