MapInfo Pro

  • 1.  MapInfo Monday: Smart Text Adornment in the Map window

    Posted 10-18-2021 06:33
    Edited by Peter Horsbøll Møller 10-19-2021 16:23

    Happy #MapInfoMonday,

    In the article today, we will look at another small improvement we brought to you with MapInfo Pro v2021. If you read the article on Time Series, you noticed how I added Smart Text Adornments to the map ​showing information about the current time period for the time series.

    You can use these Smart Text Adornments in a normal map, too. They can be smart, or dynamic if you prefer, or just plain static text.

    Adding Smart Text Adornments

    You can add these Smart Text Adornments from the Map tab via the Add To Map dropdown.


    You will be presented with the dialog Smart Text where you can control the Smart Text expression, the font and the position of the adornment in your map.


    By default, the dialog will add a Map Title to the map using the name of the map window. You can however change this to a different MapBasic expression to show different values on your map.


    As these adornments are dynamic, they will change if you for example rename your map as I have done below.


    You can use any MapBasic expression as an adornment on your map but of course, they probably make the most sense if they in some way refer to the map or the window.

    Here are a few other examples of expressions.

    You can show the name of the coordinate system on the map.


    And you can show the current cartographic scale on the map.


    Below you can see an example of a map with a map title, and the cartographic scale as well as the coordinate system name.

    The expression for Smart Text Adornment

    The basic expression for a Smart Text adornment looks like this:
    • $mb{WindowInfo(CurContext(4), WIN_INFO_NAME)}
    Let's break this into the three core elements
    • $mb{}: Tells MapInfo Pro to treat the content inside the {} as a MapBasic expression. In the layout window, you can also use ${} which would tell MapInfo Pro to look for the Alias in the Smart Text Alias file. This is currently not supported in the Smart Text Adornments in the map window.
    • WindowInfo(): Is a standard MapBasic function that can give you details about the window, such as name, type, and size.
    • CurContext(4): Is a MapBasic function that refers to the content where it's being used. Typically you would use CurContext() to get the ID of a window or similar. That's how it's used here where 4 refers to the ID of the map window.
    A couple of other useful Smart Text expressions
    • $mb{MapperInfo(CurContext(4), MAPPER_INFO_CARTO_SCALE_EXPR)}: Current cartographic scale of the map
    • $mb{MapperInfo(CurContext(4), MAPPER_INFO_COORDSYS_NAME)}: Name of the coordinate system of the map
    • $mb{MapperInfo(CurContext(4), MAPPER_INFO_MINX)}: X coordinate of the lower-left corner of the map
    • $mb{MapperInfo(CurContext(4), MAPPER_INFO_MAXX)}: X coordinate of the upper-right corner of the map
    • $mb{MapperInfo(CurContext(4), MAPPER_INFO_MINY)}: Y coordinate of the lower-left corner of the map
    • $mb{MapperInfo(CurContext(4), MAPPER_INFO_MAXY)}: Y coordinate of the upper-right corner of the map
    • $mb{MapperInfo(CurContext(4), MAPPER_INFO_ZOOM)}: Zoom width of the map
    • $mb{MapperInfo(CurContext(4), MAPPER_INFO_DISTUNITS)}: Abbreviated distance units of the map, for example, "km" or "mi"
    • $mb{MapperInfo(CurContext(4), MAPPER_INFO_AREAUNITS)}: Abbreviated area units of the map, for example, "sq km" or "sq mi"
    You can also combine multiple expressions inside the {} to return a complex text string or multiple lines.
    • $mb{"Title: " + WindowInfo(CurContext(4), WIN_INFO_NAME)}: Combines a fixed string in "" with the value returned from a MapBasic function
    • $mb{MapperInfo(CurContext(4), MAPPER_INFO_CARTO_SCALE_EXPR) + Chr$(10) + MapperInfo(CurContext(4), MAPPER_INFO_COORDSYS_NAME)}: Combines the result from two MapBasic functions as a single string on two lines. The function Chr$(10) returns a new line character.

    You have earlier been able to add Smart Text like these to your layout and now you can also add them directly onto your map window, and maintain these when you print or export your map.

    What will you use this new capability to do?



    ------------------------------
    Peter Horsbøll Møller
    Principal Presales Consultant | Distinguished Engineer
    Precisely | Trust in Data
    ------------------------------


  • 2.  RE: MapInfo Monday: Smart Text Adornment in the Map window

    Employee
    Posted 10-18-2021 10:49
    One minor correction: re - you can also use ${} which would tell MapInfo Pro to look for the Alias in the Smart Text Alias file.
    We currently do not support Aliases in map smart text adornments.


    ------------------------------
    Bob Fortin
    Software Architect and Distinguished Engineer
    MapInfo Pro Development Team
    ------------------------------



  • 3.  RE: MapInfo Monday: Smart Text Adornment in the Map window

    Posted 10-19-2021 16:24
    Thanks, Bob. I had forgotten about that current limitation. I have modified my article to mention this limitation.

    ------------------------------
    Peter Horsbøll Møller
    Principal Presales Consultant | Distinguished Engineer
    Precisely | Trust in Data
    ------------------------------