Changing Scale

hyderhyder Global Mapper UserPosts: 10
edited September 2011 in SDK
I have a requirement that user will select scale (1:50000...etc) from menu and then map will be redrawn at that scale.
There is a method to get the the last drawn scale, is there a method to change or set the layer drawn scale.


Thanks and regards,
Hyder

Comments

  • Frank2Frank2 Super Moderator Posts: 105
    edited May 2010
    I believe 'GM_CalcScaleRectangle' is what you want to use.
  • hyderhyder Global Mapper User Posts: 10
    edited May 2010
    yes i think this is the required method, few questions,

    1) aCenterPoint, is this point is Lat / Long Center of currentViewRectangle
    2)aPixWidth , is this the width of currentViewReactangle in pixels.

    plz, provide a sample code it is urgent.

    Thanks and regards,
    Hyder
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited May 2010
    Hyder,

    The aCenterPoint parameter should be in whatever your current projection is set to (call GM_GetProjection to get, or GM_SetProjection to set). So this could be lat/lon values, or it might be UTM easting/northing values, or coordinates in any other projection.

    The pixel width and height parameters are the pixel dimensions of the view window that you are trying to calculate a scale rectangle for.

    For example, assuming your projection is Geographic (lat/lon) and you want to get the view rectangle to use for a scale of 1:25000 at a lat/lon of 40N 90W and an output pixel size of 800x600, use the following:

    GM_Point_t theCenterPoint;
    theCenterPoint.mX = -90.0;
    theCenterPoint.mY = 40.0;
    GM_Rectangle_t theScaleRect;
    GM_CalcScaleRectangle( &theCenterPoint, 25000.0, theDC, 800, 600, &theScaleRect );

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • diofantisdiofantis Global Mapper User Posts: 35Trusted User
    edited September 2011
    Hello all,
    I am trying to understand what does the scale variable returns on gm_getlastdrawnscale function?
    i.e. 250000 (= 1:250000) means
    a) 1cm on map equals to 250000 cms
    b) 1inch on map equals to 250000 inches
    c) 1pixel on map equals to 250000 pixels

    Actually my goal is to display in my application the 'map scale' in a different style
    i.e. '250 KM' i.s.o. '1 : (corresponding scale value of 250KM)'

    and i am a little confused about it.

    Note that my map display area is square so 250KM means from one edge (left/top) to the other (right/bottom).

    Any ideas?
    Thanks in advance.
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited September 2011
    The scale value is a unit-less value relating the how much larger distances are on the last draw than in real life. So both your A and B would be correct (it doesn't really apply for pixels but ground distances).

    A scale value with a unit like 250KM is typically not a direct scale ratio like what GM_GetLastDrawnScale reports but corresponds to how long 1 cm or 1 inch on the map is, or sometimes how far across your map is. For how you are describing it, you would want to start with your map center point and calculating the bounding box that goes 125 km in each direction and use that for your view rectangle for drawing.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
Sign In or Register to comment.