MapInfo Pro

 View Only
  • 1.  Map Scale Smart Text

    Posted 05-20-2022 13:45
    When using Smart Text to display map scale in a layout, are there any formatting options available?  I have a set of maps that I'm printing at 1"=60' and sometimes the text displayed will change to will change to something like 1"=60.0000012'.  Can you format it to only display whole numbers?

    ------------------------------
    Jim
    ------------------------------


  • 2.  RE: Map Scale Smart Text

    Employee
    Posted 05-23-2022 08:34
    Jim

    What Smart Text are you using? Can you share the expression?

    I tried configuring a couple of SmartText to display the scale.

    The top one is showing the cartographic scale and the bottom one is showing the map scale

    The expressions for the two examples are like this:
    ${MapCartographicScale}: referring to a SmartText alias for this expression: $mb{"Scale: " + MapperInfo(LayoutItemWinID(CurContext(1), 1, LAYOUT_ITEM_TYPE_MAPPER), MAPPER_INFO_CARTO_SCALE_EXPR)}

    and this custom SmartText expression:
    $mb{"1 cm = " + MapperInfo(LayoutItemWinID(CurContext(1), 1, LAYOUT_ITEM_TYPE_MAPPER), MAPPER_INFO_SCALE) + " " +MapperInfo(LayoutItemWinID(CurContext(1), 1, LAYOUT_ITEM_TYPE_MAPPER), MAPPER_INFO_DISTUNITS)}

    The second expression, I can improve to round the value to the nearest integer and format using my regional settings:
    $mb{"1 cm = " + FormatNumber$(Round(MapperInfo(LayoutItemWinID(CurContext(1), 1, LAYOUT_ITEM_TYPE_MAPPER), MAPPER_INFO_SCALE), 1)) + " " +MapperInfo(LayoutItemWinID(CurContext(1), 1, LAYOUT_ITEM_TYPE_MAPPER), MAPPER_INFO_DISTUNITS)}

    Please note that my expression expects you to use cm as your paper units. If you are using different units, change it to the appropriate units in the string, such as inch:
    $mb{"1 in = " + FormatNumber$(Round(MapperInfo(LayoutItemWinID(CurContext(1), 1, LAYOUT_ITEM_TYPE_MAPPER), MAPPER_INFO_SCALE), 1)) + " " +MapperInfo(LayoutItemWinID(CurContext(1), 1, LAYOUT_ITEM_TYPE_MAPPER), MAPPER_INFO_DISTUNITS)}

    Would this work for you too?

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



  • 3.  RE: Map Scale Smart Text

    Posted 05-23-2022 08:44

    I used the samples in the MapInfo Pro User Guide:

     

    Scale 1 in = $mb{MapperInfo(LayoutItemInfo(CurContext(1), "Main Map",
    5), 2)} $mb{MapperInfo(LayoutItemInfo(CurContext(1), "Main Map", 5),
    12)}

     

    And this one.

     

    Scale 1 in = $mb{MapperInfo(LayoutItemWinID(CurContext(1), "Main Map",
    1), 2)} $mb{MapperInfo(LayoutItemWinID(CurContext(1), "Main Map", 1),
    12)}

     

    I had originally used the one for cartographic scale, but I need to use map scale, as everyone is used to seeing 1" = xxx ft on all of our maps.

     

    Thanks,

    Jim

     






  • 4.  RE: Map Scale Smart Text

    Posted 05-23-2022 09:22

    The rounding works great, until I run Site Mapper.  It seems to still want to force it to miles, instead of ft like the map is set to, so it rounds to 0 when printing.  I don't want you to keep spending time on it though, we can just use static text to display our scale and stick with printing one scale at a time.  I really appreciate your assistance though, and for letting me know about Site Mapper. 

     

    Jim

     






  • 5.  RE: Map Scale Smart Text

    Employee
    Posted 05-24-2022 02:28
    Hi Jim

    Two things:
    1. Can you verify that the distance unit is still feet on the map in the frame? Just wanted to make sure that the SiteMapper tool doesn't change that by mistake
    2. What version of MapInfo Pro are you using? I recall we had some issues with SmartText referencing windows where it sometimes changed from one window to another. That should have been fixed in the latest version of MapInfo Pro, v2021.1.

    Thanks

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



  • 6.  RE: Map Scale Smart Text

    Posted 05-24-2022 10:10

    I'm using v2021.1.  I can't check, because it only changes to miles during the printing process.  Once it's done, I check the map options and it is in feet, but also the smart text goes back to showing ft too.  Seems like Site Mapper is forcing a temporary change to miles, while it prints.

     

    Thanks,

    Jim

     






  • 7.  RE: Map Scale Smart Text

    Posted 08-26-2022 11:28
    This, along with the thread here, were really useful in some work I'm doing with layout templates.  Thanks so much Peter and Jim for asking the question.

    Best wishes

    David Squires
    Definitive Map Review Officer
    Nottinghamshire County Council
    UK


    ------------------------------
    David Squires
    Knowledge Community Shared Account
    ------------------------------



  • 8.  RE: Map Scale Smart Text

    Posted 08-29-2022 20:44
    Hi @Peter Møller,
    Saw this thread come up in recent feed and thought i would share a finding in regard to smart text map units. To put it simply i use the following code:
    $mb{MapperInfo(LayoutItemInfo(CurContext(1), "Map-1", 5), 33)} ( 1 $mb{SessionInfo(4)} = $mb{MapperInfo(LayoutItemInfo(CurContext(1), "Map-1", 5), 2)} $mb{MapperInfo(LayoutItemInfo(CurContext(1), "Map-1", 5), 12)})​

    to give me the following result, however you will notice when inspecting the actual map scale of the layout map that the smart text is showing in meters and has simply just adjusted the unit type, i'm not good with coding but is this expected behaviour with what i am using:

    The only way i can find to change the scale to actual KM values is to change it in system settings:

    Thoughts.

    ------------------------------
    Joel Cranston
    Lockyer Valley Regional Council
    ------------------------------



  • 9.  RE: Map Scale Smart Text

    Employee
    Posted 08-30-2022 02:03
    I like your solution, Joel. It shows the values and the units used to calculate these.

    Currently, the SmartText expressions probably are at their limit as very few MapBasic functions take units as parameters. That would have been a way around these issues.

    In a MapBasic application, you could change the units for the map and then extract the values you are looking for in the right units. You can also use these for SmartText if you create an application and use the IMBXRegisterPublicFunction method to publish a custom function to MapInfo Pro. In this way, you can create your own functions and make them available to the user of MapInfo Pro. It does of course require that the application is running.

    I have touched upon this in an earlier thread here on the MapInfo Community.

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