Mapinfo 16 - Mapbasic - Layout Designer - Adding a named map window

278 views
Skip to first unread message

Matthew Hirsch

unread,
Apr 3, 2018, 6:46:06 PM4/3/18
to MapInfo-L
I had a great little script that would auto save map images based on a grid layer.    Unfortunately, with the new, and unwanted static layout window, my script no longer works so I am having to rewrite.   

My current code selects a grid number, zooms in to the grid, then (as a result of the static layout) opens a new layout designer and tries to fill the layout with the correct map data.

That said, I am trying to open a layout window, create a frame of a specific size, then call a map window that I rename higher in the code.   
This script is generic so can be used with any maps with a grid layer; they are not always the same layer  names or number of layers.     I tried to do the process manually to get the code, but in layout designer, when I select "Add new map" and then choose the named map window, it looks like it recreates the map.

Is there a way to code MB to add the named window rather than have it do all the layers like a workspace file?   

I'd like to do this.

Layout Designer
Set Coordsys Layout Units "in" Create Frame (0.184,0.1882) (16.8319,10.7396) Name "MapLayout" 
Set Designer Frame Id 1 From Window MYNAMEDMAP Legends On   

Rather than 

Layout Designer
Set Coordsys Layout Units "in" Create Frame (0.184,0.1882) (16.8319,10.7396) Name "MapLayout" 

Set Designer Frame Id 1 From Window 3174 Legends On
Map From GRID,GRID,GRID,RT_RG,MULTI
  ,SINGLE,USZIP,BGDEMOPD,BingHybrid,BingRoads
  Width 7.875 Units "in" Height 9.22917 Units "in" Floating
  Pen (1,2,0)    Into Window 3200 Id 1 
Set Window WindowID(0) Front
Set Window FrontWindow() ScrollBars Off Autoscroll On Enhanced On Smooth Text Antialias Image High Vector None
Set Map Redraw Off
Set Map
  CoordSys Earth Projection 10, 157, "m", 0
  Center (-13663649.24,4646610.635)
  Zoom 1.159692678 Units "mi"
  Preserve Zoom Display Zoom
  Distance Units "mi" Area Units "sq mi" XY Units "degree"
Set Map
  Layer 1
    Display Off
    Global Pen (2,2,255) Brush (1,16777215,16777215) Symbol (35,0,12) Line (1,2,0) Font ("Arial",0,9,0)
    Selectable Off
    Label Line None Position Center Font ("Arial",1,8,0,16776960) Pen (1,2,0) 
      With MAP
      Parallel On Auto On Overlap On Duplicates On PartialSegments On Offset 0
      Visibility On
  Layer 2
    Display Global
    Global Pen (2,2,255) Brush (1,16777215,16777215) Symbol (35,0,12) Line (1,2,0) Font ("Arial",0,9,0)
    Selectable Off
    Label Line None Position Center Font ("Arial",1,8,0,16776960) Pen (1,2,0) 
      With MAP
      Parallel On Auto On Overlap On Duplicates On PartialSegments On Offset 0
      Visibility On
  Layer 3
    Display Global
    Global Pen (2,2,255) Brush (1,16777215,16777215) Symbol (35,0,12) Line (1,2,0) Font ("Arial",0,9,0)
    Selectable Off
    Label Line None Position Below Font ("Arial",1,8,16777215,16711680) Pen (1,2,0) 
      With QTY
      Parallel On Auto On Overlap On Duplicates On PartialSegments On Offset 6
      Visibility On
  Layer 4
    Display Global
    Global Pen (1,2,0) Brush (2,16777215,16777215) Symbol (34,65280,5) Line (1,2,0) Font ("Arial",0,9,0)
    Selectable Off
    Label Line Arrow Position Right Font ("Arial",0,9,0) Pen (1,2,0) 
      With ADDRESS_ID
      Parallel On Auto Off Overlap Off Duplicates On Offset 2
      Visibility On
  Layer 5
    Display Global
    Global Pen (1,2,0) Brush (2,16777215,16777215) Symbol (31,16711680,7) Line (1,2,0) Font ("Arial",0,9,0)
    Selectable Off
    Label Line Arrow Position Right Auto Retry On Font ("Arial",257,7,16711680,16777215) Pen (1,2,0) 
      With LABEL
      Parallel On Auto On Overlap Off Duplicates On PartialSegments On Offset 2
      Visibility Zoom (0, 10) Units "mi"
  Layer 6
    Display Off
    Global Pen (1,2,0) Brush (2,16777215,16777215) Symbol (32,255,7) Line (1,2,0) Font ("Arial",0,9,0)
    Selectable Off
    Label Line Arrow Position Right Auto Retry On Font ("Arial",257,7,255,16777215) Pen (1,2,0) 
      With LABEL
      Parallel On Auto On Overlap Off Duplicates On PartialSegments On Offset 2
      Visibility Zoom (0, 10) Units "mi"
  Layer 7
    Display Off
    Global Pen (1,2,0) Brush (2,16777215,16777215) Symbol (35,0,12) Line (1,2,0) Font ("Arial",0,9,0)
    Label Line None Position Center Font ("Arial",0,9,0) Pen (1,2,0) 
      With CODE
      Parallel On Auto Off Overlap Off Duplicates On Offset 2
      Visibility On
  Layer 8
    Display Off
    Global Pen (1,2,0) Brush (2,16777215,16777215) Symbol (35,0,12) Line (1,2,0) Font ("Arial",0,9,0)
    Label Line None Position Center Font ("Arial",0,9,0) Pen (1,2,0) 
      With CODE
      Parallel On Auto Off Overlap Off Duplicates On Offset 2
      Visibility On
  Layer 9
    Display Global
    Global Pen (1,2,16711935)  Brush (15,13672703)  Symbol (59,255,10)  Line (1,2,0)  Font ("Arial",0,9,0)
    Selectable Off
  contrast 40 
  brightness 60 
  alpha 255 
    transparency off 
  color 0 
    grayscale on 
  Layer 10
    Display Off
    Global Pen (1,2,0)  Brush (2,16777215,16777215)  Symbol (35,0,12)  Line (1,2,0)  Font ("Arial",0,9,0)
    Selectable Off
  contrast 50 
  brightness 50 
  alpha 255 
    transparency off 
  color 0 
    grayscale on 
Set Map Layer 0 Editable
Set Map Redraw On
Set Window FrontWindow() Title "FullMap"
Set Window FrontWindow() Printer
 Name "\\dc01\RicohC5200S" Orientation Landscape Copies 1
 Papersize 17

Thank you.

Peter Horsbøll Møller

unread,
Apr 3, 2018, 11:21:43 PM4/3/18
to mapi...@googlegroups.com

Hi Matt

 

I tend to see the new layout as more dynamic compared to the old layout window.

Maybe you aren’t aware but the “map image” in the new layout is basically a real map.

 

You can grab that map and change the center and/or zoom of this instead of creating a completely new layout.

 

Peter Horsbøll Møller

Pitney Bowes

--
--
You received this message because you are subscribed to the
Google Groups "MapInfo-L" group.To post a message to this group, send
email to mapi...@googlegroups.com
To unsubscribe from this group, go to:
http://groups.google.com/group/mapinfo-l/subscribe?hl=en
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at
http://groups.google.com/group/mapinfo-l?hl=en

---
You received this message because you are subscribed to the Google Groups "MapInfo-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapinfo-l+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michele Buselli

unread,
Apr 4, 2018, 9:07:43 AM4/4/18
to MapInfo-L
You can refer to the map window by its window identifier in the Set Designer Frame statement. Get the window identifier of your map window using FrontWindow() right after you create it. Then pass that value as the argument to the From Window clause:

Set Designer Frame Id 1 From Window win_id_of_map Legends On
Reply all
Reply to author
Forward
0 new messages